My team and I are trying to set up some integration tests of a distributed system that is highly dependant on the flow of time and events coming from external sources. Just to give you an idea about what we're working on:
when event A is received within 8:00 AM and 9:00 AM, and afterward, within 5 minutes, a second event B is received, then write a record into the DB with the timestamp at which event A has been received.
Now... writing an integration test against the real system seems complex.
How to set the date of the system under test ?
The system under test should ideally work with a time defined by the integration tests. Maybe the integration test should set the server time at "9:00" when the test starts ? Any other advice ?
How to send events at a known rate ?
Events should be sent with a reproducible and known rhythm, i.e. fire event A at 9:05 and event B at 9:06. Maybe a plain programmable scheduler can be used here ?
How to cope with tests requiring large timeouts ?
Some test scenarios requires that large amount of time pass between two events. Is it possible to artificially speed up the flow of time to compress one hour in just some second in the test ? I though about speeding up the clock of the system (not in the meaning of overclocking, just in the mean of having the seconds ticks faster). It seems to me that this cannot be done in an actual piece of hardware but maybe in a virtual machine this is possible. Any advice on this topic ?
Constraints
- Not all module being part of the integration tests are under our direct control.