Exemple #1
0
    def test_set_autoscale_parameters_with_bootstrap_context_and_parameters(self):  # NOQA

        # Cloudify agent configuration parameters should be populated.
        cloudify_agent = {
            MAX_WORKERS_KEY: 10,
            MIN_WORKERS_KEY: 5
        }
        set_autoscale_parameters({}, cloudify_agent)
        self.assertEqual(cloudify_agent[MAX_WORKERS_KEY], 10)
        self.assertEqual(cloudify_agent[MIN_WORKERS_KEY], 5)
Exemple #2
0
    def test_set_autoscale_parameters_validate_max_bigger_than_min(self):  # NOQA

        # Cloudify agent configuration parameters should be populated.
        cloudify_agent = {
            MAX_WORKERS_KEY: 10,
            MIN_WORKERS_KEY: 20
        }
        try:
            set_autoscale_parameters({}, cloudify_agent)
            self.fail('Expected NonRecoverableError since {0} is bigger than'
                      .format(MIN_WORKERS_KEY, MAX_WORKERS_KEY))
        except NonRecoverableError:
            pass
    def test_set_autoscale_parameters_validate_max_bigger_than_min(self):  # NOQA

        from windows_agent_installer import set_autoscale_parameters

        cloudify_agent = {
            constants.MAX_WORKERS_KEY: 10,
            constants.MIN_WORKERS_KEY: 20
        }
        try:
            set_autoscale_parameters({}, cloudify_agent)
            self.fail('Expected NonRecoverableError since {0} is bigger than'
                      .format(constants.MIN_WORKERS_KEY,
                              constants.MAX_WORKERS_KEY))
        except NonRecoverableError:
            pass
    def test_set_autoscale_parameters_with_bootstrap_context_zero_min(self):  # NOQA

        from windows_agent_installer import set_autoscale_parameters

        cloudify_agent = {}
        bootstrap_context = BootstrapContext({'cloudify_agent': {
            constants.MAX_WORKERS_KEY: 10,
            constants.MIN_WORKERS_KEY: 0
        }})
        ctx = MockCloudifyContext(bootstrap_context=bootstrap_context)
        set_autoscale_parameters(
            ctx.bootstrap_context,
            cloudify_agent)
        self.assertEqual(cloudify_agent[constants.MAX_WORKERS_KEY], 10)
        self.assertEqual(cloudify_agent[constants.MIN_WORKERS_KEY], 0)
Exemple #5
0
    def test_set_autoscale_parameters_with_bootstrap_context_and_no_parameters(self):  # NOQA

        # Bootstrap context values should be populated.

        cloudify_agent = {}
        bootstrap_context = BootstrapContext({'cloudify_agent': {
            MAX_WORKERS_KEY: 10,
            MIN_WORKERS_KEY: 5
        }})
        ctx = MockCloudifyContext(bootstrap_context=bootstrap_context)
        set_autoscale_parameters(
            ctx.bootstrap_context,
            cloudify_agent)
        self.assertEqual(cloudify_agent[MAX_WORKERS_KEY], 10)
        self.assertEqual(cloudify_agent[MIN_WORKERS_KEY], 5)
    def test_set_autoscale_parameters_with_bootstrap_context_cloudify_agent(self):  # NOQA

        from windows_agent_installer import set_autoscale_parameters

        # cloudify agent does contain auto scale configuration parameters.
        # bootstrap_context does contain auto scale configuration parameters.
        # this means all parameters should be
        # the ones specified by the cloudify_agent.
        cloudify_agent = {
            constants.MAX_WORKERS_KEY: 10,
            constants.MIN_WORKERS_KEY: 5
        }
        bootstrap_context = BootstrapContext({'cloudify_agent': {
            constants.MAX_WORKERS_KEY: 2,
            constants.MIN_WORKERS_KEY: 3
        }})
        set_autoscale_parameters(bootstrap_context, cloudify_agent)
        self.assertEqual(cloudify_agent[constants.MAX_WORKERS_KEY], 10)
        self.assertEqual(cloudify_agent[constants.MIN_WORKERS_KEY], 5)
    def test_set_autoscale_parameters_with_bootstrap_context_and_empty_cloudify_agent(self):  # NOQA

        from windows_agent_installer import set_autoscale_parameters

        # cloudify agent does not contain any
        # auto scale configuration parameters.
        # bootstrap_context does contain auto
        # scale configuration parameters.
        # this means all parameters should be the ones
        # specified by the bootstrap_context.
        cloudify_agent = {}
        bootstrap_context = BootstrapContext({'cloudify_agent': {
            constants.MAX_WORKERS_KEY: 10,
            constants.MIN_WORKERS_KEY: 5
        }})
        ctx = MockCloudifyContext(bootstrap_context=bootstrap_context)
        set_autoscale_parameters(
            ctx.bootstrap_context,
            cloudify_agent)
        self.assertEqual(cloudify_agent[constants.MAX_WORKERS_KEY], 10)
        self.assertEqual(cloudify_agent[constants.MIN_WORKERS_KEY], 5)