From cb3db853ee164fa344aedead02658342ba8cb5ba Mon Sep 17 00:00:00 2001 From: Kaiyan Sheng Date: Mon, 22 May 2017 13:30:13 -0600 Subject: [PATCH] Change to "monasca-read-only-user" for read only tests "monasca-read-only-user" is a better name instead of "anotherrole" for read only tempest tests. It's also set by default in api-config.conf Also change test.attr() to decorators.attr() in tempest tests because of the deprecation warning. Change-Id: I05427147e2755bdc6fde483a145258f6fb695356 --- monasca_tempest_tests/tests/api/base.py | 4 ++-- ...t_alarm_state_history_multiple_transitions.py | 8 ++++---- .../tests/api/test_alarm_transitions.py | 15 +++++++-------- .../test_alarms_state_history_one_transition.py | 16 ++++++++-------- .../tests/api/test_metrics_names.py | 12 ++++++------ .../tests/api/test_notification_method_type.py | 6 +++--- monasca_tempest_tests/tests/api/test_versions.py | 6 +++--- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/monasca_tempest_tests/tests/api/base.py b/monasca_tempest_tests/tests/api/base.py index 54d8aa7..2cfc200 100644 --- a/monasca_tempest_tests/tests/api/base.py +++ b/monasca_tempest_tests/tests/api/base.py @@ -1,4 +1,4 @@ -# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP +# (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP # # 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 @@ -39,7 +39,7 @@ class BaseMonascaTest(tempest.test.BaseTestCase): force_tenant_isolation=True, identity_version=auth_version) credentials = cls.cred_provider.get_creds_by_roles( - ['monasca-user', 'anotherrole', 'admin']).credentials + ['monasca-user', 'monasca-read-only-user', 'admin']).credentials cls.os = clients.Manager(credentials=credentials) cls.monasca_client = cls.os.monasca_client cls.projects_client = cls.os.projects_client diff --git a/monasca_tempest_tests/tests/api/test_alarm_state_history_multiple_transitions.py b/monasca_tempest_tests/tests/api/test_alarm_state_history_multiple_transitions.py index 5423bd5..bf869f5 100644 --- a/monasca_tempest_tests/tests/api/test_alarm_state_history_multiple_transitions.py +++ b/monasca_tempest_tests/tests/api/test_alarm_state_history_multiple_transitions.py @@ -1,4 +1,4 @@ -# (C) Copyright 2016 Hewlett Packard Enterprise Development LP +# (C) Copyright 2016-2017 Hewlett Packard Enterprise Development LP # # 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 @@ -18,7 +18,7 @@ from monasca_tempest_tests.tests.api import base from monasca_tempest_tests.tests.api import constants from monasca_tempest_tests.tests.api import helpers from tempest.lib.common.utils import data_utils -from tempest import test +from tempest.lib import decorators MIN_HISTORY = 2 @@ -78,7 +78,7 @@ class TestAlarmStateHistoryMultipleTransitions(base.BaseMonascaTest): super(TestAlarmStateHistoryMultipleTransitions, cls).\ resource_cleanup() - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarm_state_history(self): # Get the alarm state history for a specific alarm by ID resp, response_body = self.monasca_client.list_alarms_state_history() @@ -111,7 +111,7 @@ class TestAlarmStateHistoryMultipleTransitions(base.BaseMonascaTest): "alarm state history is needed." self.fail(error_msg) - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarm_state_history_with_offset_limit(self): # Get the alarm state history for a specific alarm by ID resp, response_body = self.monasca_client.list_alarms_state_history() diff --git a/monasca_tempest_tests/tests/api/test_alarm_transitions.py b/monasca_tempest_tests/tests/api/test_alarm_transitions.py index de54c7e..5bfad4b 100644 --- a/monasca_tempest_tests/tests/api/test_alarm_transitions.py +++ b/monasca_tempest_tests/tests/api/test_alarm_transitions.py @@ -1,4 +1,4 @@ -# (C) Copyright 2016 Hewlett Packard Enterprise Development LP +# (C) Copyright 2016-2017 Hewlett Packard Enterprise Development LP # # 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 @@ -14,11 +14,10 @@ import time -from tempest.lib.common.utils import data_utils -from tempest import test - from monasca_tempest_tests.tests.api import base from monasca_tempest_tests.tests.api import helpers +from tempest.lib.common.utils import data_utils +from tempest.lib import decorators WAIT_SECS = 10 @@ -63,7 +62,7 @@ class TestAlarmTransitions(base.BaseMonascaTest): resp, resp_body = self.monasca_client.create_metrics([metric]) self.assertEqual(204, resp.status) - @test.attr(type="gate") + @decorators.attr(type="gate") def test_alarm_max_function(self): metric_def = { 'name': data_utils.rand_name("max_test"), @@ -91,7 +90,7 @@ class TestAlarmTransitions(base.BaseMonascaTest): self._wait_for_alarm_transition(alarm_id, "ALARM") - @test.attr(type="gate") + @decorators.attr(type="gate") def test_alarm_max_with_deterministic(self): metric_def = { 'name': data_utils.rand_name("max_deterministic_test"), @@ -118,7 +117,7 @@ class TestAlarmTransitions(base.BaseMonascaTest): self._wait_for_alarm_transition(alarm_id, "ALARM") - @test.attr(type="gate") + @decorators.attr(type="gate") def test_alarm_last_function(self): metric_def = { 'name': data_utils.rand_name("last_test"), @@ -149,7 +148,7 @@ class TestAlarmTransitions(base.BaseMonascaTest): self._wait_for_alarm_transition(alarm_id, "OK") - @test.attr(type="gate") + @decorators.attr(type="gate") def test_alarm_last_with_deterministic(self): metric_def = { 'name': data_utils.rand_name("last_deterministic_test"), diff --git a/monasca_tempest_tests/tests/api/test_alarms_state_history_one_transition.py b/monasca_tempest_tests/tests/api/test_alarms_state_history_one_transition.py index 91dc2d0..a2cfe24 100644 --- a/monasca_tempest_tests/tests/api/test_alarms_state_history_one_transition.py +++ b/monasca_tempest_tests/tests/api/test_alarms_state_history_one_transition.py @@ -1,4 +1,4 @@ -# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP +# (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP # # 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 @@ -19,7 +19,7 @@ from monasca_tempest_tests.tests.api import constants from monasca_tempest_tests.tests.api import helpers from oslo_utils import timeutils from tempest.lib.common.utils import data_utils -from tempest import test +from tempest.lib import decorators NUM_ALARM_DEFINITIONS = 3 MIN_HISTORY = 3 @@ -64,7 +64,7 @@ class TestAlarmsStateHistoryOneTransition(base.BaseMonascaTest): def resource_cleanup(cls): super(TestAlarmsStateHistoryOneTransition, cls).resource_cleanup() - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarms_state_history(self): resp, response_body = self.monasca_client.list_alarms_state_history() self.assertEqual(200, resp.status) @@ -83,7 +83,7 @@ class TestAlarmsStateHistoryOneTransition(base.BaseMonascaTest): 'timestamp', 'sub_alarms']) == set(element)) - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarms_state_history_with_dimensions(self): resp, response_body = self.monasca_client.list_alarms_state_history() elements = response_body['elements'] @@ -109,7 +109,7 @@ class TestAlarmsStateHistoryOneTransition(base.BaseMonascaTest): "to test." self.fail(error_msg) - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarms_state_history_with_start_time(self): # 1, get all histories resp, all_response_body = self.monasca_client.\ @@ -136,7 +136,7 @@ class TestAlarmsStateHistoryOneTransition(base.BaseMonascaTest): expected_elements.remove(min_element) self.assertEqual(expected_elements, selected_elements) - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarms_state_history_with_end_time(self): # 1, get all histories resp, all_response_body = self.monasca_client.\ @@ -163,7 +163,7 @@ class TestAlarmsStateHistoryOneTransition(base.BaseMonascaTest): expected_elements.remove(max_element) self.assertEqual(expected_elements, selected_elements) - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarms_state_history_with_start_end_time(self): # 1, get all histories resp, all_response_body = self.monasca_client.\ @@ -190,7 +190,7 @@ class TestAlarmsStateHistoryOneTransition(base.BaseMonascaTest): # 3. compare #1 and #2 self.assertEqual(all_elements, selected_elements) - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_alarms_state_history_with_offset_limit(self): resp, response_body = self.monasca_client.list_alarms_state_history() elements_set1 = response_body['elements'] diff --git a/monasca_tempest_tests/tests/api/test_metrics_names.py b/monasca_tempest_tests/tests/api/test_metrics_names.py index da451d6..80c089c 100644 --- a/monasca_tempest_tests/tests/api/test_metrics_names.py +++ b/monasca_tempest_tests/tests/api/test_metrics_names.py @@ -1,4 +1,4 @@ -# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP +# (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP # # 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 @@ -18,7 +18,7 @@ from monasca_tempest_tests.tests.api import base from monasca_tempest_tests.tests.api import constants from monasca_tempest_tests.tests.api import helpers from tempest.lib.common.utils import data_utils -from tempest import test +from tempest.lib import decorators from urllib import urlencode @@ -70,13 +70,13 @@ class TestMetricsNames(base.BaseMonascaTest): def resource_cleanup(cls): super(TestMetricsNames, cls).resource_cleanup() - @test.attr(type='gate') + @decorators.attr(type='gate') def test_list_metrics_names(self): resp, response_body = self.monasca_client.list_metrics_names() metric_names = self._verify_response(resp, response_body) self.assertEqual(metric_names, self._expected_names_list) - @test.attr(type='gate') + @decorators.attr(type='gate') def test_list_metrics_names_with_dimensions(self): query_params = '?dimensions=' + self._dimensions_param resp, response_body = self.monasca_client.list_metrics_names( @@ -85,7 +85,7 @@ class TestMetricsNames(base.BaseMonascaTest): self.assertEqual(metric_names, self._test_metric_names_with_same_dim) - @test.attr(type='gate') + @decorators.attr(type='gate') def test_list_metrics_names_with_limit_offset(self): resp, response_body = self.monasca_client.list_metrics_names() self.assertEqual(200, resp.status) @@ -125,7 +125,7 @@ class TestMetricsNames(base.BaseMonascaTest): # Get the next set offset = self._get_offset(response_body) - @test.attr(type='gate') + @decorators.attr(type='gate') def test_list_metrics_names_with_offset_not_in_metrics_names_list(self): offset1 = 'tempest-abc' offset2 = 'tempest-name111' diff --git a/monasca_tempest_tests/tests/api/test_notification_method_type.py b/monasca_tempest_tests/tests/api/test_notification_method_type.py index e71e2ee..6f2bc30 100644 --- a/monasca_tempest_tests/tests/api/test_notification_method_type.py +++ b/monasca_tempest_tests/tests/api/test_notification_method_type.py @@ -1,4 +1,4 @@ -# (C) Copyright 2016 Hewlett Packard Enterprise Development LP +# (C) Copyright 2016-2017 Hewlett Packard Enterprise Development LP # # 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 @@ -13,7 +13,7 @@ # under the License. from monasca_tempest_tests.tests.api import base -from tempest import test +from tempest.lib import decorators class TestNotificationMethodType(base.BaseMonascaTest): @@ -26,7 +26,7 @@ class TestNotificationMethodType(base.BaseMonascaTest): def resource_cleanup(cls): super(TestNotificationMethodType, cls).resource_cleanup() - @test.attr(type="gate") + @decorators.attr(type="gate") def test_list_notification_method_type(self): resp, response_body = (self.monasca_client. list_notification_method_types()) diff --git a/monasca_tempest_tests/tests/api/test_versions.py b/monasca_tempest_tests/tests/api/test_versions.py index d82dce6..00e2e21 100644 --- a/monasca_tempest_tests/tests/api/test_versions.py +++ b/monasca_tempest_tests/tests/api/test_versions.py @@ -1,4 +1,4 @@ -# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP +# (C) Copyright 2015,2017 Hewlett Packard Enterprise Development Company LP # # 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 @@ -17,7 +17,7 @@ import datetime from oslo_serialization import jsonutils as json from monasca_tempest_tests.tests.api import base -from tempest import test +from tempest.lib import decorators class TestVersions(base.BaseMonascaTest): @@ -26,7 +26,7 @@ class TestVersions(base.BaseMonascaTest): def resource_setup(cls): super(TestVersions, cls).resource_setup() - @test.attr(type='gate') + @decorators.attr(type='gate') def test_get_version(self): resp, response_body = self.monasca_client.get_version() self.assertEqual(resp.status, 200)