You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ap...@apache.org on 2021/07/08 19:36:32 UTC

[incubator-pinot] branch master updated: Add support to skip kinesis test if docker is not available (#7140)

This is an automated email from the ASF dual-hosted git repository.

apucher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 88bff60  Add support to skip kinesis test if docker is not available (#7140)
88bff60 is described below

commit 88bff607679ce1885cc7ca65ebdeac3b67d055ad
Author: Kartik Khare <kh...@gmail.com>
AuthorDate: Fri Jul 9 01:04:03 2021 +0530

    Add support to skip kinesis test if docker is not available (#7140)
---
 .../tests/RealtimeKinesisIntegrationTest.java      | 45 +++++++++++++++-------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/RealtimeKinesisIntegrationTest.java b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/RealtimeKinesisIntegrationTest.java
index d001c93..8f8021a 100644
--- a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/RealtimeKinesisIntegrationTest.java
+++ b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/RealtimeKinesisIntegrationTest.java
@@ -23,7 +23,6 @@ import cloud.localstack.docker.annotation.LocalstackDockerAnnotationProcessor;
 import cloud.localstack.docker.annotation.LocalstackDockerConfiguration;
 import cloud.localstack.docker.annotation.LocalstackDockerProperties;
 import cloud.localstack.docker.command.Command;
-import cloud.localstack.docker.exception.LocalstackDockerException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.JsonNodeType;
 import com.google.common.base.Function;
@@ -39,6 +38,7 @@ import java.sql.PreparedStatement;
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -63,6 +63,7 @@ import org.apache.pinot.util.TestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
+import org.testng.SkipException;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -108,9 +109,20 @@ public class RealtimeKinesisIntegrationTest extends BaseClusterIntegrationTestSe
 
   List<String> h2FieldNameAndTypes = new ArrayList<>();
 
+  private boolean skipTestNoDockerInstalled = false;
+
   @BeforeClass
   public void setUp()
       throws Exception {
+    try {
+      DockerInfoCommand dockerInfoCommand = new DockerInfoCommand();
+      dockerInfoCommand.execute();
+    } catch (IllegalStateException e) {
+      skipTestNoDockerInstalled = true;
+      LOGGER.warn("Skipping test! Docker is not found running", e);
+      throw new SkipException(e.getMessage());
+    }
+
     TestUtils.ensureDirectoriesExistAndEmpty(_tempDir);
 
     // Start the Pinot cluster
@@ -206,18 +218,10 @@ public class RealtimeKinesisIntegrationTest extends BaseClusterIntegrationTestSe
 
   public void startKinesis()
       throws Exception {
-    try {
-      final LocalstackDockerConfiguration dockerConfig = PROCESSOR.process(this.getClass());
-      localstackDocker.startup(dockerConfig);
-    } catch (LocalstackDockerException e) {
-      StopAllLocalstackDockerCommand stopAllLocalstackDockerCommand = new StopAllLocalstackDockerCommand();
-      stopAllLocalstackDockerCommand.execute();
-
-      final LocalstackDockerConfiguration dockerConfig = PROCESSOR.process(this.getClass());
-      //Restart localstack docker after killing all the existing localstack docker containers.
-      //If it fails at this step, the test is terminated.
-      localstackDocker.startup(dockerConfig);
-    }
+    final LocalstackDockerConfiguration dockerConfig = PROCESSOR.process(this.getClass());
+    StopAllLocalstackDockerCommand stopAllLocalstackDockerCommand = new StopAllLocalstackDockerCommand();
+    stopAllLocalstackDockerCommand.execute();
+    localstackDocker.startup(dockerConfig);
 
     kinesisClient = KinesisClient.builder().httpClient(new ApacheSdkHttpService().createHttpClientBuilder()
         .buildWithDefaults(
@@ -438,6 +442,10 @@ public class RealtimeKinesisIntegrationTest extends BaseClusterIntegrationTestSe
   @AfterClass(alwaysRun = true)
   public void tearDown()
       throws Exception {
+    if (skipTestNoDockerInstalled) {
+      return;
+    }
+
     dropRealtimeTable(getTableName());
     stopServer();
     stopBroker();
@@ -461,4 +469,15 @@ public class RealtimeKinesisIntegrationTest extends BaseClusterIntegrationTestSe
       }
     }
   }
+
+  public static class DockerInfoCommand extends Command {
+
+    public void execute() {
+      String dockerInfo = dockerExe.execute(Collections.singletonList("info"));
+
+      if (dockerInfo.toLowerCase().contains("error")) {
+        throw new IllegalStateException("Docker daemon is not running!");
+      }
+    }
+  }
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org