Skip to content

Commit

Permalink
fix(quarkus-extesion/engine): Turn off JobExecutor
Browse files Browse the repository at this point in the history
Problem Description:

- ManagedJobExecutorTest#shouldExecuteJob was failing sporadically on CI due to the asynchronous execution of scheduled jobs.
  The synchronous execution of the test would query for the existence of the job. Sometimes, the job would be already completed
  by the time the Query API would make assertions on its existence and that would lead into failures.

Solution:

- Turn off the job scheduler before filing any job executions

Related-to: #3940
  • Loading branch information
psavidis committed Dec 6, 2023
1 parent a1e71d6 commit fec7c89
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
*/
package org.camunda.bpm.quarkus.engine.test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.camunda.bpm.engine.impl.test.TestHelper.waitForJobExecutorToProcessAllJobs;

import io.quarkus.test.QuarkusUnitTest;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import org.camunda.bpm.engine.ManagementService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
import org.camunda.bpm.engine.impl.test.TestHelper;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.quarkus.engine.extension.QuarkusProcessEngineConfiguration;
Expand All @@ -35,12 +40,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;

import static org.assertj.core.api.Assertions.assertThat;

public class ManagedJobExecutorTest {

@RegisterExtension
Expand Down Expand Up @@ -129,6 +128,7 @@ public void shouldNotReuseManagedExecutor() {
@Deployment
public void shouldExecuteJob() {
// given
processEngineConfiguration.getJobExecutor().shutdown();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("asyncTaskProcess");

// when
Expand All @@ -137,14 +137,16 @@ public void shouldExecuteJob() {
.processInstanceId(processInstance.getId())
.count();

TestHelper.waitForJobExecutorToProcessAllJobs(processEngineConfiguration, 5000l, 25l);

// then
assertThat(jobCount).isOne();

waitForJobExecutorToProcessAllJobs(processEngineConfiguration, 5000L, 25L);

jobCount = managementService
.createJobQuery()
.processInstanceId(processInstance.getId())
.count();

assertThat(jobCount).isZero();
}

Expand Down

0 comments on commit fec7c89

Please sign in to comment.