Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zeebeTestEngine.increaseTime not working reliably for Spring Boot Tests #659

Open
tobiasschaefer opened this issue Feb 23, 2024 · 6 comments

Comments

@tobiasschaefer
Copy link
Contributor

Describe the bug

I have a process test whose process includes an timer intermediate catch event with a duration of 15 minutes. Obviously, I don’t want the test to wait but want be be able to trigger the timer (or rather increase the time of the environment so that it fires).

Here is a nice working example which works: TimerTest.java 1

However, this previous example uses @ZeebeProcessTest and in my case I have
@SpringBootTest @ZeebeSpringTest and it doesn’t work reliably.

To reproduce the issue I created a fork of the Camunda 8 Twitter Example: twitter-with-timer 2 in which I

  • added a timer with a duration in the process model
  • added the same skipTimer implementation.
  • disabled all tests but the first (to make it simpler)
  • I replaced @Test with @RepeatedTest(10) to make the error more obvious and reproducible.

However, this test

  • sometimes fails on the first zeebeTestEngine.waitForIdleState(DEFAULT)
  • sometimes on the last zeebeTestEngine.waitForIdleState(DEFAULT)
  • sometimes it succeeds.

See also discussion in the forum thread #50258

Expected behavior

Test should pass every time.

Log/Stacktrace

image

Repetition 1: failed on “zeebeTestEngine.waitForIdleState(DEFAULT);” (first line in method skipTimeout) with a timeout

Repetition 2: failed a few lines later on
“zeebeTestEngine.waitForIdleState(DEFAULT);” (last (!) line in method skipTimeout) with a timeout

Repetition 4 failed with “Mockito.verify(twitterService).tweet(“Hello world”);”

On the second invocation all 10 were successful:

image

On further invocations I get random results similar to the first and second invocation.

Note that the duration is quite different. I don’t know much about Zeebe internals but is there some configuration which can be set to make the timers being checked more often?

Environment:

  • OS: Windows
  • Deployment: none - its a local test with @ZeebeSpringTest, i.e. it uses the embedded process engine
  • Spring-Zeebe Version: 8.3.1
  • SpringBoot Version: 3.1.5
  • Configuration: n.A.
@rshamborovskyy
Copy link

Same problem here. @ZeebeSpringTest with timer event and increaseTime passes randomly.
Would really like to have this one sorted out. Meanwhile I need to think about some workaround.

@tobiasschaefer
Copy link
Contributor Author

Hi @jonathanlukas ,

this issue still affects us and Roman has the same issue. Since you were involved in the forum discussion before I created this issue and know who could support internally at Camunda:

Could you please get someone involved in this ticket so it gets fixed?

Best,
Tobias

@jonathanlukas
Copy link
Contributor

@tobiasschaefer I investigated the problem today and had some findings. I am currently checking with the zeebe team.

@jonathanlukas
Copy link
Contributor

jonathanlukas commented May 21, 2024

@tobiasschaefer I just prepared a fixed version of the timer testing with additional working spring zeebe tests:

camunda-community-hub/camunda-8-examples#376

@tobiasschaefer
Copy link
Contributor Author

Hi @jonathanlukas ,

thanks a lot! 💯

It's now working for me too 👍

@jonathanlukas
Copy link
Contributor

Awesome! Now I just need to add something to the testing docs so that other people will not face the same issue. Do you have a proposal for that?

In detail, the problem is that waitForBusyState is also triggered by job activation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants