-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
15432: [Backport stable/8.3] Do not delete jobs from backoff cf r=Zelldon a=backport-action # Description Backport of #15419 to `stable/8.3`. relates to #14329 original author: `@Zelldon` Co-authored-by: Christopher Zell <[email protected]>
- Loading branch information
Showing
3 changed files
with
133 additions
and
29 deletions.
There are no files selected for viewing
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
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
90 changes: 90 additions & 0 deletions
90
qa/integration-tests/src/test/java/io/camunda/zeebe/it/clustering/StateMigrationTest.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,90 @@ | ||
/* | ||
* 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.it.util.GrpcClientRule; | ||
import io.netty.util.NetUtil; | ||
import java.time.Duration; | ||
import org.awaitility.Awaitility; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.RuleChain; | ||
import org.springframework.util.unit.DataSize; | ||
|
||
public class StateMigrationTest { | ||
|
||
private static final DataSize ATOMIX_SEGMENT_SIZE = DataSize.ofMegabytes(2); | ||
private static final Duration SNAPSHOT_PERIOD = Duration.ofMinutes(5); | ||
private final ClusteringRule clusteringRule = | ||
new ClusteringRule( | ||
1, | ||
3, | ||
3, | ||
cfg -> { | ||
cfg.getData().setSnapshotPeriod(SNAPSHOT_PERIOD); | ||
cfg.getData().setLogSegmentSize(ATOMIX_SEGMENT_SIZE); | ||
cfg.getData().setLogIndexDensity(1); | ||
cfg.getNetwork().setMaxMessageSize(ATOMIX_SEGMENT_SIZE); | ||
}); | ||
private final GrpcClientRule clientRule = | ||
new GrpcClientRule( | ||
config -> | ||
config | ||
.gatewayAddress(NetUtil.toSocketAddressString(clusteringRule.getGatewayAddress())) | ||
.defaultRequestTimeout(Duration.ofMinutes(1)) | ||
.usePlaintext()); | ||
|
||
@Rule public RuleChain ruleChain = RuleChain.outerRule(clusteringRule).around(clientRule); | ||
|
||
// regression test for https://github.com/camunda/zeebe/issues/14329 | ||
@Test | ||
public void shouldMakeJobActivatableAfterMigrationAndBackoff() { | ||
// given | ||
final String jobType = "test"; | ||
clientRule.createSingleJob(jobType); | ||
|
||
final var activateResponse = | ||
clientRule | ||
.getClient() | ||
.newActivateJobsCommand() | ||
.jobType(jobType) | ||
.maxJobsToActivate(1) | ||
.send() | ||
.join(); | ||
final var jobKey = activateResponse.getJobs().get(0).getKey(); | ||
|
||
final Duration backoffTimeout = Duration.ofDays(1); | ||
clientRule | ||
.getClient() | ||
.newFailCommand(jobKey) | ||
.retries(1) | ||
.retryBackoff(backoffTimeout) | ||
.send() | ||
.join(); | ||
|
||
// when | ||
// we restart the leader - and expect another node takes over | ||
// new leader has to run migration first before starting processing | ||
clusteringRule.restartBroker(clusteringRule.getLeaderForPartition(1).getNodeId()); | ||
// increasing time so after job backoff timeout job should be marked activatable again | ||
clusteringRule.getClock().addTime(backoffTimeout.plus(backoffTimeout)); | ||
|
||
// then | ||
Awaitility.await() | ||
.until( | ||
() -> | ||
clientRule | ||
.getClient() | ||
.newActivateJobsCommand() | ||
.jobType(jobType) | ||
.maxJobsToActivate(1) | ||
.send() | ||
.join(), | ||
r -> !activateResponse.getJobs().isEmpty()); | ||
} | ||
} |