Пример #1
0
    def test_uniques_empty_values_2(self):
        control = MockControl()
        state = control.get_state()

        de = NeedyEngine()
        de.initialize(control, state, self._get_config(1, "dt1",
            unique_key="somekey", unique_values=" "))

        de.decide(control, state)
        self.assertEqual(control._launch_calls, 1)
        self.assertEqual(control.instances[0].extravars, None)
Пример #2
0
    def test_basic(self):
        control = MockControl()
        state = control.get_state()

        de = NeedyEngine()
        de.initialize(control, state, self._get_config(1, "dt1"))

        de.decide(control, state)
        self.assertEqual(control._launch_calls, 1)
        state = control.get_state()

        de.reconfigure(control, dict(preserve_n=2))

        de.decide(control, state)
        self.assertEqual(control._launch_calls, 2)
Пример #3
0
    def test_ran_out_of_uniques(self):
        control = MockControl()
        state = control.get_state()

        de = NeedyEngine()
        de.initialize(control, state, self._get_config(2, "dt1",
            unique_key="somekey", unique_values=[1, ]))

        de.decide(control, state)
        self.assertEqual(control._launch_calls, 1)
        self.assertEqual(control.instances[0].extravars, {"somekey": 1})

        # kill first. replacement should get same unique
        control.instances[0].state = InstanceState.FAILED

        state = control.get_state()
        de.decide(control, state)
        self.assertEqual(control._launch_calls, 2)
        self.assertEqual(control.instances[1].extravars, {"somekey": 1})