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
This commit is contained in:
Kaiyan Sheng 2017-05-22 13:30:13 -06:00
parent 9b8a7802d2
commit cb3db853ee
7 changed files with 33 additions and 34 deletions

View File

@ -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

View File

@ -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()

View File

@ -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"),

View File

@ -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']

View File

@ -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'

View File

@ -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())

View File

@ -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)