You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by il...@apache.org on 2020/07/07 15:30:57 UTC
[lucene-solr] branch branch_8x updated: SOLR-14462: adjust test so
less sessions are used even if test runs slowly. fix synchronization issue.
(#1657)
This is an automated email from the ASF dual-hosted git repository.
ilan pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new e65631e SOLR-14462: adjust test so less sessions are used even if test runs slowly. fix synchronization issue. (#1657)
e65631e is described below
commit e65631e026c5bb5c8eeb6fd1351bf798c0c6985c
Author: Ilan Ginzburg <ig...@salesforce.com>
AuthorDate: Tue Jul 7 17:30:20 2020 +0200
SOLR-14462: adjust test so less sessions are used even if test runs slowly. fix synchronization issue. (#1657)
cherry picked from 06b1f3e86694b35365fd569a0581b1f6fc2cadb3
---
.../client/solrj/cloud/autoscaling/TestPolicy.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
index a47f612..d3e3a8f 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/cloud/autoscaling/TestPolicy.java
@@ -1858,11 +1858,13 @@ public class TestPolicy extends SolrTestCaseJ4 {
for (int i = 0; i < COUNT_THREADS; i++) {
threads[i] = new Thread(() -> {
try {
- // This thread requests a session, computes using it for 50ms then returns is, executes for 1000ms more,
+ // This thread requests a session, computes using it for 25ms then returns is, executes for 1000ms more,
// releases the sessions and finishes.
PolicyHelper.SessionWrapper session = PolicyHelper.getSession(solrCloudManager);
- seenSessions.add(session);
- Thread.sleep(50);
+ synchronized (seenSessions) {
+ seenSessions.add(session);
+ }
+ Thread.sleep(25);
session.returnSession(session.get());
Thread.sleep(1000);
session.release();
@@ -1879,11 +1881,13 @@ public class TestPolicy extends SolrTestCaseJ4 {
}
assertEquals(COUNT_THREADS, completedThreads.get());
- // The value asserted below is somewhat arbitrary. Running locally max seen is 10, so hopefully 30 is safe.
- // Idea is to verify we do not allocate a high number of sessions even if many concurrent session
+ // The value asserted below is somewhat arbitrary. Running locally usually uses up to 5 sessions, so hopefully 30 is
+ // safe. Idea is to verify we do not allocate a high number of sessions even if many concurrent session
// requests arrive at the same time. The session computing time is short in purpose. If it were long, it would be
- // expected for more sessions to be allocated.
- assertTrue("Too many sessions created: " + seenSessions.size(), seenSessions.size() < 30);
+ // expected for more sessions to be needed.
+ // Note we joined with all the threads having updated seenSessions so no need to synchronize ("All actions in a thread
+ // happen before any other thread successfully returns from a join() on that thread" - JSR-133)
+ assertTrue("Too many (>=30) sessions created: " + seenSessions.size(), seenSessions.size() < 30);
PolicyHelper.SessionRef sessionRef = (PolicyHelper.SessionRef) solrCloudManager.getObjectCache().get(PolicyHelper.SessionRef.class.getName());
assertTrue(sessionRef.isEmpty());