コード例 #1
0
    def test_resource_names(self):
        stack = utils.parse_stack(self.template)
        snip = stack.t.resource_definitions(stack)['deploy_mysql']
        resg = sd.SoftwareDeploymentGroup('test', snip, stack)
        self.assertEqual(set(('server1', 'server2')),
                         set(resg._resource_names()))

        resg.properties = {'servers': {'s1': 'u1', 's2': 'u2', 's3': 'u3'}}
        self.assertEqual(set(('s1', 's2', 's3')), set(resg._resource_names()))
コード例 #2
0
 def test_build_resource_definition(self):
     stack = utils.parse_stack(self.template)
     snip = stack.t.resource_definitions(stack)['deploy_mysql']
     resg = sd.SoftwareDeploymentGroup('test', snip, stack)
     expect = {
         'type': 'OS::Heat::SoftwareDeployment',
         'properties': {
             'actions': ['CREATE', 'UPDATE'],
             'config': 'config_uuid',
             'input_values': {
                 'foo': 'bar'
             },
             'name': '10_config',
             'signal_transport': 'CFN_SIGNAL'
         }
     }
     self.assertEqual(expect, resg._build_resource_definition())
     self.assertEqual(expect,
                      resg._build_resource_definition(include_all=True))
コード例 #3
0
    def test_assemble_nested(self):
        """
        Tests that the nested stack that implements the group is created
        appropriately based on properties.
        """
        stack = utils.parse_stack(self.template)
        snip = stack.t.resource_definitions(stack)['deploy_mysql']
        resg = sd.SoftwareDeploymentGroup('test', snip, stack)
        templ = {
            "heat_template_version": "2013-05-23",
            "resources": {
                "server1": {
                    'type': 'OS::Heat::SoftwareDeployment',
                    'properties': {
                        'server': 'uuid1',
                        'actions': ['CREATE', 'UPDATE'],
                        'config': 'config_uuid',
                        'input_values': {
                            'foo': 'bar'
                        },
                        'name': '10_config',
                        'signal_transport': 'CFN_SIGNAL'
                    }
                },
                "server2": {
                    'type': 'OS::Heat::SoftwareDeployment',
                    'properties': {
                        'server': 'uuid2',
                        'actions': ['CREATE', 'UPDATE'],
                        'config': 'config_uuid',
                        'input_values': {
                            'foo': 'bar'
                        },
                        'name': '10_config',
                        'signal_transport': 'CFN_SIGNAL'
                    }
                }
            }
        }

        self.assertEqual(templ, resg._assemble_nested(['server1', 'server2']))
コード例 #4
0
    def test_attributes(self):
        stack = utils.parse_stack(self.template)
        snip = stack.t.resource_definitions(stack)['deploy_mysql']
        resg = sd.SoftwareDeploymentGroup('test', snip, stack)
        nested = self.patchobject(resg, 'nested')
        server1 = mock.MagicMock()
        server2 = mock.MagicMock()
        nested.return_value = {'server1': server1, 'server2': server2}

        server1.FnGetAtt.return_value = 'Thing happened on server1'
        server2.FnGetAtt.return_value = 'ouch'
        self.assertEqual(
            {
                'server1': 'Thing happened on server1',
                'server2': 'ouch'
            }, resg.FnGetAtt('deploy_stdouts'))

        server1.FnGetAtt.return_value = ''
        server2.FnGetAtt.return_value = 'Its gone Pete Tong'
        self.assertEqual({
            'server1': '',
            'server2': 'Its gone Pete Tong'
        }, resg.FnGetAtt('deploy_stderrs'))

        server1.FnGetAtt.return_value = 0
        server2.FnGetAtt.return_value = 1
        self.assertEqual({
            'server1': 0,
            'server2': 1
        }, resg.FnGetAtt('deploy_status_codes'))

        server1.FnGetAtt.assert_has_calls([
            mock.call('deploy_stdout'),
            mock.call('deploy_stderr'),
            mock.call('deploy_status_code'),
        ])
コード例 #5
0
 def test_validate(self):
     stack = utils.parse_stack(self.template)
     snip = stack.t.resource_definitions(stack)['deploy_mysql']
     resg = sd.SoftwareDeploymentGroup('deploy_mysql', snip, stack)
     self.assertIsNone(resg.validate())