Search code examples
apache-flinkflink-statefun

How can I programmatically terminate the Statefun Harness


I'm attempting to create a cucumber testing environment for my flink stateful function application using the testing harness. I've built out the necessary wiring and step definitions to mock ingress and egress points and am now able to run nice scripted end-to-end integration tests. The only problem is in gracefully tearing down the harness at the end of the testing scenario.

If you let the cucumber script run to the end, the harness will be torn down as a part of the cleanup but this causes surefire to report the error "The forked VM terminated without saying properly goodbye. VM crash or System.exit called?"

I did notice another posting which suggested the use of an ingress which took a predefined list of inputs. That would, however, take away the ability to really test more nuanced scenarios involving message delays and multiple ingresses.

Any suggestions folks?


Solution

  • In similar situations I've used a custom ingress (source function) that checks a static AtomicBoolean, and exits when that's set. So in my main test code when I want to finish up, I set that true, then (cheesy, fragile) wait a bit or (better) monitor the MiniCluster status until the job completes.