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 | |
| 22 | @classmethod |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 23 | def setup_clients(cls): |
| 24 | super(InstanceActionsTestJSON, cls).setup_clients() |
| 25 | cls.client = cls.servers_client |
| 26 | |
| 27 | @classmethod |
Andrea Frittoli | 50bb80d | 2014-09-15 12:34:27 +0100 | [diff] [blame] | 28 | def resource_setup(cls): |
| 29 | super(InstanceActionsTestJSON, cls).resource_setup() |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 30 | server = cls.create_test_server(wait_until='ACTIVE') |
| 31 | cls.request_id = server.response['x-compute-request-id'] |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 32 | cls.server_id = server['id'] |
| 33 | |
Hoisaleshwara Madan V S | a39f4c2 | 2013-12-26 10:32:42 +0530 | [diff] [blame] | 34 | @test.attr(type='gate') |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 35 | @test.idempotent_id('77ca5cc5-9990-45e0-ab98-1de8fead201a') |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 36 | def test_list_instance_actions(self): |
| 37 | # List actions of the provided server |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame] | 38 | self.client.reboot(self.server_id, 'HARD') |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 39 | self.client.wait_for_server_status(self.server_id, 'ACTIVE') |
| 40 | |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame] | 41 | body = self.client.list_instance_actions(self.server_id) |
Attila Fazekas | 4b8b008 | 2013-10-25 14:24:32 +0200 | [diff] [blame] | 42 | self.assertTrue(len(body) == 2, str(body)) |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 43 | 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 S | a39f4c2 | 2013-12-26 10:32:42 +0530 | [diff] [blame] | 46 | @test.attr(type='gate') |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 47 | @test.idempotent_id('aacc71ca-1d70-4aa5-bbf6-0ff71470e43c') |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 48 | def test_get_instance_action(self): |
| 49 | # Get the action details of the provided server |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame] | 50 | body = self.client.get_instance_action(self.server_id, |
| 51 | self.request_id) |
Leo Toyoda | faca6ff | 2013-04-22 16:52:53 +0900 | [diff] [blame] | 52 | self.assertEqual(self.server_id, body['instance_uuid']) |
| 53 | self.assertEqual('create', body['action']) |