From 442be1122d68b6d356e3f918b7bdd34d465bf94b Mon Sep 17 00:00:00 2001 From: Simon Hofbauer <61789910+hofi1@users.noreply.github.com> Date: Tue, 27 Feb 2024 18:32:08 +0100 Subject: [PATCH] fix flaky test assertion #2667 (#2682) fix flaky test assertion in org.apache.helix .rest.server.TestPerInstanceAccessor.testGetAllMessages Co-authored-by: simonh5 --- .../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 355d5d1012..f9e48ca1f5 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 @@ -331,8 +331,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()); }