blob: e93ed2b42062b2ef481b5b88c6089e2e9f7e45d6 [file] [log] [blame]
Daryl Walleck1465d612011-11-02 02:22:15 -05001from nose.plugins.attrib import attr
2from storm import openstack
3import unittest2 as unittest
4import storm.config
5from storm.common.utils.data_utils import rand_name
6
7
8class ServerActionsTest(unittest.TestCase):
9 resize_available = storm.config.StormConfig().env.resize_available
10
11 @classmethod
12 def setUpClass(cls):
13 cls.os = openstack.Manager()
14 cls.client = cls.os.servers_client
15 cls.config = storm.config.StormConfig()
16 cls.image_ref = cls.config.env.image_ref
17 cls.image_ref_alt = cls.config.env.image_ref_alt
18 cls.flavor_ref = cls.config.env.flavor_ref
19 cls.flavor_ref_alt = cls.config.env.flavor_ref_alt
20
21 def setUp(self):
22 self.name = rand_name('server')
23 resp, server = self.client.create_server(self.name, self.image_ref,
24 self.flavor_ref)
25 self.id = server['id']
26 self.client.wait_for_server_status(self.id, 'ACTIVE')
27
28 def tearDown(self):
29 self.client.delete_server(self.id)
30
31 @attr(type='smoke')
32 def test_change_server_password(self):
33 """ The server's password should be set to the provided password """
34 resp, body = self.client.change_password(self.id, 'newpass')
35 self.client.wait_for_server_status(self.id, 'ACTIVE')
36 #TODO: SSH in to verify the new password works
37
38 @attr(type='smoke')
39 def test_reboot_server_hard(self):
40 """ The server should be power cycled """
41 #TODO: Add validation the server has been rebooted
42
43 resp, body = self.client.reboot(self.id, 'HARD')
44 self.client.wait_for_server_status(self.id, 'ACTIVE')
45
46 @attr(type='smoke')
47 def test_reboot_server_soft(self):
48 """ The server should be signaled to reboot gracefully """
49 #TODO: Add validation the server has been rebooted
50
51 resp, body = self.client.reboot(self.id, 'SOFT')
52 self.client.wait_for_server_status(self.id, 'ACTIVE')
53
54 @attr(type='smoke')
55 def test_rebuild_server(self):
56 """ The server should be rebuilt using the provided image """
57
58 self.client.rebuild(self.id, self.image_ref_alt, name='rebuiltserver')
59 self.client.wait_for_server_status(self.id, 'ACTIVE')
60 resp, server = self.client.get_server(self.id)
61 self.assertEqual(self.image_ref_alt, server['image']['id'])
62 self.assertEqual('rebuiltserver', server['name'])
63
64 @attr(type='smoke')
65 @unittest.skipIf(not resize_available, 'Resize not available.')
66 def test_resize_server_confirm(self):
67 """
68 The server's RAM and disk space should be modified to that of
69 the provided flavor
70 """
71
72 self.client.resize(self.id, self.flavor_ref_alt)
73 self.client.wait_for_server_status(self.id, 'VERIFY_RESIZE')
74
75 self.client.confirm_resize(self.id)
76 self.client.wait_for_server_status(self.id, 'ACTIVE')
77
78 resp, server = self.client.get_server(self.id)
79 self.assertEqual(self.flavor_ref_alt, server['flavor']['id'])
80
81 @attr(type='smoke')
82 @unittest.skipIf(not resize_available, 'Resize not available.')
83 def test_resize_server_revert(self):
84 """
85 The server's RAM and disk space should return to its original
86 values after a resize is reverted
87 """
88
89 self.client.resize(self.id, self.flavor_ref_alt)
90 self.client.wait_for_server_status(id, 'VERIFY_RESIZE')
91
92 self.client.revert_resize(self.id)
93 self.client.wait_for_server_status(id, 'ACTIVE')
94
95 resp, server = self.client.get_server(id)
96 self.assertEqual(self.flavor_ref, server['flavor']['id'])