This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 7ba774fa2 Fix flaky tests (#2645) (#2666)
7ba774fa2 is described below
commit 7ba774fa264cdf929791f830563542c6b3df4674
Author: Simon Hofbauer <[email protected]>
AuthorDate: Tue Feb 27 19:14:31 2024 +0100
Fix flaky tests (#2645) (#2666)
in org.apache.helix.rest.metadatastore.
TestZkMetadataStoreDirectory
Co-authored-by: simonh5 <[email protected]>
---
.../rest/metadatastore/TestZkMetadataStoreDirectory.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git
a/helix-rest/src/test/java/org/apache/helix/rest/metadatastore/TestZkMetadataStoreDirectory.java
b/helix-rest/src/test/java/org/apache/helix/rest/metadatastore/TestZkMetadataStoreDirectory.java
index 64e04df9f..38ddfba87 100644
---
a/helix-rest/src/test/java/org/apache/helix/rest/metadatastore/TestZkMetadataStoreDirectory.java
+++
b/helix-rest/src/test/java/org/apache/helix/rest/metadatastore/TestZkMetadataStoreDirectory.java
@@ -21,6 +21,7 @@ package org.apache.helix.rest.metadatastore;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -31,7 +32,6 @@ import java.util.Set;
import org.apache.helix.TestHelper;
import org.apache.helix.msdcommon.constant.MetadataStoreRoutingConstants;
-import org.apache.helix.msdcommon.exception.InvalidRoutingDataException;
import org.apache.helix.rest.server.AbstractTestClass;
import org.apache.helix.zookeeper.datamodel.ZNRecord;
import org.apache.helix.zookeeper.datamodel.serializer.ZNRecordSerializer;
@@ -136,7 +136,7 @@ public class TestZkMetadataStoreDirectory extends
AbstractTestClass {
realms.add(TEST_REALM_2);
for (String namespace : _routingZkAddrMap.keySet()) {
-
Assert.assertEquals(_metadataStoreDirectory.getAllMetadataStoreRealms(namespace),
realms);
+
assertCollectionsContainSameElementsIgnoringOrder(_metadataStoreDirectory.getAllMetadataStoreRealms(namespace),
realms);
}
}
@@ -147,7 +147,7 @@ public class TestZkMetadataStoreDirectory extends
AbstractTestClass {
allShardingKeys.addAll(TEST_SHARDING_KEYS_2);
for (String namespace : _routingZkAddrMap.keySet()) {
-
Assert.assertEquals(_metadataStoreDirectory.getAllShardingKeys(namespace),
allShardingKeys);
+
assertCollectionsContainSameElementsIgnoringOrder(_metadataStoreDirectory.getAllShardingKeys(namespace),allShardingKeys);
}
}
@@ -375,4 +375,10 @@ public class TestZkMetadataStoreDirectory extends
AbstractTestClass {
return true;
}, TestHelper.WAIT_DURATION), "Routing data path should be deleted after
the tests.");
}
+ private void
assertCollectionsContainSameElementsIgnoringOrder(Collection<String>
collection1,
+ Collection<String> collection2) {
+ Assert.assertEquals(collection2.size(), collection1.size());
+ Assert.assertTrue(collection2.containsAll(collection1));
+ Assert.assertTrue(collection1.containsAll(collection2));
+ }
}