Skip to content

Commit

Permalink
Fix gateway e2e test - set timestamp in second instead of ms (#2942)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyuanlu authored Oct 8, 2024
1 parent 2439837 commit b8393ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void resetTargetStateCache(String clusterName, String instanceName) {
*/
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testE2E() throws Exception {
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));
}
Expand Down Expand Up @@ -158,15 +158,18 @@ public void testE2E() throws Exception {
// 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));

Expand Down

0 comments on commit b8393ae

Please sign in to comment.