blob: 814aec73fca8a266fa43346ff322298d6bb3beb4 [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
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000017from tempest.common import waiters
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053018from tempest import test
Leo Toyodafaca6ff2013-04-22 16:52:53 +090019
20
ivan-zhuf2b00502013-10-18 10:06:52 +080021class InstanceActionsTestJSON(base.BaseV2ComputeTest):
Leo Toyodafaca6ff2013-04-22 16:52:53 +090022
23 @classmethod
Rohan Kanade60b73092015-02-04 17:58:19 +053024 def setup_clients(cls):
25 super(InstanceActionsTestJSON, cls).setup_clients()
26 cls.client = cls.servers_client
27
28 @classmethod
Andrea Frittoli50bb80d2014-09-15 12:34:27 +010029 def resource_setup(cls):
30 super(InstanceActionsTestJSON, cls).resource_setup()
David Kranz0fb14292015-02-11 15:55:20 -050031 server = cls.create_test_server(wait_until='ACTIVE')
32 cls.request_id = server.response['x-compute-request-id']
Leo Toyodafaca6ff2013-04-22 16:52:53 +090033 cls.server_id = server['id']
34
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
Ken'ichi Ohmichi5271b0f2015-08-10 07:53:27 +000038 self.client.reboot_server(self.server_id, 'HARD')
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000039 waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090040
ghanshyam0f825252015-08-25 16:02:50 +090041 body = (self.client.list_instance_actions(self.server_id)
42 ['instanceActions'])
Attila Fazekas4b8b0082013-10-25 14:24:32 +020043 self.assertTrue(len(body) == 2, str(body))
Leo Toyodafaca6ff2013-04-22 16:52:53 +090044 self.assertTrue(any([i for i in body if i['action'] == 'create']))
45 self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
46
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
Ken'ichi Ohmichi277d1882015-11-20 00:44:06 +000050 body = self.client.show_instance_action(
ghanshyam0f825252015-08-25 16:02:50 +090051 self.server_id, self.request_id)['instanceAction']
Leo Toyodafaca6ff2013-04-22 16:52:53 +090052 self.assertEqual(self.server_id, body['instance_uuid'])
53 self.assertEqual('create', body['action'])