You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2022/05/05 08:47:16 UTC

[GitHub] [jackrabbit-oak] tihom88 commented on a diff in pull request #559: Oak-9729 | Improving ES test container creation for ES tests

tihom88 commented on code in PR #559:
URL: https://github.com/apache/jackrabbit-oak/pull/559#discussion_r865684223


##########
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestServer.java:
##########
@@ -44,23 +44,32 @@ public class ElasticTestServer implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(ElasticTestServer.class);
     private static final String PLUGIN_DIGEST = "db479aeee452b2a0f6e3c619ecdf27ca5853e54e7bc787e5c56a49899c249240";
-    private static ElasticTestServer esTestServer;
-    private volatile ElasticsearchContainer elasticsearchContainer;
+    private static ElasticTestServer esTestServer = new ElasticTestServer();
+    private static volatile ElasticsearchContainer elasticsearchContainer;
 
-    public static synchronized ElasticTestServer getESTestServer() {
-            if (esTestServer == null) {
-                LOG.info("Starting ES test server");
-                esTestServer = new ElasticTestServer();
-                esTestServer.setup();
-                Runtime.getRuntime().addShutdownHook(new Thread(() -> {
-                    LOG.info("Stopping global ES test server.");
-                    esTestServer.close();
-                }));
+    private ElasticTestServer() {
+    }
+
+    public static synchronized ElasticsearchContainer getESTestServer() {
+        // Setup a new ES container if elasticsearchContainer is null or not running
+        if (elasticsearchContainer == null || !elasticsearchContainer.isRunning()) {

Review Comment:
   Can a container be in different state like starting? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org