blob: f63a3600556f75289e886f902a62d9c907b487c7 [file] [log] [blame]
rabi90b3ab42017-05-04 13:02:28 +05301# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14from heat_integrationtests.functional import functional_base
15
16
17class StackSnapshotRestoreTest(functional_base.FunctionalTestsBase):
18
19 def setUp(self):
20 super(StackSnapshotRestoreTest, self).setUp()
21 if not self.conf.minimal_image_ref:
22 raise self.skipException("No image configured to test")
23
24 if not self.conf.minimal_instance_type:
25 raise self.skipException(
26 "No minimal_instance_type configured to test")
27
28 self.assign_keypair()
29
30 def test_stack_snapshot_restore(self):
31 template = '''
32heat_template_version: ocata
33parameters:
34 keyname:
35 type: string
36 flavor:
37 type: string
38 image:
39 type: string
40 network:
41 type: string
42resources:
43 my_port:
44 type: OS::Neutron::Port
45 properties:
46 network: {get_param: network}
47 my_server:
48 type: OS::Nova::Server
49 properties:
50 image: {get_param: image}
51 flavor: {get_param: flavor}
52 key_name: {get_param: keyname}
53 networks: [{port: {get_resource: my_port} }]
54
55'''
56
57 def get_server_image(server_id):
58 server = self.compute_client.servers.get(server_id)
59 return server.image['id']
60
61 parameters = {'keyname': self.keypair_name,
62 'flavor': self.conf.minimal_instance_type,
63 'image': self.conf.minimal_image_ref,
64 'network': self.conf.fixed_network_name}
65 stack_identifier = self.stack_create(template=template,
66 parameters=parameters)
67 server_resource = self.client.resources.get(
68 stack_identifier, 'my_server')
69 server_id = server_resource.physical_resource_id
70 prev_image_id = get_server_image(server_id)
71
72 # Do snapshot and restore
73 snapshot_id = self.stack_snapshot(stack_identifier)
74 self.stack_restore(stack_identifier, snapshot_id)
75
76 self.assertNotEqual(prev_image_id, get_server_image(server_id))