blob: c80417032680d846e6d42c7d480c9ce097c52e24 [file] [log] [blame]
Leo Toyodafaca6ff2013-04-22 16:52:53 +09001# Copyright 2013 NEC 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
Sean Dague1937d092013-05-17 16:36:38 -040016from tempest.api.compute import base
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053017from tempest import test
Leo Toyodafaca6ff2013-04-22 16:52:53 +090018
19
ivan-zhuf2b00502013-10-18 10:06:52 +080020class InstanceActionsTestJSON(base.BaseV2ComputeTest):
Leo Toyodafaca6ff2013-04-22 16:52:53 +090021
22 @classmethod
Rohan Kanade60b73092015-02-04 17:58:19 +053023 def setup_clients(cls):
24 super(InstanceActionsTestJSON, cls).setup_clients()
25 cls.client = cls.servers_client
26
27 @classmethod
Andrea Frittoli50bb80d2014-09-15 12:34:27 +010028 def resource_setup(cls):
29 super(InstanceActionsTestJSON, cls).resource_setup()
David Kranz0fb14292015-02-11 15:55:20 -050030 server = cls.create_test_server(wait_until='ACTIVE')
31 cls.request_id = server.response['x-compute-request-id']
Leo Toyodafaca6ff2013-04-22 16:52:53 +090032 cls.server_id = server['id']
33
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053034 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080035 @test.idempotent_id('77ca5cc5-9990-45e0-ab98-1de8fead201a')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090036 def test_list_instance_actions(self):
37 # List actions of the provided server
David Kranzae99b9a2015-02-16 13:37:01 -050038 self.client.reboot(self.server_id, 'HARD')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090039 self.client.wait_for_server_status(self.server_id, 'ACTIVE')
40
David Kranzae99b9a2015-02-16 13:37:01 -050041 body = self.client.list_instance_actions(self.server_id)
Attila Fazekas4b8b0082013-10-25 14:24:32 +020042 self.assertTrue(len(body) == 2, str(body))
Leo Toyodafaca6ff2013-04-22 16:52:53 +090043 self.assertTrue(any([i for i in body if i['action'] == 'create']))
44 self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
45
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053046 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080047 @test.idempotent_id('aacc71ca-1d70-4aa5-bbf6-0ff71470e43c')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090048 def test_get_instance_action(self):
49 # Get the action details of the provided server
David Kranzae99b9a2015-02-16 13:37:01 -050050 body = self.client.get_instance_action(self.server_id,
51 self.request_id)
Leo Toyodafaca6ff2013-04-22 16:52:53 +090052 self.assertEqual(self.server_id, body['instance_uuid'])
53 self.assertEqual('create', body['action'])