def test_get_stack_order_raises_exception_on_cyclic_dependency(self):
        stacks = {
            'app1':
            StackConfig({
                'template-url': 'horst.yml',
                'parameters': {
                    'a': '|Ref|app2.id'
                }
            }),
            'app2':
            StackConfig({
                'template-url': 'horst.yml',
                'parameters': {
                    'a': '|Ref|app3.id'
                }
            }),
            'app3':
            StackConfig({
                'template-url': 'horst.yml',
                'parameters': {
                    'a': '|Ref|app1.id'
                }
            })
        }

        with self.assertRaises(CyclicDependencyException):
            DependencyResolver.get_stack_order(stacks)
    def test_get_stack_order_includes_independent_stacks(self):
        stacks = {
            'default-sg':
            StackConfig({'template-url': 'horst.yml'}),
            'app1':
            StackConfig({
                'template-url': 'horst.yml',
                'parameters': {
                    'a': '|Ref|vpc.id',
                    'b': '|Ref|default-sg.id'
                }
            }),
            'app2':
            StackConfig({
                'template-url': 'horst.yml',
                'parameters': {
                    'a': '|Ref|vpc.id',
                    'b': '|Ref|default-sg.id',
                    'c': 'Ref::app1.id'
                }
            }),
            'vpc':
            StackConfig({
                'template-url': 'horst.yml',
                'parameters': {
                    'logBucketName': 'is24-cloudtrail-logs',
                    'includeGlobalServices': False
                }
            })
        }

        result = 4

        self.assertEqual(result,
                         len(DependencyResolver.get_stack_order(stacks)))
Пример #3
0
    def test_apply_stack_name_suffix_applies_suffix_to_sublist_items(self):
        stacks = {
            "stack-a": StackConfig(
                {"template-url": "some-url", "parameters": {"alist": ["|ref|stack-b.a", "|ref|stack-b.b"]}}),
            "stack-b": StackConfig({"template-url": "some-url"})
        }

        result = Config._apply_stack_name_suffix(stacks, "-test")

        self.assertEqual(result["stack-a-test"].parameters["alist"][0], "|ref|stack-b-test.a")
        self.assertEqual(result["stack-a-test"].parameters["alist"][1], "|ref|stack-b-test.b")
Пример #4
0
    def test_apply_stack_name_suffix_appends_number_suffix_to_all_stacks(self):
        stacks = {
            "stack-a": StackConfig({"template-url": "some-url", "parameters": {"a": 1, "b": "|ref|stack-b.a"}}),
            "stack-b": StackConfig({"template-url": "some-url", "parameters": {"a": 1, "b": "foo"}})
        }

        result = Config._apply_stack_name_suffix(stacks, 3)

        self.assertEqual(result["stack-a3"].parameters["a"], 1)
        self.assertEqual(result["stack-a3"].parameters["b"], "|ref|stack-b3.a")
        self.assertEqual(result["stack-b3"].parameters["a"], 1)
        self.assertEqual(result["stack-b3"].parameters["b"], "foo")
    def test_get_stack_order_returns_a_valid_order(self):
        stacks = {'default-sg': StackConfig({'template-url': 'horst.yml', 'parameters': {'a': '|Ref|vpc.id'}}),
                  'app1': StackConfig(
                      {'template-url': 'horst.yml', 'parameters': {'a': '|Ref|vpc.id', 'b': '|Ref|default-sg.id'}}),
                  'app2': StackConfig({'template-url': 'horst.yml',
                                       'parameters': {'a': '|Ref|vpc.id', 'b': '|Ref|default-sg.id',
                                                      'c': '|Ref|app1.id'}}),
                  'vpc': StackConfig({'template-url': 'horst.yml',
                                      'parameters': {'logBucketName': 'is24-cloudtrail-logs',
                                                     'includeGlobalServices': False}})
                  }

        expected = ['vpc', 'default-sg', 'app1', 'app2']

        self.assertEqual(expected, DependencyResolver.get_stack_order(stacks))
Пример #6
0
    def test_apply_stack_name_suffix_does_not_append_none_suffix(self):
        stacks = {
            "stack-d": StackConfig({"template-url": "some-url"})
        }

        result = Config._apply_stack_name_suffix(stacks, None)
        self.assertEqual(result, stacks)
Пример #7
0
 def create_stack_config(self):
     return StackConfig(
         {
             'template-url': 'any url',
             'timeout': 1,
             'parameters': {
                 'any parameter': 'any value'
             }
         }, 'any dir', {'any tag': 'any value'})
Пример #8
0
    def test_apply_stack_name_suffix_does_not_modify_externally_referenced_stacks(self):
        stacks = {
            "stack-c": StackConfig({"template-url": "some-url", "parameters": {"a": 1, "b": "|ref|external_stack.a"}})
        }

        result = Config._apply_stack_name_suffix(stacks, "-test")

        self.assertEqual(result["stack-c-test"].parameters["a"], 1)
        self.assertEqual(result["stack-c-test"].parameters["b"], "|ref|external_stack.a")