From 9cfabd7eef57dc05158b6c24a606c9071d3849db Mon Sep 17 00:00:00 2001 From: Nikola Koevski Date: Thu, 7 May 2020 16:22:41 +0200 Subject: [PATCH] fix(engine): ensure distinct deploy time timestamps * 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 --- .../repository/ProcessApplicationDeploymentTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/repository/ProcessApplicationDeploymentTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/repository/ProcessApplicationDeploymentTest.java index 09bf14910ac..e0a578f2fbf 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/api/repository/ProcessApplicationDeploymentTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/repository/ProcessApplicationDeploymentTest.java @@ -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; @@ -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; @@ -104,6 +106,7 @@ public void tearDown() throws Exception { clearProcessApplicationDeployments(); processApplication.undeploy(); processEngineConfiguration.setDeploymentHandlerFactory(defaultDeploymentHandlerFactory); + ClockUtil.reset(); } @Test @@ -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(); @@ -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")