From e0b1834240542994e00ec512ddc6f844f1deea43 Mon Sep 17 00:00:00 2001 From: simonh5 Date: Tue, 3 Oct 2023 18:21:37 -0500 Subject: [PATCH] fix flaky test assertion #2667 fix flaky test assertion in org.apache.helix .rest.server.TestPerInstanceAccessor.testGetAllMessages --- .../apache/helix/rest/server/TestPerInstanceAccessor.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestPerInstanceAccessor.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestPerInstanceAccessor.java index 35f0712b41..fd085327bc 100644 --- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestPerInstanceAccessor.java +++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestPerInstanceAccessor.java @@ -325,8 +325,11 @@ public void testGetAllInstances() throws IOException { Set instances = OBJECT_MAPPER.readValue(instancesStr, OBJECT_MAPPER.getTypeFactory().constructCollectionType(Set.class, String.class)); - Assert.assertEquals(instances, _instancesMap.get(CLUSTER_NAME), "Instances from response: " - + instances + " vs instances actually: " + _instancesMap.get(CLUSTER_NAME)); + String errorMessage = "Instances from response: "+ instances + " vs instances actually: " + + _instancesMap.get(CLUSTER_NAME); + Assert.assertEquals(instances.size(), _instancesMap.get(CLUSTER_NAME).size(), errorMessage); + Assert.assertTrue(instances.containsAll(_instancesMap.get(CLUSTER_NAME)), errorMessage); + Assert.assertTrue(_instancesMap.get(CLUSTER_NAME).containsAll(instances), errorMessage); System.out.println("End test :" + TestHelper.getTestMethodName()); }