Testing application that starts Camunda 8 cloud process

Hi,

I’m trying to write a functional test for an application that:

  1. listens to messages on AWS SQS
  2. picks them up
  3. takes the info from them and start a bpmn process on Camunda Cloud 8 with extracted info as input variable.

Our application is very similar to this example : blog-tutorials/spring-boot-aws-integration-tests at master · rieckpil/blog-tutorials (github.com)
The only difference is we start Camunda process instead of writing the data to S3 bucket.
Imagine that under processMessage method from here : blog-tutorials/SimpleMessageListener.java at master · rieckpil/blog-tutorials (github.com)

looks something like this :
@Value("${ProcessId}")
private String processId;
@Autowired
private ZeebeClient zeebeClient;

 @SqsListener(value = "${event-processing.order-event-queue}")

public void processMessage(@Payload OrderEvent orderEvent) throws JsonProcessingException {
ProcessInstanceEvent processInstanceEvent = zeebeClient.newCreateInstanceCommand()
.bpmnProcessId(processId)
.latestVersion()
.variables(Map.of(…))
.send()
.join();

My test is almost identical copy of the test on the above example repo as well.
For my test im trying to emulate both sqs and Camunda. I got the sqs emulation part working (thanks to the example) using Testcontainers with localstack and marking my test as SpringBootTest.
However, when i try to add ZeebeSpringTest annotation to the test as well it seems to break things.
I have a @BeforeAll method that creates the SQS queue on the container. It looks like it runs before the context was loaded and the main application started which is great as it needs to point to that emulated queue.
When ZeebeSpringTest annotation is added to my test, this method doesnt seem to run.
I tried checking what happens with a similar @BeforeAll method in another application which only has Camunda as external dependency, and it looks like it runs only after the main application was started by test rather than before.

Any chance someone had to emulate/mock both Camunda and another dependency ( preferably using testcontainers library) and have any advice?

thanks

Hi @olgap!

Recently some lifecycle changes have been made in spring-zeebe-test, which I believe will fix your problem. Would you mind updating spring-zeebe-starter and spring-zeebe-test to version 8.0.5?

I have ran the example test you have provided with this version and the log line you added is now logged before the startup of the application, both with and without the @ZeebeSpringTest annotation.

Hope this helps you,
Remco

1 Like