blob: 103c24163bef4e0cbdc8c31ab334e1999a5154a3 [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
Andrea Frittoli50bb80d2014-09-15 12:34:27 +010023 def resource_setup(cls):
24 super(InstanceActionsTestJSON, cls).resource_setup()
Leo Toyodafaca6ff2013-04-22 16:52:53 +090025 cls.client = cls.servers_client
David Kranz0fb14292015-02-11 15:55:20 -050026 server = cls.create_test_server(wait_until='ACTIVE')
27 cls.request_id = server.response['x-compute-request-id']
Leo Toyodafaca6ff2013-04-22 16:52:53 +090028 cls.server_id = server['id']
29
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053030 @test.attr(type='gate')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090031 def test_list_instance_actions(self):
32 # List actions of the provided server
33 resp, body = self.client.reboot(self.server_id, 'HARD')
34 self.client.wait_for_server_status(self.server_id, 'ACTIVE')
35
36 resp, body = self.client.list_instance_actions(self.server_id)
37 self.assertEqual(200, resp.status)
Attila Fazekas4b8b0082013-10-25 14:24:32 +020038 self.assertTrue(len(body) == 2, str(body))
Leo Toyodafaca6ff2013-04-22 16:52:53 +090039 self.assertTrue(any([i for i in body if i['action'] == 'create']))
40 self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
41
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053042 @test.attr(type='gate')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090043 def test_get_instance_action(self):
44 # Get the action details of the provided server
45 resp, body = self.client.get_instance_action(self.server_id,
46 self.request_id)
47 self.assertEqual(200, resp.status)
48 self.assertEqual(self.server_id, body['instance_uuid'])
49 self.assertEqual('create', body['action'])