Exemple #1
0
    def test_recovery(self):

        # put some values in the store directly
        yield self.store.add_sensor(SensorItem("s1", 100, "s1v1"))
        yield self.store.add_sensor(SensorItem("s2", 100, "s2v1"))
        yield self.store.add_sensor(SensorItem("s1", 200, "s1v2"))

        d1 = dict(instance_id="i1", launch_id="l1", allocation="big",
                  site="cleveland", state=InstanceStates.PENDING)
        yield self.store.add_instance(CoreInstance.from_dict(d1))
        d2 = dict(instance_id="i2", launch_id="l2", allocation="big",
                  site="cleveland", state=InstanceStates.PENDING)
        yield self.store.add_instance(CoreInstance.from_dict(d2))

        d2['state'] = InstanceStates.RUNNING
        yield self.store.add_instance(CoreInstance.from_dict(d2))

        # recovery should bring them into state
        yield self.state.recover()
        yield self.assertSensor("s1", 200, "s1v2")
        yield self.assertSensor("s2", 100, "s2v1")
        yield self.assertInstance("i1", launch_id="l1", allocation="big",
                  site="cleveland", state=InstanceStates.PENDING)
        yield self.assertInstance("i2", launch_id="l2", allocation="big",
                  site="cleveland", state=InstanceStates.RUNNING)
Exemple #2
0
 def new_kill(self, instanceid):
     state = InstanceStates.TERMINATING
     dct = dict(instance_id=instanceid, state=state, site="chicago",
                allocation="small", health=InstanceHealthState.UNKNOWN,
                launch_id="thelaunch")
     prev = self.instances.get(instanceid)
     if prev:
         item = CoreInstance.from_existing(prev, **dct)
     else:
         item = CoreInstance.from_dict(dct)
     self.instances[instanceid] = item
     self.instance_changes[instanceid].append(item)
Exemple #3
0
 def new_kill(self, instanceid):
     state = InstanceStates.TERMINATING
     dct = dict(instance_id=instanceid,
                state=state,
                site="chicago",
                allocation="small",
                health=InstanceHealthState.UNKNOWN,
                launch_id="thelaunch")
     prev = self.instances.get(instanceid)
     if prev:
         item = CoreInstance.from_existing(prev, **dct)
     else:
         item = CoreInstance.from_dict(dct)
     self.instances[instanceid] = item
     self.instance_changes[instanceid].append(item)