I'm working on a new project using flink stateful functions. I've written some basic unit tests using FunctionTestHarness, but a test using this method can't test interaction between stateful functions.
The flink testing documentation (base flink, not for stateful functions) demonstrates how to run a complete job using MiniClusterWithClientResource
and then make assertions on the output of the job. I'm searching for a way to do something similar with stateful functions.
The statefun-flink-harness-example looked very promising, but the RunnerTest
using Harness is marked with @Ignore
since it will never terminate. This is useful for debugging, but can't be used in an automated test.
Here are the problem I've identified so far which make it difficult to write a test which terminates with Harness:
- Harness uses SerializableSupplier to provide input, and there's no way for the SerializableSupplier to say that it's done. This means any test using Harness is always waiting for more input.
- If Harness was aware that all input had been sent, it would need a way to terminate once there were no pending events.
- As an additional complication, some systems would still never terminate due to delayed events sent by Context
.sendAfter()
I'd think this would be a common need to enable more interesting automated tests which can be run from CI/CD processes. Has anyone found a way to solve the above, or perhaps discovered an entirely different method using tools other than Harness?