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

penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new a550bb5  Add retry for the sql test (#9010)
a550bb5 is described below

commit a550bb5235cff8583b7fa34d5ec615887db8064c
Author: Yong Zhang <[email protected]>
AuthorDate: Thu Dec 24 04:22:35 2020 +0800

    Add retry for the sql test (#9010)
    
    *Motivation*
    
    Using await until for retrying the condition check.
    
    (cherry picked from commit d3e39a7e51b13a0eb5b05306bc21c934d827633f)
---
 .github/workflows/ci-integration-sql.yaml          |  2 +-
 .../tests/integration/presto/TestBasicPresto.java  | 46 ++++++++++++++--------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/ci-integration-sql.yaml 
b/.github/workflows/ci-integration-sql.yaml
index fae5ef9..d6bd447 100644
--- a/.github/workflows/ci-integration-sql.yaml
+++ b/.github/workflows/ci-integration-sql.yaml
@@ -95,4 +95,4 @@ jobs:
 
       - name: run integration tests
         if: steps.docs.outputs.changed_only == 'no'
-        run: mvn -B -f tests/pom.xml test 
-DintegrationTestSuiteFile=pulsar-sql.xml -DintegrationTests 
-DredirectTestOutputToFile=false
+        run: mvn -B -f tests/pom.xml test 
-DintegrationTestSuiteFile=pulsar-sql.xml -DintegrationTests 
-DredirectTestOutputToFile=false -DtestForkCount=1
diff --git 
a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/presto/TestBasicPresto.java
 
b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/presto/TestBasicPresto.java
index ed09b31..bb54c93 100644
--- 
a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/presto/TestBasicPresto.java
+++ 
b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/presto/TestBasicPresto.java
@@ -28,10 +28,10 @@ import 
org.apache.pulsar.tests.integration.docker.ContainerExecResult;
 import org.apache.pulsar.tests.integration.suites.PulsarTestSuite;
 import org.apache.pulsar.tests.integration.topologies.PulsarCluster;
 import org.apache.pulsar.tests.integration.topologies.PulsarClusterSpec;
+import org.awaitility.Awaitility;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeSuite;
 import org.testng.annotations.Test;
 
 import java.sql.Connection;
@@ -42,6 +42,7 @@ import java.sql.SQLException;
 import java.sql.Timestamp;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -124,23 +125,34 @@ public class TestBasicPresto extends PulsarTestSuite {
         assertThat(result.getExitCode()).isEqualTo(0);
         assertThat(result.getStdout()).contains("public/default");
 
-        result = execQuery("show tables in pulsar.\"public/default\";");
-        assertThat(result.getExitCode()).isEqualTo(0);
-        assertThat(result.getStdout()).contains("stocks");
-
-        ContainerExecResult containerExecResult = 
execQuery(String.format("select * from pulsar.\"public/default\".%s order by 
entryid;", stocksTopic));
-        assertThat(containerExecResult.getExitCode()).isEqualTo(0);
-        log.info("select sql query output \n{}", 
containerExecResult.getStdout());
-        String[] split = containerExecResult.getStdout().split("\n");
-        assertThat(split.length).isEqualTo(NUM_OF_STOCKS);
+        pulsarCluster.getBroker(0)
+            .execCmd(
+                "/bin/bash",
+                "-c", "bin/pulsar-admin namespaces unload public/default");
 
-        String[] split2 = containerExecResult.getStdout().split("\n|,");
-
-        for (int i = 0; i < NUM_OF_STOCKS; ++i) {
-            assertThat(split2).contains("\"" + i + "\"");
-            assertThat(split2).contains("\"" + "STOCK_" + i + "\"");
-            assertThat(split2).contains("\"" + (100.0 + i * 10) + "\"");
-        }
+        Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(
+            () -> {
+                ContainerExecResult r = execQuery("show tables in 
pulsar.\"public/default\";");
+                assertThat(r.getExitCode()).isEqualTo(0);
+                assertThat(r.getStdout()).contains("stocks");
+            }
+        );
+
+        Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(
+            () -> {
+                ContainerExecResult containerExecResult = 
execQuery(String.format("select * from pulsar.\"public/default\".%s order by 
entryid;", stocksTopic));
+                assertThat(containerExecResult.getExitCode()).isEqualTo(0);
+                log.info("select sql query output \n{}", 
containerExecResult.getStdout());
+                String[] split = containerExecResult.getStdout().split("\n");
+                assertThat(split.length).isEqualTo(NUM_OF_STOCKS);
+                String[] split2 = 
containerExecResult.getStdout().split("\n|,");
+                for (int i = 0; i < NUM_OF_STOCKS; ++i) {
+                    assertThat(split2).contains("\"" + i + "\"");
+                    assertThat(split2).contains("\"" + "STOCK_" + i + "\"");
+                    assertThat(split2).contains("\"" + (100.0 + i * 10) + 
"\"");
+                }
+            }
+        );
 
         // test predicate pushdown
 

Reply via email to