def test_periodic_task_parameters(self):
        _set_expiration_policy_config(17, 13)

        e_policy = expiration_policy.ExecutionExpirationPolicy(cfg.CONF)

        self.assertEqual(
            17 * 60,
            e_policy._periodic_spacing['run_execution_expiration_policy'])
    def test_negative_wrong_conf_values(self):
        _set_expiration_policy_config(None, None)
        e_policy = expiration_policy.ExecutionExpirationPolicy(cfg.CONF)

        self.assertDictEqual({}, e_policy._periodic_spacing)
        self.assertListEqual([], e_policy._periodic_tasks)

        _set_expiration_policy_config(None, 60)
        e_policy = expiration_policy.ExecutionExpirationPolicy(cfg.CONF)

        self.assertDictEqual({}, e_policy._periodic_spacing)
        self.assertListEqual([], e_policy._periodic_tasks)

        _set_expiration_policy_config(60, None)
        e_policy = expiration_policy.ExecutionExpirationPolicy(cfg.CONF)

        self.assertDictEqual({}, e_policy._periodic_spacing)
        self.assertListEqual([], e_policy._periodic_tasks)
Beispiel #3
0
        def _assert_scheduling(expiration_policy_config, should_schedule):
            ExecutionExpirationPolicy._periodic_tasks = []
            _set_expiration_policy_config(*expiration_policy_config)
            e_policy = expiration_policy.ExecutionExpirationPolicy(cfg.CONF)

            if should_schedule:
                self.assertTrue(e_policy._periodic_tasks,
                                "Periodic task should have been created.")
            else:
                self.assertFalse(e_policy._periodic_tasks,
                                 "Periodic task shouldn't have been created.")