Move pause_available class variable into skip decorators
We shouldn't do a getattr on CONF in the class definition. It will cause
import errors if there isn't a config file. Just use
CONF.compute_feature_enabled.pause in the skip decorator.
Change-Id: If24c45eba0ee466a00589806b27c736c0e8dba54
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 7e34213..451d08f 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -23,7 +23,6 @@
class DeleteServersTestJSON(base.BaseV2ComputeTest):
- pause_available = CONF.compute_feature_enabled.pause
# NOTE: Server creations of each test class should be under 10
# for preventing "Quota exceeded for instances"
@@ -59,7 +58,8 @@
self.assertEqual('204', resp['status'])
self.client.wait_for_server_termination(server['id'])
- @testtools.skipIf(not pause_available, 'Pause is not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.pause,
+ 'Pause is not available.')
@test.attr(type='gate')
def test_delete_server_while_in_pause_state(self):
# Delete a server while it's VM state is Pause
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 4b3551c..8e9481f 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -30,7 +30,6 @@
class ServerActionsTestJSON(base.BaseV2ComputeTest):
resize_available = CONF.compute_feature_enabled.resize
- pause_available = CONF.compute_feature_enabled.pause
run_ssh = CONF.compute.run_ssh
def setUp(self):
@@ -341,7 +340,8 @@
self.wait_for(self._get_output)
- @testtools.skipIf(not pause_available, 'Pause is not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.pause,
+ 'Pause is not available.')
@test.attr(type='gate')
def test_pause_unpause_server(self):
resp, server = self.client.pause_server(self.server_id)
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index dd69d91..cc801b5 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -29,7 +29,6 @@
class ServersNegativeTestJSON(base.BaseV2ComputeTest):
- pause_available = CONF.compute_feature_enabled.pause
def setUp(self):
super(ServersNegativeTestJSON, self).setUp()
@@ -128,7 +127,8 @@
self.assertRaises(exceptions.NotFound, self.client.reboot,
nonexistent_server, 'SOFT')
- @testtools.skipIf(not pause_available, 'Pause is not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.pause,
+ 'Pause is not available.')
@test.attr(type=['negative', 'gate'])
def test_pause_paused_server(self):
# Pause a paused server.
@@ -308,7 +308,8 @@
self.assertRaises(exceptions.NotFound, self.servers_client.stop,
nonexistent_server)
- @testtools.skipIf(not pause_available, 'Pause is not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.pause,
+ 'Pause is not available.')
@test.attr(type=['negative', 'gate'])
def test_pause_non_existent_server(self):
# pause a non existent server
@@ -316,7 +317,8 @@
self.assertRaises(exceptions.NotFound, self.client.pause_server,
nonexistent_server)
- @testtools.skipIf(not pause_available, 'Pause is not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.pause,
+ 'Pause is not available.')
@test.attr(type=['negative', 'gate'])
def test_unpause_non_existent_server(self):
# unpause a non existent server
@@ -324,7 +326,8 @@
self.assertRaises(exceptions.NotFound, self.client.unpause_server,
nonexistent_server)
- @testtools.skipIf(not pause_available, 'Pause is not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.pause,
+ 'Pause is not available.')
@test.attr(type=['negative', 'gate'])
def test_unpause_server_invalid_state(self):
# unpause an active server.