Example #1
0
 def update_snapshot(self, events):
     snapshot_mutate_event = PartialSnapshot(self._snapshot)
     for event in events:
         snapshot_mutate_event.from_cloudevent(event)
     self._snapshot.merge_event(snapshot_mutate_event)
     if self._status != self._snapshot.get_status():
         self._status = self._status_tracker.update_state(
             self._snapshot.get_status())
     return snapshot_mutate_event
Example #2
0
def test_multiple_cloud_events_trigger_non_communicated_change():
    """In other words, though we say all steps are finished, we don't
    explicitly send an event that changes the realization status. It should
    happen by virtue of the steps being completed."""
    snapshot = (SnapshotBuilder().add_step(
        step_id="0", status="Unknown").build(["0"], status="Unknown"))
    partial = PartialSnapshot(snapshot)
    partial.from_cloudevent(
        CloudEvent({
            "id": "0",
            "type": ids.EVTYPE_FM_STEP_SUCCESS,
            "source": "/real/0/step/0",
        }))
    assert partial.to_dict(
    )["reals"]["0"]["status"] == state.REALIZATION_STATE_FINISHED
Example #3
0
def test_update_partial_from_multiple_cloudevents(snapshot):
    partial = PartialSnapshot(snapshot)
    partial.from_cloudevent(
        CloudEvent({
            "id": "0",
            "type": ids.EVTYPE_FM_JOB_RUNNING,
            "source": "/real/0/step/0/job/0",
        }))
    partial.from_cloudevent(
        CloudEvent(
            {
                "id": "0",
                "type": ids.EVTYPE_FM_JOB_FAILURE,
                "source": "/real/0/step/0/job/0",
            },
            {ids.ERROR_MSG: "failed"},
        ))
    partial.from_cloudevent(
        CloudEvent({
            "id": "1",
            "type": ids.EVTYPE_FM_JOB_SUCCESS,
            "source": "/real/0/step/0/job/1",
        }))
    jobs = partial.to_dict()["reals"]["0"]["steps"]["0"]["jobs"]
    jobs["0"]["status"] == state.JOB_STATE_FAILURE
    jobs["1"]["status"] == state.JOB_STATE_FINISHED
Example #4
0
 async def _ensemble_cancelled_handler(self, event):
     snapshot_mutate_event = PartialSnapshot.from_cloudevent(event)
     await self._send_snapshot_update(snapshot_mutate_event)
     self._stop()
Example #5
0
 async def _fm_handler(self, event):
     snapshot_mutate_event = PartialSnapshot.from_cloudevent(event)
     await self._send_snapshot_update(snapshot_mutate_event)