diff options
| author | Stephen Finucane <stephenfin@redhat.com> | 2023-05-17 11:58:39 +0100 |
|---|---|---|
| committer | Stephen Finucane <stephenfin@redhat.com> | 2023-05-17 15:59:33 +0100 |
| commit | 0a63f8603e37542a9758db4ed2db73c781b48e4f (patch) | |
| tree | b251b9bb68cccecd066fcb047442c09ff0ec5372 /openstackclient/tests/functional | |
| parent | 3c9afe69bbb249b30e586fd0f8b3dd095d2cab48 (diff) | |
| download | python-openstackclient-0a63f8603e37542a9758db4ed2db73c781b48e4f.tar.gz | |
compute: Fix bug with start/stop server
A mistake was introduced during the conversion from novaclient to SDK in
change I5ebfa6b2468d5f20b99ea0eab1aea9377be09b8c. Fix the issue and add
functional tests to prevent it being reintroduced.
Change-Id: I6b314eab31bcf452e88b8b6a239ac2e296497cb9
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Story: 2010750
Task: 48004
Diffstat (limited to 'openstackclient/tests/functional')
| -rw-r--r-- | openstackclient/tests/functional/compute/v2/test_server.py | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/openstackclient/tests/functional/compute/v2/test_server.py b/openstackclient/tests/functional/compute/v2/test_server.py index 7ce1ddcb..d04fe31d 100644 --- a/openstackclient/tests/functional/compute/v2/test_server.py +++ b/openstackclient/tests/functional/compute/v2/test_server.py @@ -27,11 +27,11 @@ class ServerTests(common.ComputeTestCase): @classmethod def setUpClass(cls): - super(ServerTests, cls).setUpClass() + super().setUpClass() cls.haz_network = cls.is_service_enabled('network') def test_server_list(self): - """Test server list, set""" + """Test server list""" cmd_output = self.server_create() name1 = cmd_output['name'] cmd_output = self.server_create() @@ -1447,6 +1447,46 @@ class ServerTests(common.ComputeTestCase): raw_output = self.openstack('server volume list ' + server_name) self.assertEqual('\n', raw_output) + def test_server_stop_start(self): + """Test server stop, start""" + server_name = uuid.uuid4().hex + cmd_output = self.openstack( + 'server create ' + + '--network private ' + + '--flavor ' + + self.flavor_name + + ' ' + + '--image ' + + self.image_name + + ' ' + + '--wait ' + + server_name, + parse_output=True, + ) + + self.assertIsNotNone(cmd_output['id']) + self.assertEqual(server_name, cmd_output['name']) + self.addCleanup(self.openstack, 'server delete --wait ' + server_name) + server_id = cmd_output['id'] + + cmd_output = self.openstack( + 'server stop ' + server_name, + ) + self.assertEqual("", cmd_output) + + # This is our test that the request succeeded. If it doesn't transition + # to SHUTOFF then it didn't work. + self.wait_for_status(server_id, "SHUTOFF") + + cmd_output = self.openstack( + 'server start ' + server_name, + ) + self.assertEqual("", cmd_output) + + # As above, this is our test that the request succeeded. If it doesn't + # transition to ACTIVE then it didn't work. + self.wait_for_status(server_id, "ACTIVE") + def test_server_migration_list(self): # Verify that the command does not raise an exception when we list # migrations, including when we specify a query. |
