summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-19 21:55:13 +0000
committerGerrit Code Review <review@openstack.org>2017-06-19 21:55:13 +0000
commit4a8921680317507a2524c94d14c1188eabf4f447 (patch)
tree0fc09cafc6df754735a882a72c1fa0c1138401e7
parentb48eba0e3502096ea09758e1058d5263361f3326 (diff)
parent54959dd43b6441a29afc6eb36bda5441cb4c76b0 (diff)
Merge "Minimize number of servers created for certain tests"
-rw-r--r--patrole_tempest_plugin/tests/api/compute/test_admin_server_actions_rbac.py65
-rw-r--r--patrole_tempest_plugin/tests/api/compute/test_deferred_delete_rbac.py47
-rw-r--r--patrole_tempest_plugin/tests/api/compute/test_rescue_rbac.py43
-rw-r--r--patrole_tempest_plugin/tests/api/compute/test_server_diagnostics_rbac.py44
-rw-r--r--patrole_tempest_plugin/tests/api/compute/test_server_misc_policy_actions_rbac.py154
-rw-r--r--patrole_tempest_plugin/tests/api/compute/test_server_password_rbac.py52
-rw-r--r--patrole_tempest_plugin/tests/api/compute/test_server_usage_rbac.py43
7 files changed, 154 insertions, 294 deletions
diff --git a/patrole_tempest_plugin/tests/api/compute/test_admin_server_actions_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_admin_server_actions_rbac.py
deleted file mode 100644
index 37fad18..0000000
--- a/patrole_tempest_plugin/tests/api/compute/test_admin_server_actions_rbac.py
+++ /dev/null
@@ -1,65 +0,0 @@
1# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest import config
17from tempest.lib import decorators
18from tempest import test
19
20from patrole_tempest_plugin import rbac_rule_validation
21from patrole_tempest_plugin.tests.api.compute import rbac_base
22
23CONF = config.CONF
24
25
26class AdminServerActionsRbacTest(rbac_base.BaseV2ComputeRbacTest):
27
28 @classmethod
29 def skip_checks(cls):
30 super(AdminServerActionsRbacTest, cls).skip_checks()
31 if not test.is_extension_enabled('os-admin-actions', 'compute'):
32 msg = "%s skipped as os-admin-actions not enabled." % cls.__name__
33 raise cls.skipException(msg)
34
35 @classmethod
36 def resource_setup(cls):
37 super(AdminServerActionsRbacTest, cls).resource_setup()
38 cls.server_id = cls.create_test_server(wait_until='ACTIVE')['id']
39
40 @rbac_rule_validation.action(
41 service="nova",
42 rule="os_compute_api:os-admin-actions:reset_state")
43 @decorators.idempotent_id('ae84dd0b-f364-462e-b565-3457f9c019ef')
44 def test_reset_server_state(self):
45 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
46 self.servers_client.reset_state(self.server_id, state='error')
47 self.addCleanup(self.servers_client.reset_state,
48 self.server_id,
49 state='active')
50
51 @rbac_rule_validation.action(
52 service="nova",
53 rule="os_compute_api:os-admin-actions:inject_network_info")
54 @decorators.idempotent_id('ce48c340-51c1-4cff-9b6e-0cc5ef008630')
55 def test_inject_network_info(self):
56 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
57 self.servers_client.inject_network_info(self.server_id)
58
59 @rbac_rule_validation.action(
60 service="nova",
61 rule="os_compute_api:os-admin-actions:reset_network")
62 @decorators.idempotent_id('2911a242-15c4-4fcb-80d5-80a8930661b0')
63 def test_reset_network(self):
64 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
65 self.servers_client.reset_network(self.server_id)
diff --git a/patrole_tempest_plugin/tests/api/compute/test_deferred_delete_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_deferred_delete_rbac.py
deleted file mode 100644
index ebeab76..0000000
--- a/patrole_tempest_plugin/tests/api/compute/test_deferred_delete_rbac.py
+++ /dev/null
@@ -1,47 +0,0 @@
1# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.lib import decorators
17from tempest import test
18
19from patrole_tempest_plugin import rbac_rule_validation
20from patrole_tempest_plugin.tests.api.compute import rbac_base
21
22
23class DeferredDeleteRbacTest(rbac_base.BaseV2ComputeRbacTest):
24
25 @classmethod
26 def skip_checks(cls):
27 super(DeferredDeleteRbacTest, cls).skip_checks()
28 if not test.is_extension_enabled('os-deferred-delete', 'compute'):
29 msg = "%s skipped as os-deferred-delete extension not enabled." \
30 % cls.__name__
31 raise cls.skipException(msg)
32
33 @classmethod
34 def resource_setup(cls):
35 super(DeferredDeleteRbacTest, cls).resource_setup()
36 cls.server = cls.create_test_server(wait_until='ACTIVE')
37
38 @decorators.idempotent_id('189bfed4-1e6d-475c-bb8c-d57e60895391')
39 @rbac_rule_validation.action(
40 service="nova",
41 rule="os_compute_api:os-deferred-delete")
42 def test_force_delete_server(self):
43 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
44 # Force-deleting a server enforces os-deferred-delete according to the
45 # following API: https://github.com/openstack/nova/blob/master/nova/api
46 # /openstack/compute/deferred_delete.py
47 self.servers_client.force_delete_server(self.server['id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_rescue_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_rescue_rbac.py
deleted file mode 100644
index a0a021f..0000000
--- a/patrole_tempest_plugin/tests/api/compute/test_rescue_rbac.py
+++ /dev/null
@@ -1,43 +0,0 @@
1# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.lib import decorators
17from tempest import test
18
19from patrole_tempest_plugin import rbac_rule_validation
20from patrole_tempest_plugin.tests.api.compute import rbac_base
21
22
23class RescueRbacTest(rbac_base.BaseV2ComputeRbacTest):
24
25 @classmethod
26 def skip_checks(cls):
27 super(RescueRbacTest, cls).skip_checks()
28 if not test.is_extension_enabled('os-rescue', 'compute'):
29 msg = "%s skipped as os-rescue not enabled." % cls.__name__
30 raise cls.skipException(msg)
31
32 @classmethod
33 def resource_setup(cls):
34 super(RescueRbacTest, cls).resource_setup()
35 cls.server = cls.create_test_server(wait_until='ACTIVE')
36
37 @rbac_rule_validation.action(
38 service="nova",
39 rule="os_compute_api:os-rescue")
40 @decorators.idempotent_id('fbbb2afc-ed0e-4552-887d-ac00fb5d436e')
41 def test_rescue_server(self):
42 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
43 self.servers_client.rescue_server(self.server['id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_diagnostics_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_diagnostics_rbac.py
deleted file mode 100644
index f6359b4..0000000
--- a/patrole_tempest_plugin/tests/api/compute/test_server_diagnostics_rbac.py
+++ /dev/null
@@ -1,44 +0,0 @@
1# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.lib import decorators
17from tempest import test
18
19from patrole_tempest_plugin import rbac_rule_validation
20from patrole_tempest_plugin.tests.api.compute import rbac_base
21
22
23class ServerDiagnosticsRbacTest(rbac_base.BaseV2ComputeRbacTest):
24
25 @classmethod
26 def skip_checks(cls):
27 super(ServerDiagnosticsRbacTest, cls).skip_checks()
28 if not test.is_extension_enabled('os-server-diagnostics', 'compute'):
29 msg = ("%s skipped as os-server-diagnostics not "
30 "enabled." % cls.__name__)
31 raise cls.skipException(msg)
32
33 @classmethod
34 def resource_setup(cls):
35 super(ServerDiagnosticsRbacTest, cls).resource_setup()
36 cls.server = cls.create_test_server(wait_until='ACTIVE')
37
38 @rbac_rule_validation.action(
39 service="nova",
40 rule="os_compute_api:os-server-diagnostics")
41 @decorators.idempotent_id('5dabfcc4-bedb-417b-8247-b3ee7c5c0f3e')
42 def test_show_server_diagnostics(self):
43 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
44 self.servers_client.show_server_diagnostics(self.server['id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_misc_policy_actions_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_misc_policy_actions_rbac.py
new file mode 100644
index 0000000..cb826e3
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_server_misc_policy_actions_rbac.py
@@ -0,0 +1,154 @@
1# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.common import waiters
17from tempest.lib import decorators
18from tempest.lib import exceptions as lib_exc
19from tempest import test
20
21from patrole_tempest_plugin import rbac_rule_validation
22from patrole_tempest_plugin.tests.api.compute import rbac_base
23
24
25class MiscPolicyActionsRbacTest(rbac_base.BaseV2ComputeRbacTest):
26 """Test multiple policy actions that require a server to be created.
27
28 Minimize the number of servers that need to be created across classes
29 by consolidating test cases related to different policy "families" into
30 one class. This reduces the risk of running into `BuildErrorException`
31 errors being raised due to too many servers being created simultaneously
32 especially when higher concurrency is used.
33
34 Only applies to:
35 * policy "families" that require server creation
36 * small policy "families" -- i.e. containing one to three policies
37 """
38
39 @classmethod
40 def resource_setup(cls):
41 super(MiscPolicyActionsRbacTest, cls).resource_setup()
42 cls.server_id = cls.create_test_server(wait_until='ACTIVE')['id']
43
44 def setUp(self):
45 super(MiscPolicyActionsRbacTest, self).setUp()
46 try:
47 waiters.wait_for_server_status(self.servers_client,
48 self.server_id, 'ACTIVE')
49 except lib_exc.NotFound:
50 # If the server was found to be deleted by a previous test,
51 # a new one is built
52 server = self.create_test_server(wait_until='ACTIVE')
53 self.__class__.server_id = server['id']
54 except Exception:
55 # Rebuilding the server in case something happened during a test
56 self.__class__.server_id = self.rebuild_server(self.server_id)
57
58 @test.requires_ext(extension='os-admin-actions', service='compute')
59 @rbac_rule_validation.action(
60 service="nova",
61 rule="os_compute_api:os-admin-actions:reset_state")
62 @decorators.idempotent_id('ae84dd0b-f364-462e-b565-3457f9c019ef')
63 def test_reset_server_state(self):
64 """Test reset server state, part of os-admin-actions."""
65 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
66 self.servers_client.reset_state(self.server_id, state='error')
67 self.addCleanup(self.servers_client.reset_state, self.server_id,
68 state='active')
69
70 @test.requires_ext(extension='os-admin-actions', service='compute')
71 @rbac_rule_validation.action(
72 service="nova",
73 rule="os_compute_api:os-admin-actions:inject_network_info")
74 @decorators.idempotent_id('ce48c340-51c1-4cff-9b6e-0cc5ef008630')
75 def test_inject_network_info(self):
76 """Test inject network info, part of os-admin-actions."""
77 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
78 self.servers_client.inject_network_info(self.server_id)
79
80 @test.attr(type=['slow'])
81 @test.requires_ext(extension='os-admin-actions', service='compute')
82 @rbac_rule_validation.action(
83 service="nova",
84 rule="os_compute_api:os-admin-actions:reset_network")
85 @decorators.idempotent_id('2911a242-15c4-4fcb-80d5-80a8930661b0')
86 def test_reset_network(self):
87 """Test reset network, part of os-admin-actions."""
88 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
89 self.servers_client.reset_network(self.server_id)
90
91 @test.requires_ext(extension='os-deferred-delete', service='compute')
92 @decorators.idempotent_id('189bfed4-1e6d-475c-bb8c-d57e60895391')
93 @rbac_rule_validation.action(
94 service="nova",
95 rule="os_compute_api:os-deferred-delete")
96 def test_force_delete_server(self):
97 """Test force delete server, part of os-deferred-delete."""
98 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
99 # Force-deleting a server enforces os-deferred-delete.
100 self.servers_client.force_delete_server(self.server_id)
101
102 @test.requires_ext(extension='os-rescue', service='compute')
103 @rbac_rule_validation.action(
104 service="nova",
105 rule="os_compute_api:os-rescue")
106 @decorators.idempotent_id('fbbb2afc-ed0e-4552-887d-ac00fb5d436e')
107 def test_rescue_server(self):
108 """Test rescue server, part of os-rescue."""
109 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
110 self.servers_client.rescue_server(self.server_id)
111
112 @test.requires_ext(extension='os-server-diagnostics', service='compute')
113 @rbac_rule_validation.action(
114 service="nova",
115 rule="os_compute_api:os-server-diagnostics")
116 @decorators.idempotent_id('5dabfcc4-bedb-417b-8247-b3ee7c5c0f3e')
117 def test_show_server_diagnostics(self):
118 """Test show server diagnostics, part of os-server-diagnostics."""
119 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
120 self.servers_client.show_server_diagnostics(self.server_id)
121
122 @test.requires_ext(extension='os-server-password', service='compute')
123 @decorators.idempotent_id('aaf43f78-c178-4581-ac18-14afd3f1f6ba')
124 @rbac_rule_validation.action(
125 service="nova",
126 rule="os_compute_api:os-server-password")
127 def test_delete_server_password(self):
128 """Test delete server password, part of os-server-password."""
129 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
130 self.servers_client.delete_password(self.server_id)
131
132 @test.requires_ext(extension='os-server-password', service='compute')
133 @rbac_rule_validation.action(
134 service="nova",
135 rule="os_compute_api:os-server-password")
136 @decorators.idempotent_id('f677971a-7d20-493c-977f-6ff0a74b5b2c')
137 def test_get_server_password(self):
138 """Test show server password, part of os-server-password."""
139 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
140 self.servers_client.show_password(self.server_id)
141
142 @test.requires_ext(extension='OS-SRV-USG', service='compute')
143 @rbac_rule_validation.action(
144 service="nova",
145 rule="os_compute_api:os-server-usage")
146 @decorators.idempotent_id('f0437ead-b9fb-462a-9f3d-ce53fac9d57a')
147 def test_show_server_usage(self):
148 """Test show server usage, part of os-server-usage.
149
150 TODO(felipemonteiro): Once multiple policy test is supported, this
151 test can be combined with the generic test for showing a server.
152 """
153 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
154 self.servers_client.show_server(self.server_id)
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_password_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_password_rbac.py
deleted file mode 100644
index 7826268..0000000
--- a/patrole_tempest_plugin/tests/api/compute/test_server_password_rbac.py
+++ /dev/null
@@ -1,52 +0,0 @@
1# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.lib import decorators
17from tempest import test
18
19from patrole_tempest_plugin import rbac_rule_validation
20from patrole_tempest_plugin.tests.api.compute import rbac_base
21
22
23class ServerPasswordRbacTest(rbac_base.BaseV2ComputeRbacTest):
24
25 @classmethod
26 def skip_checks(cls):
27 super(ServerPasswordRbacTest, cls).skip_checks()
28 if not test.is_extension_enabled('os-server-password', 'compute'):
29 msg = "%s skipped as os-server-password extension not enabled." \
30 % cls.__name__
31 raise cls.skipException(msg)
32
33 @classmethod
34 def resource_setup(cls):
35 super(ServerPasswordRbacTest, cls).resource_setup()
36 cls.server = cls.create_test_server(wait_until="ACTIVE")
37
38 @decorators.idempotent_id('aaf43f78-c178-4581-ac18-14afd3f1f6ba')
39 @rbac_rule_validation.action(
40 service="nova",
41 rule="os_compute_api:os-server-password")
42 def test_delete_server_password(self):
43 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
44 self.servers_client.delete_password(self.server['id'])
45
46 @rbac_rule_validation.action(
47 service="nova",
48 rule="os_compute_api:os-server-password")
49 @decorators.idempotent_id('f677971a-7d20-493c-977f-6ff0a74b5b2c')
50 def test_get_server_password(self):
51 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
52 self.servers_client.show_password(self.server['id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_usage_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_usage_rbac.py
deleted file mode 100644
index 777af29..0000000
--- a/patrole_tempest_plugin/tests/api/compute/test_server_usage_rbac.py
+++ /dev/null
@@ -1,43 +0,0 @@
1# Copyright 2017 AT&T Corporation.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.lib import decorators
17from tempest import test
18
19from patrole_tempest_plugin import rbac_rule_validation
20from patrole_tempest_plugin.tests.api.compute import rbac_base
21
22
23class ServerUsageRbacTest(rbac_base.BaseV2ComputeRbacTest):
24
25 @classmethod
26 def skip_checks(cls):
27 super(ServerUsageRbacTest, cls).skip_checks()
28 if not test.is_extension_enabled('OS-SRV-USG', 'compute'):
29 msg = "%s skipped as OS-SRV-USG not enabled." % cls.__name__
30 raise cls.skipException(msg)
31
32 @classmethod
33 def resource_setup(cls):
34 super(ServerUsageRbacTest, cls).resource_setup()
35 cls.server = cls.create_test_server(wait_until='ACTIVE')
36
37 @rbac_rule_validation.action(
38 service="nova",
39 rule="os_compute_api:os-server-usage")
40 @decorators.idempotent_id('f0437ead-b9fb-462a-9f3d-ce53fac9d57a')
41 def test_show_server_diagnostics(self):
42 self.rbac_utils.switch_role(self, toggle_rbac_role=True)
43 self.servers_client.show_server(self.server['id'])