From 43ea8ac82dddbe0ce0070e85b01faf9eaae460b7 Mon Sep 17 00:00:00 2001 From: simonh5 Date: Mon, 2 Oct 2023 02:26:37 -0500 Subject: [PATCH] fix: fix flaky test assertion #2644 in org.apache.helix.rest.server. TestInstancesAccessor#testGetAllInstances --- .../apache/helix/rest/server/TestInstancesAccessor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java index fa059ad3030..689abc692d0 100644 --- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java +++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestInstancesAccessor.java @@ -159,8 +159,12 @@ 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)); + Assert.assertEquals(instances.size(), _instancesMap.get(CLUSTER_NAME).size(), "Different amount of elements in " + + "the sets: " + instances.size() + " vs: " + _instancesMap.get(CLUSTER_NAME).size()); + Assert.assertTrue(instances.containsAll(_instancesMap.get(CLUSTER_NAME)), "instances set does not contain all " + + "elenets of _instanceMap"); + Assert.assertTrue(_instancesMap.get(CLUSTER_NAME).containsAll(instances), "_instanceMap set does not contain all " + + "elements of instances"); System.out.println("End test :" + TestHelper.getTestMethodName()); }