diff --git a/doc/source/readme.rst b/doc/source/readme.rst index 434d665..73600c1 100644 --- a/doc/source/readme.rst +++ b/doc/source/readme.rst @@ -143,14 +143,3 @@ And, to run a specific test:: $ export TEMPEST_CONFIG_DIR=/watcher-cloud/etc/ $ tox -eall-plugin watcher_tempest_plugin.tests.api.admin.test_audit_template.TestCreateDeleteAuditTemplate.test_create_audit_template - -Watcherclient Tempest tests execution -------------------------------------- - -To run Watcherclient functional tests you need to execute ``tempest run`` command:: - - $ tempest run --regex watcher_tempest_plugin.tests.client_functional - -You can run specified test(s) by using a regular expression:: - - $ tempest run --regex watcher_tempest_plugin.tests.client_functional.v1.test_action.ActionTests.test_action_list diff --git a/releasenotes/notes/remove-client-functional-tests-0ae36f97571c4aba.yaml b/releasenotes/notes/remove-client-functional-tests-0ae36f97571c4aba.yaml new file mode 100644 index 0000000..6c512b0 --- /dev/null +++ b/releasenotes/notes/remove-client-functional-tests-0ae36f97571c4aba.yaml @@ -0,0 +1,10 @@ +--- +others: + - | + Watcherclient functional tests have been removed from watcher-tempest-plugin. + Users should now run client functional tests directly from python-watcherclient + instead of watcher-tempest-plugin. + + - The ``debtcollector`` dependency has been removed from test-requirements.txt + as it was only used for deprecation warnings in the now-removed client + functional tests. diff --git a/test-requirements.txt b/test-requirements.txt index 1f61c24..dfc0d47 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,6 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -debtcollector>=1.2.0 # Apache-2.0 hacking>=3.2 stestr>=1.0.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 diff --git a/watcher_tempest_plugin/tests/client_functional/__init__.py b/watcher_tempest_plugin/tests/client_functional/__init__.py deleted file mode 100644 index efd1c93..0000000 --- a/watcher_tempest_plugin/tests/client_functional/__init__.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- encoding: utf-8 -*- -# Copyright (c) 2025 Red Hat -# -# 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. -from debtcollector import removals -import warnings - -warnings.simplefilter("once", DeprecationWarning) -removals.removed_module( - __name__, - replacement="watcherclient.tests.client_functional", - removal_version="2026.1", - message=( - "The 'watcher_tempest_plugin.tests.client_functional' module is " - "deprecated and will be removed in version 2026.1. " - "We recommend using watcherclient.tests.client_functional for " - "running functional tests. " - ) -) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/__init__.py b/watcher_tempest_plugin/tests/client_functional/v1/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/watcher_tempest_plugin/tests/client_functional/v1/base.py b/watcher_tempest_plugin/tests/client_functional/v1/base.py deleted file mode 100644 index 7835343..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/base.py +++ /dev/null @@ -1,151 +0,0 @@ -# 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 os - -import re -import shlex -import subprocess -import testtools - -from tempest import clients -from tempest.common import credentials_factory as creds_factory -from tempest.lib.cli import output_parser -from tempest.lib import exceptions - - -def credentials(): - # You can get credentials either from tempest.conf file or - # from OS environment. - tempest_creds = clients.get_auth_provider( - creds_factory.get_configured_admin_credentials()) - creds = tempest_creds.credentials - creds_dict = { - '--os-username': os.environ.get('OS_USERNAME', creds.username), - '--os-password': os.environ.get('OS_PASSWORD', creds.password), - '--os-project-name': os.environ.get('OS_PROJECT_NAME', - creds.project_name), - '--os-auth-url': os.environ.get('OS_AUTH_URL', - tempest_creds.auth_url), - '--os-project-domain-name': os.environ.get('OS_PROJECT_DOMAIN_ID', - creds.project_domain_name), - '--os-user-domain-name': os.environ.get('OS_USER_DOMAIN_ID', - creds.user_domain_name), - } - return [x for sub in creds_dict.items() for x in sub] - - -def execute(cmd, fail_ok=False, merge_stderr=False): - """Executes specified command for the given action.""" - cmdlist = shlex.split(cmd) - cmdlist.extend(credentials()) - stdout = subprocess.PIPE - stderr = subprocess.STDOUT if merge_stderr else subprocess.PIPE - proc = subprocess.Popen(cmdlist, stdout=stdout, stderr=stderr) - result, result_err = proc.communicate() - result = result.decode('utf-8') - if not fail_ok and proc.returncode != 0: - raise exceptions.CommandFailed(proc.returncode, cmd, result, - result_err) - return result - - -class TestCase(testtools.TestCase): - - delimiter_line = re.compile(r'^\+\-[\+\-]+\-\+$') - - api_version = 1.0 - - @classmethod - def watcher(cls, cmd, fail_ok=False): - """Executes watcherclient command for the given action.""" - return execute( - 'openstack optimize --os-infra-optim-api-version {0} {1}'.format( - cls.api_version, cmd), fail_ok=fail_ok) - - @classmethod - def get_opts(cls, fields, format='value'): - return ' -f {0} {1}'.format(format, - ' '.join(['-c ' + it for it in fields])) - - @classmethod - def assertOutput(cls, expected, actual): - if expected != actual: - raise Exception('{0} != {1}'.format(expected, actual)) - - @classmethod - def assertInOutput(cls, expected, actual): - if expected not in actual: - raise Exception('{0} not in {1}'.format(expected, actual)) - - def assert_table_structure(self, items, field_names): - """Verify that all items have keys listed in field_names.""" - for item in items: - for field in field_names: - self.assertIn(field, item) - - def assert_show_fields(self, items, field_names): - """Verify that all items have keys listed in field_names.""" - for item in items: - for key in item.keys(): - self.assertIn(key, field_names) - - def assert_show_structure(self, items, field_names): - """Verify that all field_names listed in keys of all items.""" - if isinstance(items, list): - o = {} - for d in items: - o.update(d) - else: - o = items - item_keys = o.keys() - for field in field_names: - self.assertIn(field, item_keys) - - @staticmethod - def parse_show_as_object(raw_output): - """Return a dict with values parsed from cli output.""" - items = TestCase.parse_show(raw_output) - o = {} - for item in items: - o.update(item) - return o - - @staticmethod - def parse_show(raw_output): - """Return list of dicts with item values parsed from cli output.""" - - items = [] - table_ = output_parser.table(raw_output) - for row in table_['values']: - item = {} - item[row[0]] = row[1] - items.append(item) - return items - - def parse_listing(self, raw_output): - """Return list of dicts with basic item parsed from cli output.""" - return output_parser.listing(raw_output) - - def has_actionplan_succeeded(self, ap_uuid): - return self.parse_show_as_object( - self.watcher('actionplan show %s' % ap_uuid) - )['State'] == 'SUCCEEDED' - - @classmethod - def has_audit_created(cls, audit_uuid): - audit = cls.parse_show_as_object( - cls.watcher('audit show %s' % audit_uuid)) - if audit['Audit Type'] == 'ONESHOT': - return audit['State'] == 'SUCCEEDED' - else: - return audit['State'] == 'ONGOING' diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_action.py b/watcher_tempest_plugin/tests/client_functional/v1/test_action.py deleted file mode 100644 index 8e72276..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_action.py +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from oslo_utils import uuidutils - -import functools - -from tempest.lib.common.utils import test_utils -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class ActionTests(base.TestCase): - """Functional tests for action.""" - - dummy_name = 'dummy' - list_fields = ['UUID', 'Parents', 'State', 'Action Plan', 'Action'] - detailed_list_fields = list_fields + ['Created At', 'Updated At', - 'Deleted At', 'Parameters'] - audit_template_name = 'a' + uuidutils.generate_uuid() - audit_uuid = None - - @classmethod - def setUpClass(cls): - template_raw_output = cls.watcher( - 'audittemplate create %s dummy -s dummy' % cls.audit_template_name) - template_output = cls.parse_show_as_object(template_raw_output) - audit_output = cls.parse_show_as_object(cls.watcher( - 'audit create -a %s' % template_output['Name'])) - cls.audit_uuid = audit_output['UUID'] - audit_created = test_utils.call_until_true( - func=functools.partial(cls.has_audit_created, cls.audit_uuid), - duration=600, - sleep_for=2) - if not audit_created: - raise Exception('Audit has not been succeeded') - - @classmethod - def tearDownClass(cls): - # Delete Action Plan and all related actions. - output = cls.parse_show( - cls.watcher('actionplan list --audit %s' % cls.audit_uuid)) - action_plan_uuid = list(output[0])[0] - raw_output = cls.watcher('actionplan delete %s' % action_plan_uuid) - cls.assertOutput('', raw_output) - # Delete audit - raw_output = cls.watcher('audit delete %s' % cls.audit_uuid) - cls.assertOutput('', raw_output) - # Delete Template - raw_output = cls.watcher( - 'audittemplate delete %s' % cls.audit_template_name) - cls.assertOutput('', raw_output) - - @decorators.idempotent_id('8f0fde28-eb6f-4beb-b7ad-896d76d09a15') - def test_action_list(self): - raw_output = self.watcher('action list') - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('dbcc709f-b3b4-4803-9a19-73d77058a6d0') - def test_action_detailed_list(self): - raw_output = self.watcher('action list --detail') - self.assert_table_structure([raw_output], self.detailed_list_fields) - - @decorators.idempotent_id('03c83cdb-41fd-4893-a056-fd94403827b2') - def test_action_show(self): - action_list = self.parse_show(self.watcher('action list --audit %s' - % self.audit_uuid)) - action_uuid = list(action_list[0])[0] - action = self.watcher('action show %s' % action_uuid) - self.assertIn(action_uuid, action) - self.assert_table_structure([action], - self.detailed_list_fields) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_action_plan.py b/watcher_tempest_plugin/tests/client_functional/v1/test_action_plan.py deleted file mode 100644 index 1093ffd..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_action_plan.py +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from oslo_utils import uuidutils - -import functools - -from tempest.lib.common.utils import test_utils -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class ActionPlanTests(base.TestCase): - """Functional tests for action plan.""" - - dummy_name = 'dummy' - list_fields = ['UUID', 'Audit', 'State', 'Updated At', 'Global efficacy'] - detailed_list_fields = list_fields + ['Created At', 'Deleted At', - 'Strategy', 'Efficacy indicators', - 'Hostname'] - audit_template_name = 'a' + uuidutils.generate_uuid() - audit_uuid = None - - @classmethod - def setUpClass(cls): - template_raw_output = cls.watcher( - 'audittemplate create %s dummy -s dummy' % cls.audit_template_name) - template_output = cls.parse_show_as_object(template_raw_output) - audit_raw_output = cls.watcher('audit create -a %s' - % template_output['Name']) - audit_output = cls.parse_show_as_object(audit_raw_output) - cls.audit_uuid = audit_output['UUID'] - audit_created = test_utils.call_until_true( - func=functools.partial(cls.has_audit_created, cls.audit_uuid), - duration=600, - sleep_for=2) - if not audit_created: - raise Exception('Audit has not been succeeded') - - @classmethod - def tearDownClass(cls): - # Delete action plan - output = cls.parse_show( - cls.watcher('actionplan list --audit %s' % cls.audit_uuid)) - action_plan_uuid = list(output[0])[0] - raw_output = cls.watcher('actionplan delete %s' % action_plan_uuid) - cls.assertOutput('', raw_output) - # Delete audit - raw_output = cls.watcher('audit delete %s' % cls.audit_uuid) - cls.assertOutput('', raw_output) - # Delete Template - raw_output = cls.watcher( - 'audittemplate delete %s' % cls.audit_template_name) - cls.assertOutput('', raw_output) - - @decorators.idempotent_id('81b64469-dfe1-499e-8d49-614970aea01e') - def test_action_plan_list(self): - raw_output = self.watcher('actionplan list') - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('af257105-17f4-4330-9904-80272b81de41') - def test_action_plan_detailed_list(self): - raw_output = self.watcher('actionplan list --detail') - self.assert_table_structure([raw_output], self.detailed_list_fields) - - @decorators.idempotent_id('f487078d-d001-4419-85e3-d68859c9a238') - def test_action_plan_show(self): - action_plan_list = self.parse_show(self.watcher('actionplan list')) - action_plan_uuid = list(action_plan_list[0])[0] - actionplan = self.watcher('actionplan show %s' % action_plan_uuid) - self.assertIn(action_plan_uuid, actionplan) - self.assert_table_structure([actionplan], - self.detailed_list_fields) - - @decorators.idempotent_id('629767a4-78fe-4abc-9321-6164e6c5e18d') - def test_action_plan_start(self): - output = self.parse_show(self.watcher('actionplan list --audit %s' - % self.audit_uuid)) - action_plan_uuid = list(output[0])[0] - self.watcher('actionplan start %s' % action_plan_uuid) - raw_output = self.watcher('actionplan show %s' % action_plan_uuid) - self.assert_table_structure([raw_output], self.detailed_list_fields) - - self.assertTrue(test_utils.call_until_true( - func=functools.partial( - self.has_actionplan_succeeded, action_plan_uuid), - duration=600, - sleep_for=2 - )) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_audit.py b/watcher_tempest_plugin/tests/client_functional/v1/test_audit.py deleted file mode 100644 index fee04a6..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_audit.py +++ /dev/null @@ -1,223 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from datetime import datetime -from dateutil import tz -import functools - -from oslo_utils import uuidutils -from tempest.lib.common.utils import test_utils -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class AuditTests(base.TestCase): - """Functional tests for audit.""" - - dummy_name = 'dummy' - list_fields = ['UUID', 'Name', 'Audit Type', 'State', 'Goal', 'Strategy'] - detailed_list_fields = list_fields + ['Created At', 'Updated At', - 'Deleted At', 'Parameters', - 'Interval', 'Audit Scope', - 'Next Run Time', 'Hostname'] - audit_template_name = 'a' + uuidutils.generate_uuid() - audit_uuid = None - - @classmethod - def setUpClass(cls): - raw_output = cls.watcher('audittemplate create %s dummy -s dummy' - % cls.audit_template_name) - template_output = cls.parse_show_as_object(raw_output) - audit_raw_output = cls.watcher( - 'audit create -a %s' % template_output['Name']) - audit_output = cls.parse_show_as_object(audit_raw_output) - cls.audit_uuid = audit_output['UUID'] - audit_created = test_utils.call_until_true( - func=functools.partial(cls.has_audit_created, cls.audit_uuid), - duration=600, - sleep_for=2) - if not audit_created: - raise Exception('Audit has not been succeeded') - - @classmethod - def tearDownClass(cls): - output = cls.parse_show( - cls.watcher('actionplan list --audit %s' % cls.audit_uuid)) - action_plan_uuid = list(output[0])[0] - cls.watcher('actionplan delete %s' % action_plan_uuid) - cls.watcher('audit delete %s' % cls.audit_uuid) - cls.watcher('audittemplate delete %s' % cls.audit_template_name) - - @decorators.idempotent_id('0b3a021c-93f2-4c6f-b758-959602006f8c') - def test_audit_list(self): - raw_output = self.watcher('audit list') - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('0a3af540-2214-44c9-921e-696fcab81b65') - def test_audit_detailed_list(self): - raw_output = self.watcher('audit list --detail') - self.assert_table_structure([raw_output], self.detailed_list_fields) - - @decorators.idempotent_id('78d41161-2fa9-4620-857e-9a325ad785fc') - def test_audit_show(self): - audit = self.watcher('audit show ' + self.audit_uuid) - self.assertIn(self.audit_uuid, audit) - self.assert_table_structure([audit], self.detailed_list_fields) - - @decorators.idempotent_id('e3a1b6b8-f13f-4a81-9824-377279ebf488') - def test_audit_update(self): - audit_raw_output = self.watcher('audit update %s add interval=2' - % self.audit_uuid) - audit_output = self.parse_show_as_object(audit_raw_output) - assert int(audit_output['Interval']) == 2 - - -class AuditTestsV11(AuditTests): - """This class tests v1.1 of Watcher API""" - - api_version = 1.1 - - detailed_list_fields = AuditTests.list_fields + [ - 'Created At', 'Updated At', 'Deleted At', 'Parameters', 'Interval', - 'Audit Scope', 'Next Run Time', 'Hostname', 'Start Time', 'End Time'] - - @decorators.idempotent_id('8ff17811-b066-4ed6-ada2-105c9c3d2691') - def test_audit_detailed_list(self): - raw_output = self.watcher('audit list --detail') - self.assert_table_structure([raw_output], self.detailed_list_fields) - - @decorators.idempotent_id('6937dc37-3931-4c20-a081-1cbfc45df623') - def test_audit_show(self): - audit = self.watcher('audit show ' + self.audit_uuid) - self.assertIn(self.audit_uuid, audit) - self.assert_table_structure([audit], self.detailed_list_fields) - - @decorators.idempotent_id('b811da86-95ce-4654-afef-82aaeb72b6d4') - def test_audit_update(self): - local_time = datetime.now(tz.tzlocal()) - local_time_str = local_time.strftime("%Y-%m-%dT%H:%M:%S") - utc_time = (local_time - local_time.utcoffset()) - utc_time_str = utc_time.strftime("%Y-%m-%dT%H:%M:%S") - audit_raw_output = self.watcher( - 'audit update {0} replace end_time="{1}"'.format(self.audit_uuid, - local_time_str)) - audit_output = self.parse_show_as_object(audit_raw_output) - assert audit_output['End Time'] == utc_time_str - - -class AuditTestsV12(AuditTestsV11): - """This class tests v1.2 of Watcher API""" - - api_version = 1.2 - - @classmethod - def setUpClass(cls): - raw_output = cls.watcher('audittemplate create %s dummy -s dummy' - % cls.audit_template_name) - template_output = cls.parse_show_as_object(raw_output) - audit_raw_output = cls.watcher( - 'audit create --force -a %s' % template_output['Name']) - audit_output = cls.parse_show_as_object(audit_raw_output) - cls.audit_uuid = audit_output['UUID'] - audit_created = test_utils.call_until_true( - func=functools.partial(cls.has_audit_created, cls.audit_uuid), - duration=600, - sleep_for=2) - if not audit_created: - raise Exception('Audit has not been succeeded') - - -class AuditActiveTests(base.TestCase): - - list_fields = ['UUID', 'Name', 'Audit Type', 'State', 'Goal', 'Strategy'] - detailed_list_fields = list_fields + ['Created At', 'Updated At', - 'Deleted At', 'Parameters', - 'Interval', 'Audit Scope'] - audit_template_name = 'a' + uuidutils.generate_uuid() - - @classmethod - def setUpClass(cls): - cls.watcher('audittemplate create %s dummy -s dummy' - % cls.audit_template_name) - - @classmethod - def tearDownClass(cls): - cls.watcher('audittemplate delete %s' % cls.audit_template_name) - - def _create_audit(self): - return self.parse_show_as_object( - self.watcher('audit create -a %s' - % self.audit_template_name))['UUID'] - - def _delete_audit(self, audit_uuid): - self.assertTrue(test_utils.call_until_true( - func=functools.partial( - self.has_audit_created, audit_uuid), - duration=600, - sleep_for=2 - )) - output = self.parse_show( - self.watcher('actionplan list --audit %s' % audit_uuid)) - action_plan_uuid = list(output[0])[0] - self.watcher('actionplan delete %s' % action_plan_uuid) - self.watcher('audit delete %s' % audit_uuid) - - @decorators.idempotent_id('3fabb0e4-dd89-4fa0-9085-36e95074c4f1') - def test_create_oneshot_audit(self): - audit = self.watcher('audit create -a %s' % self.audit_template_name) - audit_uuid = self.parse_show_as_object(audit)['UUID'] - self.assert_table_structure([audit], self.detailed_list_fields) - self._delete_audit(audit_uuid) - - @decorators.idempotent_id('981a7682-221f-4b8c-b5c6-33d50a6170f2') - def test_delete_oneshot_audit(self): - audit_uuid = self._create_audit() - self.assertTrue(test_utils.call_until_true( - func=functools.partial( - self.has_audit_created, audit_uuid), - duration=600, - sleep_for=2 - )) - raw_output = self.watcher('audit delete %s' % audit_uuid) - self.assertOutput('', raw_output) - output = self.parse_show( - self.watcher('actionplan list --audit %s' % audit_uuid)) - action_plan_uuid = list(output[0])[0] - self.watcher('actionplan delete %s' % action_plan_uuid) - - @decorators.idempotent_id('4ad07aab-60c7-47cf-9e28-98a27ab3bca7') - def test_continuous_audit(self): - audit = self.watcher('audit create -a %s -t CONTINUOUS -i 600' - % self.audit_template_name) - audit_uuid = self.parse_show_as_object(audit)['UUID'] - self.assert_table_structure([audit], self.detailed_list_fields) - self.assertTrue(test_utils.call_until_true( - func=functools.partial( - self.has_audit_created, audit_uuid), - duration=600, - sleep_for=2 - )) - audit_state = self.parse_show_as_object( - self.watcher('audit show %s' % audit_uuid))['State'] - if audit_state == 'ONGOING': - self.watcher('audit update %s replace state=CANCELLED' - % audit_uuid) - raw_output = self.watcher('audit delete %s' % audit_uuid) - self.assertOutput('', raw_output) - outputs = self.parse_listing( - self.watcher('actionplan list --audit %s' % audit_uuid)) - for actionplan in outputs: - self.watcher('actionplan delete %s' % actionplan['UUID']) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_audit_template.py b/watcher_tempest_plugin/tests/client_functional/v1/test_audit_template.py deleted file mode 100644 index 038509a..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_audit_template.py +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from oslo_utils import uuidutils -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class AuditTemplateTests(base.TestCase): - """Functional tests for audit template.""" - - dummy_name = 'dummy' - list_fields = ['UUID', 'Name', 'Goal', 'Strategy'] - detailed_list_fields = list_fields + ['Created At', 'Updated At', - 'Deleted At', 'Description', - 'Audit Scope'] - audit_template_name = 'a' + uuidutils.generate_uuid() - - @classmethod - def setUpClass(cls): - cls.watcher('audittemplate create %s dummy -s dummy' - % cls.audit_template_name) - - @classmethod - def tearDownClass(cls): - cls.watcher('audittemplate delete %s' % cls.audit_template_name) - - @decorators.idempotent_id('b5065a27-9757-4d65-8e9c-9c6f3677eb10') - def test_audit_template_list(self): - raw_output = self.watcher('audittemplate list') - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('a26146b4-86fd-42ff-8af5-23567a8570e5') - def test_audit_template_detailed_list(self): - raw_output = self.watcher('audittemplate list --detail') - self.assert_table_structure([raw_output], self.detailed_list_fields) - - @decorators.idempotent_id('fa8a1e4b-e5b5-4643-b298-99f80e909dc3') - def test_audit_template_show(self): - audit_template = self.watcher( - 'audittemplate show %s' % self.audit_template_name) - self.assertIn(self.audit_template_name, audit_template) - self.assert_table_structure([audit_template], - self.detailed_list_fields) - - @decorators.idempotent_id('b632e1f5-4ab6-4338-91b3-abf4d257fa28') - def test_audit_template_update(self): - raw_output = self.watcher('audittemplate update %s replace ' - 'description="Updated Desc"' - % self.audit_template_name) - audit_template_output = self.parse_show_as_object(raw_output) - assert audit_template_output['Description'] == 'Updated Desc' - - -class AuditTemplateActiveTests(base.TestCase): - - audit_template_name = 'b' + uuidutils.generate_uuid() - list_fields = ['UUID', 'Name', 'Goal', 'Strategy'] - detailed_list_fields = list_fields + ['Created At', 'Updated At', - 'Deleted At', 'Description', - 'Audit Scope'] - - def _create_audit_template(self): - self.watcher('audittemplate create %s dummy -s dummy ' - '-d "Test Audit Template"' % self.audit_template_name) - - def _delete_audit_template(self): - self.watcher('audittemplate delete %s' % self.audit_template_name) - - @decorators.idempotent_id('8c88f312-0e27-44c5-bd9b-c171086bfc55') - def test_create_audit_template(self): - raw_output = self.watcher('audittemplate create %s dummy ' - '-s dummy -d "Test Audit Template"' - % self.audit_template_name) - self.assert_table_structure([raw_output], self.detailed_list_fields) - self._delete_audit_template() - - @decorators.idempotent_id('c1980ccc-8194-4b18-bcdc-964395de3cf9') - def test_delete_audit_template(self): - self._create_audit_template() - raw_output = self.watcher('audittemplate delete %s' - % self.audit_template_name) - self.assertOutput('', raw_output) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_goal.py b/watcher_tempest_plugin/tests/client_functional/v1/test_goal.py deleted file mode 100644 index d31ae4a..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_goal.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class GoalTests(base.TestCase): - """Functional tests for goal.""" - - dummy_name = 'dummy' - list_fields = ['UUID', 'Name', 'Display name'] - - @decorators.idempotent_id('53046516-5ddb-41b7-ab43-0dac13f964b1') - def test_goal_list(self): - raw_output = self.watcher('goal list') - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('cb88a7fd-c19f-47fd-96e0-51cff152f77f') - def test_goal_detailed_list(self): - raw_output = self.watcher('goal list --detail') - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure( - [raw_output], self.list_fields + ['Efficacy specification']) - - @decorators.idempotent_id('98645ffb-2450-43ce-ad8c-c616720f0471') - def test_goal_show(self): - raw_output = self.watcher('goal show %s' % self.dummy_name) - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure( - [raw_output], self.list_fields + ['Efficacy specification']) - self.assertNotIn('server_consolidation', raw_output) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_scoring_engine.py b/watcher_tempest_plugin/tests/client_functional/v1/test_scoring_engine.py deleted file mode 100644 index ef37d31..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_scoring_engine.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class ScoringEngineTests(base.TestCase): - """Functional tests for scoring engine.""" - - dummy_name = 'dummy_scorer' - list_fields = ['UUID', 'Name', 'Description'] - detailed_list_fields = list_fields + ['Metainfo'] - - @decorators.idempotent_id('87b34f07-df9a-49c9-a229-4aba831368b1') - def test_scoringengine_list(self): - raw_output = self.watcher('scoringengine list') - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('ab987528-f56e-49ef-8463-0f4c023aaf48') - def test_scoringengine_detailed_list(self): - raw_output = self.watcher('scoringengine list --detail') - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure([raw_output], self.detailed_list_fields) - - @decorators.idempotent_id('f12b0cb7-808b-4ced-bb69-f18d6ab6ef0f') - def test_scoringengine_show(self): - raw_output = self.watcher('scoringengine show %s' % self.dummy_name) - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure([raw_output], self.detailed_list_fields) - self.assertNotIn('dummy_avg_scorer', raw_output) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_service.py b/watcher_tempest_plugin/tests/client_functional/v1/test_service.py deleted file mode 100644 index a7fff9a..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_service.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class ServiceTests(base.TestCase): - """Functional tests for service.""" - - decision_engine_name = 'watcher-decision-engine' - applier_name = 'watcher-applier' - list_fields = ['ID', 'Name', 'Host', 'Status'] - - @decorators.idempotent_id('901af2d0-2a18-45b5-bd07-31d221f19259') - def test_service_list(self): - raw_output = self.watcher('service list') - self.assertIn(self.decision_engine_name, raw_output) - self.assertIn(self.applier_name, raw_output) - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('86b6826b-58ee-4338-a294-e0e24e060ef1') - def test_service_detailed_list(self): - raw_output = self.watcher('service list --detail') - self.assertIn(self.decision_engine_name, raw_output) - self.assertIn(self.applier_name, raw_output) - self.assert_table_structure([raw_output], - self.list_fields + ['Last seen up']) - - @decorators.idempotent_id('d3b0dc69-290b-4b2d-aaf6-c2768420e125') - def test_service_show(self): - # TODO(alexchadin): this method should be refactored since Watcher will - # get HA support soon. - raw_output = self.watcher('service show %s' - % self.decision_engine_name) - self.assertIn(self.decision_engine_name, raw_output) - self.assert_table_structure([raw_output], - self.list_fields + ['Last seen up']) - self.assertNotIn(self.applier_name, raw_output) diff --git a/watcher_tempest_plugin/tests/client_functional/v1/test_strategy.py b/watcher_tempest_plugin/tests/client_functional/v1/test_strategy.py deleted file mode 100644 index 8402e0c..0000000 --- a/watcher_tempest_plugin/tests/client_functional/v1/test_strategy.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (c) 2016 Servionica -# -# 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. - -from tempest.lib import decorators - -from watcher_tempest_plugin.tests.client_functional.v1 import base - - -class StrategyTests(base.TestCase): - """Functional tests for strategy.""" - - dummy_name = 'dummy' - basic_strategy = 'basic' - list_fields = ['UUID', 'Name', 'Display name', 'Goal'] - state_fields = ['Datasource', 'Metrics', 'CDM', 'Name'] - - @decorators.idempotent_id('3ed8bc49-2bd5-4a2b-a407-7b0742ccb935') - def test_strategy_list(self): - raw_output = self.watcher('strategy list') - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure([raw_output], self.list_fields) - - @decorators.idempotent_id('88f9ee68-6cef-4536-b075-259ee28218e0') - def test_strategy_detailed_list(self): - raw_output = self.watcher('strategy list --detail') - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure([raw_output], - self.list_fields + ['Parameters spec']) - - @decorators.idempotent_id('374092aa-3222-4416-9811-7e78529bb1fe') - def test_strategy_show(self): - raw_output = self.watcher('strategy show %s' % self.dummy_name) - self.assertIn(self.dummy_name, raw_output) - self.assert_table_structure([raw_output], - self.list_fields + ['Parameters spec']) - self.assertNotIn('basic', raw_output) - - @decorators.idempotent_id('0553c5c1-8776-4a11-b1a2-262b08a1f8ee') - def test_strategy_state(self): - raw_output = self.watcher('strategy state %s' % self.basic_strategy) - self.assertIn(self.basic_strategy, raw_output) - self.assert_table_structure([raw_output], self.state_fields)