Displays only invoked tests in fuel health output
Currently we're showing last tests in fuel health output, so if you run sanity checks: $ fuel health --env X --check sanity and then run platform_tests checks: $ fuel health --env X --check platform_tests the fuel health shows both sanity and platform_tests testsets (since sanity checks was ran recently). That's wrong behaviour, so since now we're going to show only those tests which was ran by user. Change-Id: I3ae09a99f2492713a0787a373aadc97ff646bddb Closes-Bug: #1387157
This commit is contained in:
parent
996af97cc3
commit
42acd8c2d3
@ -52,6 +52,10 @@ class Environment(BaseObject):
|
||||
data = cls.connection.post_request("clusters/", data)
|
||||
return cls.init_with_data(data)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Environment, self).__init__(*args, **kwargs)
|
||||
self._testruns_ids = []
|
||||
|
||||
def set(self, data):
|
||||
if data.get('mode'):
|
||||
data["mode"] = "ha_compact" \
|
||||
@ -308,7 +312,7 @@ class Environment(BaseObject):
|
||||
return data["is_customized"]
|
||||
|
||||
def is_in_running_test_sets(self, test_set):
|
||||
return test_set["testset"] in self._test_sets_to_run,
|
||||
return test_set["testset"] in self._test_sets_to_run
|
||||
|
||||
def run_test_sets(self, test_sets_to_run):
|
||||
self._test_sets_to_run = test_sets_to_run
|
||||
@ -322,17 +326,18 @@ class Environment(BaseObject):
|
||||
},
|
||||
test_sets_to_run
|
||||
)
|
||||
return self.connection.post_request(
|
||||
"testruns",
|
||||
tests_data,
|
||||
ostf=True
|
||||
)
|
||||
|
||||
testruns = self.connection.post_request(
|
||||
"testruns", tests_data, ostf=True)
|
||||
self._testruns_ids = [tr['id'] for tr in testruns]
|
||||
return testruns
|
||||
|
||||
def get_state_of_tests(self):
|
||||
return self.connection.get_request(
|
||||
"testruns/last/{0}".format(self.id),
|
||||
ostf=True
|
||||
)
|
||||
return [
|
||||
self.connection.get_request(
|
||||
"testruns/{0}".format(testrun_id), ostf=True)
|
||||
for testrun_id in self._testruns_ids
|
||||
]
|
||||
|
||||
def stop(self):
|
||||
return Task.init_with_data(
|
||||
|
56
fuelclient/fuelclient/tests/test_environment.py
Normal file
56
fuelclient/fuelclient/tests/test_environment.py
Normal file
@ -0,0 +1,56 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
|
||||
from fuelclient.objects.environment import Environment
|
||||
from fuelclient.tests import base
|
||||
|
||||
|
||||
class TestEnvironmentOstf(base.UnitTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestEnvironmentOstf, self).setUp()
|
||||
|
||||
self.env = Environment(None)
|
||||
|
||||
@mock.patch.object(Environment.connection, 'post_request', mock.Mock(
|
||||
return_value=[
|
||||
{'id': 1},
|
||||
{'id': 2}, ]))
|
||||
def test_run_test_sets(self):
|
||||
self.assertEqual(self.env._testruns_ids, [])
|
||||
|
||||
testruns = self.env.run_test_sets(['sanity', 'ha'])
|
||||
|
||||
self.assertEqual(len(testruns), 2)
|
||||
self.assertIn(1, self.env._testruns_ids)
|
||||
self.assertIn(2, self.env._testruns_ids)
|
||||
|
||||
@mock.patch.object(Environment.connection, 'get_request', mock.Mock(
|
||||
side_effect=[
|
||||
{'id': 1, 'status': 'running'},
|
||||
{'id': 2, 'status': 'finished'}, ]))
|
||||
def test_get_state_of_tests(self):
|
||||
self.env._testruns_ids.extend([1, 2])
|
||||
tests = self.env.get_state_of_tests()
|
||||
|
||||
self.env.connection.get_request.assert_has_calls([
|
||||
mock.call('testruns/1', ostf=True),
|
||||
mock.call('testruns/2', ostf=True)])
|
||||
self.assertEqual(tests, [
|
||||
{'id': 1, 'status': 'running'},
|
||||
{'id': 2, 'status': 'finished'}])
|
Loading…
Reference in New Issue
Block a user