Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 1 | # 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 Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 16 | from tempest.api.compute import base |
Hoisaleshwara Madan V S | a39f4c2 | 2013-12-26 10:32:42 +0530 | [diff] [blame] | 17 | from tempest import test |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 18 | |
| 19 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 20 | class InstanceActionsTestJSON(base.BaseV2ComputeTest): |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 21 | _interface = 'json' |
| 22 | |
| 23 | @classmethod |
| 24 | def setUpClass(cls): |
| 25 | super(InstanceActionsTestJSON, cls).setUpClass() |
| 26 | cls.client = cls.servers_client |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 27 | resp, server = cls.create_test_server(wait_until='ACTIVE') |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 28 | cls.request_id = resp['x-compute-request-id'] |
| 29 | cls.server_id = server['id'] |
| 30 | |
Hoisaleshwara Madan V S | a39f4c2 | 2013-12-26 10:32:42 +0530 | [diff] [blame] | 31 | @test.attr(type='gate') |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 32 | 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 Fazekas | 4b8b008 | 2013-10-25 14:24:32 +0200 | [diff] [blame] | 39 | self.assertTrue(len(body) == 2, str(body)) |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 40 | 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 S | a39f4c2 | 2013-12-26 10:32:42 +0530 | [diff] [blame] | 43 | @test.attr(type='gate') |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 44 | 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 Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 52 | |
| 53 | class InstanceActionsTestXML(InstanceActionsTestJSON): |
| 54 | _interface = 'xml' |