-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: for missing job available notification
Add regression test which fails on SNAPSHOT, the job notification is missed in that case. With the fix the test is green.
- Loading branch information
1 parent
dad58fe
commit 46ece38
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
qa/integration-tests/src/test/java/io/camunda/zeebe/it/clustering/LongPollingIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.it.clustering; | ||
|
||
import io.camunda.zeebe.client.api.response.ProcessInstanceResult; | ||
import io.camunda.zeebe.model.bpmn.Bpmn; | ||
import io.camunda.zeebe.model.bpmn.BpmnModelInstance; | ||
import io.camunda.zeebe.test.util.testcontainers.ContainerLogsDumper; | ||
import io.camunda.zeebe.test.util.testcontainers.ZeebeTestContainerDefaults; | ||
import io.zeebe.containers.cluster.ZeebeCluster; | ||
import java.time.Duration; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.concurrent.TimeUnit; | ||
import org.agrona.CloseHelper; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.testcontainers.containers.Network; | ||
|
||
final class LongPollingIT { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(LongPollingIT.class); | ||
private static final BpmnModelInstance PROCESS = | ||
Bpmn.createExecutableProcess("process") | ||
.startEvent() | ||
.serviceTask("task", t -> t.zeebeJobType("foo")) | ||
.endEvent() | ||
.done(); | ||
|
||
private Network network; | ||
private ZeebeCluster cluster; | ||
|
||
@SuppressWarnings("unused") | ||
@RegisterExtension | ||
final ContainerLogsDumper gatewayLogsWatcher = | ||
new ContainerLogsDumper(() -> cluster.getGateways(), LOGGER); | ||
|
||
@SuppressWarnings("unused") | ||
@RegisterExtension | ||
final ContainerLogsDumper brokerLogsWatcher = | ||
new ContainerLogsDumper(() -> cluster.getBrokers(), LOGGER); | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
network = Network.newNetwork(); | ||
} | ||
|
||
@AfterEach | ||
void afterEach() { | ||
CloseHelper.quietCloseAll(cluster, network); | ||
} | ||
|
||
// regression test of https://github.com/camunda/zeebe/issues/9658 | ||
@Test | ||
void shouldActivateAndCompleteJobsInTime() { | ||
// given | ||
cluster = | ||
ZeebeCluster.builder() | ||
.withBrokersCount(1) | ||
.withGatewaysCount(1) | ||
.withEmbeddedGateway(false) | ||
.withPartitionsCount(3) | ||
.withReplicationFactor(1) | ||
.withBrokerImage(ZeebeTestContainerDefaults.defaultTestImage()) | ||
.withGatewayImage(ZeebeTestContainerDefaults.defaultTestImage()) | ||
.build(); | ||
cluster.start(); | ||
final var zeebeClient = cluster.newClientBuilder().build(); | ||
final var deploymentEvent = | ||
zeebeClient | ||
.newDeployResourceCommand() | ||
.addProcessModel(PROCESS, "process.bpmn") | ||
.send() | ||
.join(); | ||
// open the worker first and cause so to run into long polling mode | ||
zeebeClient | ||
.newWorker() | ||
.jobType("foo") | ||
.handler((c, j) -> c.newCompleteCommand(j).send()) | ||
.timeout(Duration.ofSeconds(10)) | ||
.pollInterval(Duration.ofMillis(10)) | ||
.open(); | ||
|
||
// when | ||
final var resultZeebeFuture = | ||
zeebeClient | ||
.newCreateInstanceCommand() | ||
.processDefinitionKey(deploymentEvent.getProcesses().get(0).getProcessDefinitionKey()) | ||
.withResult() | ||
.send(); | ||
|
||
// then | ||
Assertions.assertThat((CompletionStage<ProcessInstanceResult>) resultZeebeFuture) | ||
.succeedsWithin(2, TimeUnit.SECONDS) | ||
.isNotNull(); | ||
} | ||
} |