I’m experimenting writing integration tests and am trying to come up with the best way to “reset” the state (command query side of the DB) between tests.
The steps I’m following:
- Shutting down all tracking event processors.
- Resetting the DB (resetting the schema to the initial start state i.e. clearing all events and projections).
- Restarting the tracking event processors.
Unfortunately on step 3 my code fails:
private void restartTrackingEventProcessors(EventProcessingConfiguration eventProcessingConfiguration) {
Map<String, EventProcessor> eventProcessors = eventProcessingConfiguration.eventProcessors();
eventProcessors.forEach((processorName, processor) -> {
// If it is tracking event processor then reset the token and start it up.
Optional<TrackingEventProcessor> trackingEventProcessor = eventProcessingConfiguration.eventProcessor(processorName, TrackingEventProcessor.class);
if(trackingEventProcessor.isPresent()) {
var tep = trackingEventProcessor.get();
log.info("Restarting: {} {}", processorName, processor);
tep.resetTokens(); // Will throw if the TEP has not already been shutdown.
tep.start();
log.info("Restarted tracking event processor: {}", processorName);
}
});
}
The reason is because it hits a Saga tracking event processor (the others work fine) and we get the error:
java.lang.IllegalStateException: The handlers assigned to this Processor do not support a reset
What is the best way to reset the saga TEP so that the state of the system is “fresh” for the next test?