Repository: helix Updated Branches: refs/heads/master 811222654 -> 047ad51e8
[HELIX-736] Modify TestGetLastScheduledTaskTimestamp for increased stability This test was experiencing an intermittent failure. No inherent faults of its own, but sometimes tasks were not being given enough resource/time to be scheduled and register the timestamp, which is expected depending on how fast the system is running. One area of improvement was that TestGetLastScheduledTaskTimestamp was using a long value 0 for invalid or unscheduled timestamps. It will use -1L from now on, which is the invalid flag TaskDriver uses. Changlist: 1. Change the flag for invalid or unscheduled timestamps from 0 to -1L in TestGetLastScheduledTaskTimestamp Project: http://git-wip-us.apache.org/repos/asf/helix/repo Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/047ad51e Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/047ad51e Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/047ad51e Branch: refs/heads/master Commit: 047ad51e8b243dbbd268aa9ba954623949eba27d Parents: 8112226 Author: Hunter Lee <[email protected]> Authored: Mon Jul 16 15:54:06 2018 -0700 Committer: Hunter Lee <[email protected]> Committed: Tue Jul 17 11:44:12 2018 -0700 ---------------------------------------------------------------------- .../apache/helix/task/TestGetLastScheduledTaskTimestamp.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/helix/blob/047ad51e/helix-core/src/test/java/org/apache/helix/task/TestGetLastScheduledTaskTimestamp.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/task/TestGetLastScheduledTaskTimestamp.java b/helix-core/src/test/java/org/apache/helix/task/TestGetLastScheduledTaskTimestamp.java index 614278b..174d8c6 100644 --- a/helix-core/src/test/java/org/apache/helix/task/TestGetLastScheduledTaskTimestamp.java +++ b/helix-core/src/test/java/org/apache/helix/task/TestGetLastScheduledTaskTimestamp.java @@ -33,6 +33,7 @@ import org.testng.annotations.Test; public class TestGetLastScheduledTaskTimestamp extends TaskTestBase { private final static String TASK_START_TIME_KEY = "START_TIME"; + private final static long INVALID_TIMESTAMP = -1L; @BeforeClass public void beforeClass() throws Exception { @@ -44,8 +45,8 @@ public class TestGetLastScheduledTaskTimestamp extends TaskTestBase { public void testGetLastScheduledTaskTimestamp() throws InterruptedException { List<Long> startTimesWithStuckTasks = setupTasks("TestWorkflow_2", 5, 99999999); // First two must be -1 (two tasks are stuck), and API call must return the last value (most recent timestamp) - Assert.assertEquals(startTimesWithStuckTasks.get(0).longValue(), 0); - Assert.assertEquals(startTimesWithStuckTasks.get(1).longValue(), 0); + Assert.assertEquals(startTimesWithStuckTasks.get(0).longValue(), INVALID_TIMESTAMP); + Assert.assertEquals(startTimesWithStuckTasks.get(1).longValue(), INVALID_TIMESTAMP); Assert.assertEquals(startTimesWithStuckTasks.get(3).longValue(), _driver.getLastScheduledTaskTimestamp("TestWorkflow_2")); @@ -97,7 +98,7 @@ public class TestGetLastScheduledTaskTimestamp extends TaskTestBase { for (Integer partition : allPartitions) { String timestamp = jobContext.getMapField(partition).get(TASK_START_TIME_KEY); if (timestamp == null) { - startTimes.add(0L); + startTimes.add(INVALID_TIMESTAMP); } else { startTimes.add(Long.parseLong(timestamp)); }
