You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by at...@apache.org on 2020/07/13 09:33:13 UTC
[lucene-solr] branch master updated: Harden
TestBuildingUpMemoryPressure (#1662)
This is an automated email from the ASF dual-hosted git repository.
atri 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 a73dbdd Harden TestBuildingUpMemoryPressure (#1662)
a73dbdd is described below
commit a73dbdd877cef6a6da286da1a27b9950092eb026
Author: Atri Sharma <at...@gmail.com>
AuthorDate: Mon Jul 13 15:02:59 2020 +0530
Harden TestBuildingUpMemoryPressure (#1662)
Add better error message checking and finer mocks along with temporary logging which will be removed.
---
.../org/apache/solr/util/TestCircuitBreaker.java | 31 +++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/util/TestCircuitBreaker.java b/solr/core/src/test/org/apache/solr/util/TestCircuitBreaker.java
index 00b8d1a..f41667f 100644
--- a/solr/core/src/test/org/apache/solr/util/TestCircuitBreaker.java
+++ b/solr/core/src/test/org/apache/solr/util/TestCircuitBreaker.java
@@ -17,6 +17,7 @@
package org.apache.solr.util;
+import java.lang.invoke.MethodHandles;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
@@ -37,8 +38,11 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestCircuitBreaker extends SolrTestCaseJ4 {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private final static int NUM_DOCS = 20;
@Rule
@@ -124,6 +128,13 @@ public class TestCircuitBreaker extends SolrTestCaseJ4 {
try {
h.query(req("name:\"john smith\""));
} catch (SolrException e) {
+ if (!e.getMessage().startsWith("Circuit Breakers tripped")) {
+ if (log.isInfoEnabled()) {
+ String logMessage = "Expected error message for testBuildingMemoryPressure was not received. Error message " + e.getMessage();
+ log.info(logMessage);
+ }
+ throw new RuntimeException("Expected error message was not received. Error message " + e.getMessage());
+ }
failureCount.incrementAndGet();
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
@@ -200,19 +211,33 @@ public class TestCircuitBreaker extends SolrTestCaseJ4 {
}
private class BuildingUpMemoryPressureCircuitBreaker extends MemoryCircuitBreaker {
- private AtomicInteger count = new AtomicInteger();
+ private AtomicInteger count;
public BuildingUpMemoryPressureCircuitBreaker(SolrConfig solrConfig) {
super(solrConfig);
+
+ this.count = new AtomicInteger(0);
}
@Override
protected long calculateLiveMemoryUsage() {
- if (count.getAndIncrement() >= 4) {
+ int localCount = count.getAndIncrement();
+
+ if (localCount >= 4) {
+ //TODO: To be removed
+ if (log.isInfoEnabled()) {
+ String logMessage = "Blocking query from BuildingUpMemoryPressureCircuitBreaker for count " + localCount;
+ log.info(logMessage);
+ }
return Long.MAX_VALUE;
}
- return 5; // Random number guaranteed to not trip the circuit breaker
+ //TODO: To be removed
+ if (log.isInfoEnabled()) {
+ String logMessage = "BuildingUpMemoryPressureCircuitBreaker: Returning unblocking value for count " + localCount;
+ log.info(logMessage);
+ }
+ return Long.MIN_VALUE; // Random number guaranteed to not trip the circuit breaker
}
}
}