This is an automated email from the ASF dual-hosted git repository. jxue pushed a commit to branch helix-gateway-service in repository https://gitbox.apache.org/repos/asf/helix.git
commit a685f41c03196c96f6ffd16ef6ab3407383bc455 Author: xyuanlu <[email protected]> AuthorDate: Tue Oct 8 16:39:18 2024 -0700 Fix gateway e2e test - set timestamp in second instead of ms (#2942) --- .../apache/helix/gateway/service/GatewayServiceManager.java | 2 +- .../helix/gateway/integration/TestFilePullChannelE2E.java | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java b/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java index 9d4430ba1..5e53833dc 100644 --- a/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java +++ b/helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java @@ -119,7 +119,7 @@ public class GatewayServiceManager { */ public Map<String, Map<String, Map<String, String>>> updateCacheWithNewCurrentStateAndGetDiff(String clusterName, Map<String, Map<String, Map<String, String>>> newCurrentStateMap) { - return getOrCreateCache(clusterName).updateCacheWithNewCurrentStateAndGetDiff(newCurrentStateMap); + return getOrCreateCache(clusterName).updateCacheWithNewCurrentStateAndGetDiff(newCurrentStateMap); } public void updateCurrentState(String clusterName, String instanceName, String resourceId, String shardId, String toState) { diff --git a/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java b/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java index 3066dcc91..0097f55f4 100644 --- a/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java +++ b/helix-gateway/src/test/java/org/apache/helix/gateway/integration/TestFilePullChannelE2E.java @@ -89,7 +89,7 @@ public class TestFilePullChannelE2E extends HelixGatewayTestBase { for (int i = 0; i < START_NUM_NODE; i++) { csPaths.add(createTempFile(currentStatePath + i, ".txt", "")); targetPaths.add(createTempFile(targetStatePath + i, ".txt", "")); - String currentTime = String.valueOf(System.currentTimeMillis()); + String currentTime = String.valueOf(System.currentTimeMillis()/1000); String content = "{\"IsAlive\":" + true + ",\"LastUpdateTime\":" + currentTime + "}"; healthPaths.add(createTempFile("tmphealthCheck" + i, ".txt", content)); } @@ -158,15 +158,18 @@ public class TestFilePullChannelE2E extends HelixGatewayTestBase { // check no pending messages for partitions verifyNoPendingMessages(List.of("instance0", "instance1", "instance2")); - // change health state to false on one instance - String currentTime = String.valueOf(System.currentTimeMillis()); - String content = "{\"IsAlive\":" + false + ",\"LastUpdateTime\":" + currentTime + "}"; + // change health state to false on two instances + String currentTime = String.valueOf(System.currentTimeMillis()/1000 - 100); + String content = "{\"IsAlive\":" + true + ",\"LastUpdateTime\":" + currentTime + "}"; Files.write(healthPaths.get(0), content.getBytes()); + String content2 = "{\"IsAlive\":" + false + ",\"LastUpdateTime\":" + currentTime + "}"; + Files.write(healthPaths.get(1), content2.getBytes()); + // check live instance for that instance is gone Assert.assertTrue(TestHelper.verify(() -> { List<String> liveInstance = getLiveInstances(); - return !liveInstance.contains("instance0") && liveInstance.contains("instance1") && liveInstance.contains( + return !liveInstance.contains("instance0") && !liveInstance.contains("instance1") && liveInstance.contains( "instance2"); }, TestHelper.WAIT_DURATION));
