Esempio n. 1
0
    def test_update_group_config(self):
        """
        Updating the groupConfiguration section in a template results in a
        pyrax call to update the group configuration.
        """
        self._setup_test_stack()

        resource = self.stack["my_group"]
        new_template = copy.deepcopy(resource.parsed_template())
        new_template["Properties"]["groupConfiguration"]["minEntities"] = 5
        scheduler.TaskRunner(resource.update, new_template)()

        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual(5, self.fake_auto_scale.groups["0"].kwargs["min_entities"])
Esempio n. 2
0
    def test_update(self):
        self._setup_test_stack(self.webhook_template)
        resource = self.stack['my_webhook']
        template = copy.deepcopy(resource.parsed_template())
        template['Properties']['metadata']['a'] = 'different!'
        template['Properties']['name'] = 'newhook'

        scheduler.TaskRunner(resource.update, template)()
        self.assertEqual(
            {
                'name': 'newhook',
                'scaling_group': 'my-group-id',
                'policy': 'my-policy-id',
                'metadata': {'a': 'different!'}},
            self.fake_auto_scale.webhooks['0'].kwargs)
Esempio n. 3
0
    def test_update_group_config(self):
        """
        Updating the groupConfiguration section in a template results in a
        pyrax call to update the group configuration.
        """
        self._setup_test_stack()

        resource = self.stack['my_group']
        new_template = copy.deepcopy(resource.parsed_template())
        new_template['Properties']['groupConfiguration']['minEntities'] = 5
        scheduler.TaskRunner(resource.update, new_template)()

        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual(
            5, self.fake_auto_scale.groups['0'].kwargs['min_entities'])
Esempio n. 4
0
    def test_update_group_config(self):
        """
        Updating the groupConfiguration section in a template results in a
        pyrax call to update the group configuration.
        """
        self._setup_test_stack()

        resource = self.stack['my_group']
        new_template = copy.deepcopy(resource.parsed_template())
        new_template['Properties']['groupConfiguration']['minEntities'] = 5
        scheduler.TaskRunner(resource.update, new_template)()

        self.assertEqual(len(self.fake_auto_scale.groups), 1)
        self.assertEqual(
            self.fake_auto_scale.groups['0'].kwargs['min_entities'], 5)
Esempio n. 5
0
    def test_update(self):
        self._setup_test_stack(self.webhook_template)
        resource = self.stack['my_webhook']
        template = copy.deepcopy(resource.parsed_template())
        template['Properties']['metadata']['a'] = 'different!'
        template['Properties']['name'] = 'newhook'

        scheduler.TaskRunner(resource.update, template)()
        self.assertEqual(
            {
                'name': 'newhook',
                'scaling_group': 'my-group-id',
                'policy': 'my-policy-id',
                'metadata': {'a': 'different!'}},
            self.fake_auto_scale.webhooks['0'].kwargs)
Esempio n. 6
0
    def test_update_launch_config(self):
        """
        Updating the launchConfigresults section in a template results in a
        pyrax call to update the launch configuration.
        """
        self._setup_test_stack()

        resource = self.stack["my_group"]
        new_template = copy.deepcopy(resource.parsed_template())
        lcargs = new_template["Properties"]["launchConfiguration"]["args"]
        lcargs["loadBalancers"] = [{"loadBalancerId": "1", "port": 80}]
        scheduler.TaskRunner(resource.update, new_template)()

        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual([{"loadBalancerId": 1, "port": 80}], self.fake_auto_scale.groups["0"].kwargs["load_balancers"])
Esempio n. 7
0
    def test_update_launch_config(self):
        """
        Updating the launchConfigresults section in a template results in a
        pyrax call to update the launch configuration.
        """
        self._setup_test_stack()

        resource = self.stack['my_group']
        new_template = copy.deepcopy(resource.parsed_template())
        lcargs = new_template['Properties']['launchConfiguration']['args']
        lcargs['loadBalancers'] = [{'loadBalancerId': '1', 'port': 80}]
        scheduler.TaskRunner(resource.update, new_template)()

        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual(
            [{'loadBalancerId': 1, 'port': 80}],
            self.fake_auto_scale.groups['0'].kwargs['load_balancers'])
Esempio n. 8
0
    def test_update_launch_config(self):
        """
        Updating the launchConfigresults section in a template results in a
        pyrax call to update the launch configuration.
        """
        self._setup_test_stack()

        resource = self.stack['my_group']
        new_template = copy.deepcopy(resource.parsed_template())
        lcargs = new_template['Properties']['launchConfiguration']['args']
        lcargs['loadBalancers'] = [{'loadBalancerId': '1', 'port': 80}]
        scheduler.TaskRunner(resource.update, new_template)()

        self.assertEqual(1, len(self.fake_auto_scale.groups))
        self.assertEqual(
            [{'loadBalancerId': 1, 'port': 80}],
            self.fake_auto_scale.groups['0'].kwargs['load_balancers'])
Esempio n. 9
0
    def test_update(self):
        self._setup_test_stack(self.webhook_template)
        resource = self.stack["my_webhook"]
        template = copy.deepcopy(resource.parsed_template())
        template["Properties"]["metadata"]["a"] = "different!"
        template["Properties"]["name"] = "newhook"

        scheduler.TaskRunner(resource.update, template)()
        self.assertEqual(
            {
                "name": "newhook",
                "scaling_group": "my-group-id",
                "policy": "my-policy-id",
                "metadata": {"a": "different!"},
            },
            self.fake_auto_scale.webhooks["0"].kwargs,
        )
Esempio n. 10
0
    def test_update(self):
        """
        Updating the resource calls the appropriate update method with pyrax.
        """
        self._setup_test_stack(self.policy_template)
        resource = self.stack['my_policy']
        template = copy.deepcopy(resource.parsed_template())
        template['Properties']['changePercent'] = 50
        del template['Properties']['change']

        scheduler.TaskRunner(resource.update, template)()
        self.assertEqual(
            {
                'name': '+10 on webhook',
                'scaling_group': 'my-group-id',
                'change': 50,
                'is_percent': True,
                'cooldown': 0,
                'policy_type': 'webhook'},
            self.fake_auto_scale.policies['0'].kwargs)
Esempio n. 11
0
    def test_update(self):
        """
        Updating the resource calls the appropriate update method with pyrax.
        """
        self._setup_test_stack(self.policy_template)
        resource = self.stack['my_policy']
        template = copy.deepcopy(resource.parsed_template())
        template['Properties']['changePercent'] = 50
        del template['Properties']['change']

        scheduler.TaskRunner(resource.update, template)()
        self.assertEqual(
            {
                'name': '+10 on webhook',
                'scaling_group': 'my-group-id',
                'change': 50,
                'is_percent': True,
                'cooldown': 0,
                'policy_type': 'webhook'
            }, self.fake_auto_scale.policies['0'].kwargs)
Esempio n. 12
0
    def test_update(self):
        """
        Updating the resource calls the appropriate update method with pyrax.
        """
        self._setup_test_stack(self.policy_template)
        resource = self.stack["my_policy"]
        template = copy.deepcopy(resource.parsed_template())
        template["Properties"]["changePercent"] = 50
        del template["Properties"]["change"]

        scheduler.TaskRunner(resource.update, template)()
        self.assertEqual(
            {
                "name": "+10 on webhook",
                "scaling_group": "my-group-id",
                "change": 50,
                "is_percent": True,
                "cooldown": 0,
                "policy_type": "webhook",
            },
            self.fake_auto_scale.policies["0"].kwargs,
        )