From 47becd62ddfa4a9d08e84b512ed660b07e73a132 Mon Sep 17 00:00:00 2001 From: Yoshihiko Atsumi Date: Wed, 18 Jan 2017 02:52:57 +0000 Subject: [PATCH] Add revert resized server functional negative tests The negative tests of revert resized server API are not covered enough in functional tests. We want to add the conflict tests of when this API runs in the unexpected state of server. * Case of revert resized server API, the server status must be VERIFY_RESIZE. Change-Id: I67d7173156fb8cc93b209d6563b7d31c400cc2b3 --- nova/tests/functional/test_servers.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 0f3df6b12fff..05ed9f4e9d57 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -590,6 +590,29 @@ class ServersTest(ServersTestBase): # Cleanup self._delete_server(created_server_id) + def test_revert_resized_server_negative_invalid_state(self): + # Create server + server = self._build_minimal_create_server_request() + created_server = self.api.post_server({"server": server}) + created_server_id = created_server['id'] + found_server = self._wait_for_state_change(created_server, 'BUILD') + self.assertEqual('ACTIVE', found_server['status']) + + # Revert resized server in ACTIVE + # NOTE(yatsumi): When revert resized server API runs, + # the server status must be VERIFY_RESIZE. + # By returning 409, I want to confirm that the ACTIVE server does not + # cause unexpected behavior. + post = {'revertResize': {}} + ex = self.assertRaises(client.OpenStackApiException, + self.api.post_server_action, + created_server_id, post) + self.assertEqual(409, ex.response.status_code) + self.assertEqual('ACTIVE', found_server['status']) + + # Cleanup + self._delete_server(created_server_id) + class ServersTestV21(ServersTest): api_major_version = 'v2.1'