-
Notifications
You must be signed in to change notification settings - Fork 54
Description
The reconciler tests in samples show that the injected operator could be started at the beginning of the test method [1].
When there are multiple test methods of a reconciler, such an approach fails in the second test method, as the operator was already started in the first one.
A possible solution would be to start and stop the operator in @BeforeEach and @AfterEach methods [2]. However, restarting the operator fails due to:
java.lang.IllegalStateException: Cannot restart a stopped informer
Workaround:
The workaround just starts the operator once, without trying to stop it. As constructor injection does not seem to work (the operator instance is null), I found the following, rather cumbersome way of making it work:
@Inject
private Operator operator;
public void onStart(@Observes StartupEvent startupEvent) {
operator.start();
}
Proposal:
Make the operator restartable to enable the @BeforeEach / @AfterEach approach, which is more natural for a test setup.
[1] https://github.com/quarkiverse/quarkus-operator-sdk/blob/main/samples/exposedapp/src/test/java/io/halkyon/ExposedAppReconcilerTest.java#L32
[2] #387