blob: 667b84f50939104a636fe9344d83914bc5d2d5b5 [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 _interface = 'json'
22
23 @classmethod
24 def setUpClass(cls):
25 super(InstanceActionsTestJSON, cls).setUpClass()
26 cls.client = cls.servers_client
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090027 resp, server = cls.create_test_server(wait_until='ACTIVE')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090028 cls.request_id = resp['x-compute-request-id']
29 cls.server_id = server['id']
30
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053031 @test.attr(type='gate')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090032 def test_list_instance_actions(self):
33 # List actions of the provided server
34 resp, body = self.client.reboot(self.server_id, 'HARD')
35 self.client.wait_for_server_status(self.server_id, 'ACTIVE')
36
37 resp, body = self.client.list_instance_actions(self.server_id)
38 self.assertEqual(200, resp.status)
Attila Fazekas4b8b0082013-10-25 14:24:32 +020039 self.assertTrue(len(body) == 2, str(body))
Leo Toyodafaca6ff2013-04-22 16:52:53 +090040 self.assertTrue(any([i for i in body if i['action'] == 'create']))
41 self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
42
Hoisaleshwara Madan V Sa39f4c22013-12-26 10:32:42 +053043 @test.attr(type='gate')
Leo Toyodafaca6ff2013-04-22 16:52:53 +090044 def test_get_instance_action(self):
45 # Get the action details of the provided server
46 resp, body = self.client.get_instance_action(self.server_id,
47 self.request_id)
48 self.assertEqual(200, resp.status)
49 self.assertEqual(self.server_id, body['instance_uuid'])
50 self.assertEqual('create', body['action'])
51
Leo Toyodafaca6ff2013-04-22 16:52:53 +090052
53class InstanceActionsTestXML(InstanceActionsTestJSON):
54 _interface = 'xml'