This is an automated email from the ASF dual-hosted git repository.
psalagnac pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 34cae920532 SOLR-16390: fix flaky test
ClusterPropsAPITest.testClusterPropertyOpsAllGood (#2901)
34cae920532 is described below
commit 34cae92053283ef069f1d5cefa10ea9502a79329
Author: Pierre Salagnac <[email protected]>
AuthorDate: Tue Dec 10 22:39:06 2024 +0100
SOLR-16390: fix flaky test
ClusterPropsAPITest.testClusterPropertyOpsAllGood (#2901)
The test fails when SSL in enabled, because of testing framework that
set 'urlScheme' cluster property. This change updates the test to ignore
existing cluster properties.
(cherry picked from commit e105547be5b36994703d3ed0d38413c65f0b8349)
---
.../handler/admin/api/ClusterPropsAPITest.java | 24 ++++++++++++++--------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git
a/solr/core/src/test/org/apache/solr/handler/admin/api/ClusterPropsAPITest.java
b/solr/core/src/test/org/apache/solr/handler/admin/api/ClusterPropsAPITest.java
index 9ae628e71eb..f690dbc1498 100644
---
a/solr/core/src/test/org/apache/solr/handler/admin/api/ClusterPropsAPITest.java
+++
b/solr/core/src/test/org/apache/solr/handler/admin/api/ClusterPropsAPITest.java
@@ -18,6 +18,8 @@
package org.apache.solr.handler.admin.api;
import static org.apache.solr.common.util.Utils.getObjectByPath;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.not;
import java.net.URL;
import java.util.List;
@@ -86,11 +88,14 @@ public class ClusterPropsAPITest extends SolrCloudTestCase {
@Test
public void testClusterPropertyOpsAllGood() throws Exception {
try (HttpSolrClient client = new
HttpSolrClient.Builder(baseUrl.toString()).build()) {
- // List Properties, confirm there aren't any
+ // List Properties, confirm the test property does not exist
+ // This ignores eventually existing other properties
Object o =
Utils.executeGET(client.getHttpClient(), baseUrlV2ClusterProps,
Utils.JSONCONSUMER);
assertNotNull(o);
- assertEquals(0, ((List<?>) getObjectByPath(o, true,
"clusterProperties")).size());
+ @SuppressWarnings("unchecked")
+ List<String> initProperties = (List<String>) getObjectByPath(o, true,
"clusterProperties");
+ assertThat(initProperties, not(hasItem(testClusterProperty)));
// Create a single cluster property
String path = baseUrlV2ClusterProps + "/" + testClusterProperty;
@@ -100,13 +105,12 @@ public class ClusterPropsAPITest extends
SolrCloudTestCase {
o = Utils.executeHttpMethod(client.getHttpClient(), path,
Utils.JSONCONSUMER, httpPut);
assertNotNull(o);
- // List Properties, this time there should be 1
+ // List Properties, this time there should be the just added property
o = Utils.executeGET(client.getHttpClient(), baseUrlV2ClusterProps,
Utils.JSONCONSUMER);
assertNotNull(o);
- assertEquals(1, ((List<?>) getObjectByPath(o, true,
"clusterProperties")).size());
- assertEquals(
- testClusterProperty,
- (String) ((List<?>) getObjectByPath(o, true,
"clusterProperties")).get(0));
+ @SuppressWarnings("unchecked")
+ List<String> updatedProperties = (List<String>) getObjectByPath(o, true,
"clusterProperties");
+ assertThat(updatedProperties, hasItem(testClusterProperty));
// Fetch Cluster Property
// Same path as used in the Create step above
@@ -122,10 +126,12 @@ public class ClusterPropsAPITest extends
SolrCloudTestCase {
o = Utils.executeHttpMethod(client.getHttpClient(), path,
Utils.JSONCONSUMER, httpDelete);
assertNotNull(o);
- // List Properties, should be back to 0
+ // List Properties, the test property should be gone
o = Utils.executeGET(client.getHttpClient(), baseUrlV2ClusterProps,
Utils.JSONCONSUMER);
assertNotNull(o);
- assertEquals(0, ((List<?>) getObjectByPath(o, true,
"clusterProperties")).size());
+ @SuppressWarnings("unchecked")
+ List<String> clearedProperties = (List<String>) getObjectByPath(o, true,
"clusterProperties");
+ assertThat(clearedProperties, not(hasItem(testClusterProperty)));
}
}