You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2021/01/27 12:38:59 UTC
[lucene-solr] branch master updated: SOLR-15055: Fix this test to
avoid OS dependency.
This is an automated email from the ASF dual-hosted git repository.
ab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new b1cd6b6 SOLR-15055: Fix this test to avoid OS dependency.
b1cd6b6 is described below
commit b1cd6b691f94c5405ed013132e02628777fecdcd
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Wed Jan 27 13:38:22 2021 +0100
SOLR-15055: Fix this test to avoid OS dependency.
---
.../impl/PlacementPluginIntegrationTest.java | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
index 199d779..e699af6 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/impl/PlacementPluginIntegrationTest.java
@@ -325,7 +325,18 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
AttributeFetcher attributeFetcher = new AttributeFetcherImpl(cloudManager);
NodeMetric<String> someMetricKey = new NodeMetricImpl<>("solr.jvm:system.properties:user.name");
String sysprop = "user.name";
- String sysenv = "PWD";
+ Set<String> potentialEnvVars = Set.of("PWD", "TMPDIR", "TMP", "TEMP", "USER", "USERNAME", "HOME");
+
+ String envVar = null;
+ for (String env : potentialEnvVars) {
+ if (System.getenv(env) != null) {
+ envVar = env;
+ break;
+ }
+ }
+ if (envVar == null) {
+ fail("None of the potential env vars exist? " + potentialEnvVars);
+ }
attributeFetcher
.fetchFrom(cluster.getLiveNodes())
.requestNodeMetric(NodeMetricImpl.HEAP_USAGE)
@@ -336,11 +347,11 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
.requestNodeMetric(NodeMetricImpl.AVAILABLE_PROCESSORS)
.requestNodeMetric(someMetricKey)
.requestNodeSystemProperty(sysprop)
- .requestNodeEnvironmentVariable(sysenv)
+ .requestNodeEnvironmentVariable(envVar)
.requestCollectionMetrics(collection, Set.of(ReplicaMetricImpl.INDEX_SIZE_GB, ReplicaMetricImpl.QUERY_RATE_1MIN, ReplicaMetricImpl.UPDATE_RATE_1MIN));
AttributeValues attributeValues = attributeFetcher.fetchAttributes();
String userName = System.getProperty("user.name");
- String pwd = System.getenv("PWD");
+ String envVarValue = System.getenv(envVar);
// node metrics
for (Node node : cluster.getLiveNodes()) {
Optional<Double> doubleOpt = attributeValues.getNodeMetric(node, NodeMetricImpl.HEAP_USAGE);
@@ -363,9 +374,9 @@ public class PlacementPluginIntegrationTest extends SolrCloudTestCase {
Optional<String> syspropOpt = attributeValues.getSystemProperty(node, sysprop);
assertTrue("sysprop", syspropOpt.isPresent());
assertEquals("user.name sysprop", userName, syspropOpt.get());
- Optional<String> sysenvOpt = attributeValues.getEnvironmentVariable(node, sysenv);
- assertTrue("sysenv", sysenvOpt.isPresent());
- assertEquals("PWD sysenv", pwd, sysenvOpt.get());
+ Optional<String> envVarOpt = attributeValues.getEnvironmentVariable(node, envVar);
+ assertTrue("envVar", envVarOpt.isPresent());
+ assertEquals("envVar " + envVar, envVarValue, envVarOpt.get());
}
assertTrue(attributeValues.getCollectionMetrics(COLLECTION).isPresent());
CollectionMetrics collectionMetrics = attributeValues.getCollectionMetrics(COLLECTION).get();