mirror of https://github.com/apache/lucene.git
Make this test more robust to the presence of MBeanServer created in other tests.
This commit is contained in:
parent
3cbbecca02
commit
fe34212a28
|
@ -28,7 +28,7 @@ import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.metrics.AggregateMetric;
|
import org.apache.solr.metrics.AggregateMetric;
|
||||||
import org.apache.solr.metrics.SolrMetricManager;
|
import org.apache.solr.metrics.SolrMetricManager;
|
||||||
import org.apache.solr.metrics.SolrMetricReporter;
|
import org.apache.solr.metrics.SolrMetricReporter;
|
||||||
import org.apache.solr.util.JmxUtil;
|
import org.apache.solr.metrics.reporters.SolrJmxReporter;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -42,6 +42,7 @@ public class SolrCloudReportersTest extends SolrCloudTestCase {
|
||||||
int jmxReporter;
|
int jmxReporter;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void configureDummyCluster() throws Exception {
|
public static void configureDummyCluster() throws Exception {
|
||||||
configureCluster(0).configure();
|
configureCluster(0).configure();
|
||||||
|
@ -52,7 +53,6 @@ public class SolrCloudReportersTest extends SolrCloudTestCase {
|
||||||
shutdownCluster();
|
shutdownCluster();
|
||||||
leaderRegistries = 0;
|
leaderRegistries = 0;
|
||||||
clusterRegistries = 0;
|
clusterRegistries = 0;
|
||||||
jmxReporter = JmxUtil.findFirstMBeanServer() != null ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -99,6 +99,12 @@ public class SolrCloudReportersTest extends SolrCloudTestCase {
|
||||||
assertEquals(5, sor.getPeriod());
|
assertEquals(5, sor.getPeriod());
|
||||||
for (String registryName : metricManager.registryNames(".*\\.shard[0-9]\\.replica.*")) {
|
for (String registryName : metricManager.registryNames(".*\\.shard[0-9]\\.replica.*")) {
|
||||||
reporters = metricManager.getReporters(registryName);
|
reporters = metricManager.getReporters(registryName);
|
||||||
|
jmxReporter = 0;
|
||||||
|
reporters.forEach((k, v) -> {
|
||||||
|
if (v instanceof SolrJmxReporter) {
|
||||||
|
jmxReporter++;
|
||||||
|
}
|
||||||
|
});
|
||||||
assertEquals(reporters.toString(), 1 + jmxReporter, reporters.size());
|
assertEquals(reporters.toString(), 1 + jmxReporter, reporters.size());
|
||||||
reporter = null;
|
reporter = null;
|
||||||
for (String name : reporters.keySet()) {
|
for (String name : reporters.keySet()) {
|
||||||
|
@ -158,6 +164,12 @@ public class SolrCloudReportersTest extends SolrCloudTestCase {
|
||||||
assertEquals(reporters.toString(), 0, reporters.size());
|
assertEquals(reporters.toString(), 0, reporters.size());
|
||||||
for (String registryName : metricManager.registryNames(".*\\.shard[0-9]\\.replica.*")) {
|
for (String registryName : metricManager.registryNames(".*\\.shard[0-9]\\.replica.*")) {
|
||||||
reporters = metricManager.getReporters(registryName);
|
reporters = metricManager.getReporters(registryName);
|
||||||
|
jmxReporter = 0;
|
||||||
|
reporters.forEach((k, v) -> {
|
||||||
|
if (v instanceof SolrJmxReporter) {
|
||||||
|
jmxReporter++;
|
||||||
|
}
|
||||||
|
});
|
||||||
assertEquals(reporters.toString(), 0 + jmxReporter, reporters.size());
|
assertEquals(reporters.toString(), 0 + jmxReporter, reporters.size());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue