blob: e5da0a2c382a516034d40aa9a349d3957a180f24 [file] [log] [blame]
Leo Toyodafaca6ff2013-04-22 16:52:53 +09001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2013 NEC Corporation
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Leo Toyodafaca6ff2013-04-22 16:52:53 +090019from tempest import exceptions
20from tempest.test import attr
Leo Toyodafaca6ff2013-04-22 16:52:53 +090021
22
23class InstanceActionsTestJSON(base.BaseComputeTest):
24 _interface = 'json'
25
26 @classmethod
27 def setUpClass(cls):
28 super(InstanceActionsTestJSON, cls).setUpClass()
29 cls.client = cls.servers_client
30 resp, server = cls.create_server(wait_until='ACTIVE')
31 cls.request_id = resp['x-compute-request-id']
32 cls.server_id = server['id']
33
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040034 @attr(type=['positive', 'gate'])
Leo Toyodafaca6ff2013-04-22 16:52:53 +090035 def test_list_instance_actions(self):
36 # List actions of the provided server
37 resp, body = self.client.reboot(self.server_id, 'HARD')
38 self.client.wait_for_server_status(self.server_id, 'ACTIVE')
39
40 resp, body = self.client.list_instance_actions(self.server_id)
41 self.assertEqual(200, resp.status)
42 self.assertTrue(len(body) == 2)
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
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040046 @attr(type=['positive', 'gate'])
Leo Toyodafaca6ff2013-04-22 16:52:53 +090047 def test_get_instance_action(self):
48 # Get the action details of the provided server
49 resp, body = self.client.get_instance_action(self.server_id,
50 self.request_id)
51 self.assertEqual(200, resp.status)
52 self.assertEqual(self.server_id, body['instance_uuid'])
53 self.assertEqual('create', body['action'])
54
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040055 @attr(type=['negative', 'gate'])
Leo Toyodafaca6ff2013-04-22 16:52:53 +090056 def test_list_instance_actions_invalid_server(self):
57 # List actions of the invalid server id
58 self.assertRaises(exceptions.NotFound,
59 self.client.list_instance_actions, 'server-999')
60
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040061 @attr(type=['negative', 'gate'])
Leo Toyodafaca6ff2013-04-22 16:52:53 +090062 def test_get_instance_action_invalid_request(self):
63 # Get the action details of the provided server with invalid request
64 self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
65 self.server_id, '999')
66
67
68class InstanceActionsTestXML(InstanceActionsTestJSON):
69 _interface = 'xml'