Skip to content

Commit 49a5d1f

Browse files
committed
Stabilise tests
* Upload test artifacts on failure for all DBs * Upgrade test containers to 1.21.3 * Disable MultipleExternalWorkerAcquireServiceTaskTest#testAcquireJobsInTheSameTimeWithNoRetries since it seems like on Oracle both of the threads are acquiring jobs properly * Set fix time in IntermediateTimerEventTest#testCatchingTimerEvent before running the test * Use plus 1 second instead of millisecond in CmmnTimerTaskTest * Use different channel keys for each test in KafkaChannelDefinitionProcessorTest * Add toString on the AcquiredExternalWorkerJobImpl * Use awaitility for Camel MultiInstanceTest * Make sure that times in CMMN TaskCollectionResourceTest have seconds otherwise tests are failing due to an invalid assertion * Stabilise tests by checking for the async and timer jobs in one transaction It happens that if there is a timer the first check is done in one transaction and returns nothing. However, in the meantime the timer was moved to async, which would mean that the timers count would return empty as well and thus stop the execution. However, not everything has been executed. * Adjust the Process Engine MultiInstanceTest to only run the async jobs, since we are testing the creation of a timer job when something fails * Remove SpringEventRegistryChangeDetectorTest since we already have EventRegistryAutoConfigurationTest for testing the same thing * Disable change detection in the tests since we have multiple application contexts that could be running in the test suite and they could be causing problems between each other
1 parent c724c02 commit 49a5d1f

23 files changed

Lines changed: 102 additions & 101 deletions

File tree

.github/workflows/db2.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
distribution: 'zulu'
4545
java-version: 17
4646
- name: Test
47+
id: test
4748
# use db2 for the host here because we have specified a container for the job.
4849
# If we were running the job on the VM this would be localhost
4950
# '>-' is a special YAML syntax and means that new lines would be replaced with spaces
@@ -61,3 +62,9 @@ jobs:
6162
-Dspring.datasource.username=db2inst1
6263
-Dspring.datasource.password=flowable
6364
-Dmaven.test.redirectTestOutputToFile=false
65+
- name: Upload test artifacts
66+
uses: actions/upload-artifact@v4
67+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
68+
with:
69+
name: surefire-test-reports-db2-${{ matrix.db2 }}
70+
path: '**/target/surefire-reports/*'

.github/workflows/mariadb.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
distribution: 'zulu'
4343
java-version: 17
4444
- name: Test
45+
id: test
4546
# use localhost for the host here because we have specified a vm for the job.
4647
# '>-' is a special YAML syntax and means that new lines would be replaced with spaces
4748
# and new lines from the end would be removed
@@ -58,3 +59,9 @@ jobs:
5859
-Dspring.datasource.username=flowable
5960
-Dspring.datasource.password=flowable
6061
-Dmaven.test.redirectTestOutputToFile=false
62+
- name: Upload test artifacts
63+
uses: actions/upload-artifact@v4
64+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
65+
with:
66+
name: surefire-test-reports-mariadb-${{ matrix.mariadb }}
67+
path: '**/target/surefire-reports/*'

.github/workflows/mysql.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
distribution: 'zulu'
4343
java-version: 17
4444
- name: Test
45+
id: test
4546
# use localhost for the host here because we have specified a vm for the job.
4647
# '>-' is a special YAML syntax and means that new lines would be replaced with spaces
4748
# and new lines from the end would be removed
@@ -58,3 +59,9 @@ jobs:
5859
-Dspring.datasource.username=flowable
5960
-Dspring.datasource.password=flowable
6061
-Dmaven.test.redirectTestOutputToFile=false
62+
- name: Upload test artifacts
63+
uses: actions/upload-artifact@v4
64+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
65+
with:
66+
name: surefire-test-reports-mysql-${{ matrix.mysql }}
67+
path: '**/target/surefire-reports/*'

.github/workflows/oracle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ jobs:
8181
uses: actions/upload-artifact@v4
8282
if: ${{ failure() && steps.test.conclusion == 'failure' }}
8383
with:
84-
name: surefire-test-reports-${{ matrix.oracle }}
84+
name: surefire-test-reports-oracle-${{ matrix.oracle }}
8585
path: '**/target/surefire-reports/*'

.github/workflows/postgres.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
distribution: 'zulu'
3838
java-version: 17
3939
- name: Test
40+
id: test
4041
# use postgres for the host here because we have specified a container for the job.
4142
# If we were running the job on the VM this would be localhost
4243
# '>-' is a special YAML syntax and means that new lines would be replaced with spaces
@@ -54,3 +55,9 @@ jobs:
5455
-Dspring.datasource.username=flowable
5556
-Dspring.datasource.password=flowable
5657
-Dmaven.test.redirectTestOutputToFile=false
58+
- name: Upload test artifacts
59+
uses: actions/upload-artifact@v4
60+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
61+
with:
62+
name: surefire-test-reports-postgres-${{ matrix.postgres }}
63+
path: '**/target/surefire-reports/*'

modules/flowable-camel/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@
115115
<artifactId>nashorn-core</artifactId>
116116
<scope>test</scope>
117117
</dependency>
118+
<dependency>
119+
<groupId>org.awaitility</groupId>
120+
<artifactId>awaitility</artifactId>
121+
<scope>test</scope>
122+
</dependency>
118123

119124
</dependencies>
120125

modules/flowable-camel/src/test/java/org/flowable/camel/examples/multiinstance/MultiInstanceTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
package org.flowable.camel.examples.multiinstance;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;
17+
import static org.awaitility.Awaitility.await;
1718

19+
import java.time.Duration;
1820
import java.util.List;
1921

2022
import org.apache.camel.CamelContext;
@@ -53,7 +55,7 @@ public void configure() throws Exception {
5355

5456
@Test
5557
@Deployment(resources = { "process/multiinstanceReceive.bpmn20.xml" })
56-
public void testRunProcess() throws Exception {
58+
public void testRunProcess() {
5759
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miProcessExample");
5860
List<Job> jobList = managementService.createJobQuery().list();
5961
assertThat(jobList).hasSize(5);
@@ -64,13 +66,9 @@ public void testRunProcess() throws Exception {
6466
.count()).isEqualTo(5);
6567

6668
waitForJobExecutorToProcessAllJobs(3000, 500);
67-
int counter = 0;
68-
long processInstanceCount = 1;
69-
while (processInstanceCount == 1 && counter < 20) {
70-
Thread.sleep(500);
71-
processInstanceCount = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count();
72-
counter++;
73-
}
74-
assertThat(runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count()).isZero();
69+
await("Receive from Camel")
70+
.atMost(Duration.ofSeconds(30))
71+
.pollInterval(Duration.ofMillis(500))
72+
.untilAsserted(() -> assertThat(runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).list()).isEmpty());
7573
}
7674
}

modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/AbstractProcessEngineIntegrationTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

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

17-
import java.util.Date;
1817
import java.util.HashMap;
1918
import java.util.List;
2019
import java.util.Map;
@@ -107,12 +106,6 @@ public void cleanup() {
107106
}
108107
}
109108

110-
protected Date setCmmnClockFixedToCurrentTime() {
111-
Date date = new Date();
112-
cmmnEngineConfiguration.getClock().setCurrentTime(date);
113-
return date;
114-
}
115-
116109
protected void assertCaseInstanceEnded(CaseInstance caseInstance) {
117110
long count = cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).count();
118111
assertThat(count).as(createCaseInstanceEndedErrorMessage(caseInstance, count)).isZero();

modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/CmmnTimerTaskTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import static org.assertj.core.api.Assertions.assertThat;
1616
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1717

18+
import java.time.Instant;
19+
import java.time.temporal.ChronoUnit;
1820
import java.util.Date;
1921
import java.util.List;
2022

@@ -40,7 +42,8 @@ public class CmmnTimerTaskTest extends AbstractProcessEngineIntegrationTest {
4042
@Test
4143
@CmmnDeployment(resources = "org/flowable/cmmn/test/timerInStage.cmmn")
4244
public void testCmmnTimerTask() {
43-
Date startTime = setCmmnClockFixedToCurrentTime();
45+
Instant startTime = Instant.now();
46+
cmmnEngineConfiguration.getClock().setCurrentTime(Date.from(startTime));
4447
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("testTimerInStage").start();
4548

4649
assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).planItemInstanceState(PlanItemInstanceState.ACTIVE)
@@ -61,7 +64,7 @@ public void testCmmnTimerTask() {
6164
timerJobs = processEngineManagementService.createTimerJobQuery().scopeId(caseInstance.getId()).scopeType(ScopeTypes.CMMN).executable().list();
6265
assertThat(timerJobs).isEmpty();
6366

64-
processEngine.getProcessEngineConfiguration().getClock().setCurrentTime(new Date(startTime.getTime() + (3 * 60 * 60 * 1000 + 1)));
67+
processEngine.getProcessEngineConfiguration().getClock().setCurrentTime(Date.from(startTime.plus(3, ChronoUnit.HOURS).plusSeconds(1)));
6568

6669
timerJobs = processEngineManagementService.createTimerJobQuery().scopeId(caseInstance.getId()).scopeType(ScopeTypes.CMMN).executable().list();
6770
assertThat(timerJobs).hasSize(1);
@@ -73,7 +76,7 @@ public void testCmmnTimerTask() {
7376
.hasMessage("time limit of 7000 was exceeded");
7477

7578
// Timer fires after 3 hours, so setting it to 3 hours + 1 second
76-
cmmnEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + (3 * 60 * 60 * 1000 + 1)));
79+
cmmnEngineConfiguration.getClock().setCurrentTime(Date.from(startTime.plus(3, ChronoUnit.HOURS).plusSeconds(1)));
7780

7881
timerJobs = cmmnManagementService.createTimerJobQuery().caseInstanceId(caseInstance.getId()).executable().list();
7982
assertThat(timerJobs)

modules/flowable-cmmn-rest/src/test/java/org/flowable/cmmn/rest/service/api/runtime/TaskCollectionResourceTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,17 @@ public void testGetTasks() throws Exception {
135135
org.flowable.cmmn.api.repository.CmmnDeployment deployment = null;
136136
try {
137137
Calendar adhocTaskCreate = Calendar.getInstance();
138+
adhocTaskCreate.set(Calendar.SECOND, 14);
138139
adhocTaskCreate.set(Calendar.MILLISECOND, 0);
139140

140141
Calendar processTaskCreate = Calendar.getInstance();
141142
processTaskCreate.add(Calendar.HOUR, 2);
143+
processTaskCreate.set(Calendar.SECOND, 15);
142144
processTaskCreate.set(Calendar.MILLISECOND, 0);
143145

144146
Calendar inBetweenTaskCreation = Calendar.getInstance();
145147
inBetweenTaskCreation.add(Calendar.HOUR, 1);
148+
inBetweenTaskCreation.set(Calendar.SECOND, 21);
146149

147150
cmmnEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime());
148151
Task adhocTask = taskService.newTask();
@@ -362,7 +365,6 @@ public void testGetTasks() throws Exception {
362365
url = CmmnRestUrls.createRelativeResourceUrl(CmmnRestUrls.URL_TASK_COLLECTION) + "?dueDate=" + getIsoDateStringWithoutSeconds(
363366
adhocTaskCreate.getTime());
364367
assertResultsPresentInDataResponse(url);
365-
assertResultsPresentInDataResponse(url);
366368
url = CmmnRestUrls.createRelativeResourceUrl(CmmnRestUrls.URL_TASK_COLLECTION) + "?dueDate=" + getIsoDateStringWithMS(adhocTaskCreate.getTime());
367369
assertResultsPresentInDataResponse(url, adhocTask.getId());
368370

0 commit comments

Comments
 (0)