Skip to content

Commit

Permalink
fix(engine): ensure distinct deploy time timestamps
Browse files Browse the repository at this point in the history
* Introduce a delay between Deployments in the new test so that their DEPLOY_TIME_ timestamps can be ordered properly in MySQL.

Related to CAM-11750
  • Loading branch information
koevskinikola authored and ThorbenLindhauer committed May 11, 2020
1 parent 8d8d347 commit 9cfabd7
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;

import java.util.Date;
import java.util.List;
import java.util.Set;

Expand All @@ -38,6 +39,7 @@
import org.camunda.bpm.engine.impl.application.ProcessApplicationManager;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache;
import org.camunda.bpm.engine.impl.util.ClockUtil;
import org.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.repository.DeploymentHandlerFactory;
import org.camunda.bpm.engine.repository.DeploymentQuery;
Expand Down Expand Up @@ -104,6 +106,7 @@ public void tearDown() throws Exception {
clearProcessApplicationDeployments();
processApplication.undeploy();
processEngineConfiguration.setDeploymentHandlerFactory(defaultDeploymentHandlerFactory);
ClockUtil.reset();
}

@Test
Expand Down Expand Up @@ -1189,9 +1192,15 @@ public void testUnregisterProcessApplicationOnDeploymentDeletion() {
assertNull(managementService.getProcessApplicationForDeployment(deployment.getId()));
}

/*
* A delay is introduced between the two deployments so the test is valid when MySQL
* is used. See https://jira.camunda.com/browse/CAM-11893 for more details.
*/
@Test
public void shouldRegisterExistingDeploymentsOnLatestProcessDefinitionRemoval() {
// given
Date timeFreeze = new Date();
ClockUtil.setCurrentTime(timeFreeze);
BpmnModelInstance process1 = Bpmn.createExecutableProcess("process").done();
BpmnModelInstance process2 = Bpmn.createExecutableProcess("process").startEvent().done();

Expand All @@ -1200,6 +1209,8 @@ public void shouldRegisterExistingDeploymentsOnLatestProcessDefinitionRemoval()
.name("foo")
.addModelInstance("process.bpmn", process1));

// offset second deployment time to detect latest deployment with MySQL timestamps
ClockUtil.offset(1000L);
DeploymentWithDefinitions deployment2 = testRule.deploy(repositoryService
.createDeployment(processApplication.getReference())
.name("foo")
Expand Down

0 comments on commit 9cfabd7

Please sign in to comment.