Part of our testing involves executing the workflow and then retrieving the history through the API to validate that the process went through the expected tasks. One part of our test also involves querying our database (not the Camunda database) to see if the service task inserted the correct data into our table.
One thing we’re having a hard time with is one task at the beginning will insert to a database table, let’s say it will insert to a column with the value “IN PROGRESS” and then at the end of the workflow this will be updated to “FINISHED”. Our issue is that once we start the process, we’ll then query the database if the expected value is there but we might run into I guess you could say race condition? where the process has already finished and we retrieve the value “FINISHED” instead of “IN PROGRESS”.
If possible I want to trigger just one single service task so we can just test its behavior alone without it going through the whole process. Also for delay’s I’m hoping for something that’s not a timer or thread sleep? is it possible for us to lock a service task from executing any jobs using the API?
Do I understand it correctly that your question is purely related to testing the solution build?
If that is the case I would recommend giving this best-practice a read:
To answer your question:
It is not possible to execute only one activity of a bigger BPMN. You would need to modify it in such a way that you add a delay. (e.g. via a timer intermediate event or via a delay in the completion of your service task) To do such a thing for testing seems a bit odd to me…
Maybe proper logging could be a solution to the problem described?
Hopefully you can work with this information - My recommendation would be to use a different testing technique.
Hi @Hafflgav thanks for the reply.
The testing is actually an automated test outside our Java application and is a separate test from the unit testing done in the application. We’re basically starting a workflow process using the Camunda API and validating our expected behavior using the history API. If everything is as expected then that means our external task handlers are correct.
Hello my dear!
Maybe I didn’t understand your question very well, but you could create a process variable as a “control variable”, something like this:
Creates a control variable called databaseStatus.
When checking in your database that it is IN PROGRESS, update the control variable passing execution.setVariable(“databaseStatus”, “IN PROGRESS”); This can be done in an END execution listner of your service task in Camunda.
At the end of your process you can have an Event Based Gateway connected to a conditional event, which will wait until the databaseStatus variable has the value “FINISHED” to be able to continue and execute your last task.
Sorry if I didn’t understand your question correctly.
William Robert Alves
Thanks for the suggestion @WilliamR.Alves , but our goal is to actually query the database to see if the table column contains the text “IN PROGRESS”, which would be an issue for us if the other external tasks completed before we can check for the value.
Hello my friend!
Check if the model I made below wouldn’t meet your need?
I put some explanations in the model.
William Robert Alves