You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ma...@apache.org on 2022/12/21 08:36:38 UTC

[flink-connector-elasticsearch] branch main updated: [FLINK-28177][Connector/Elasticsearch][Tests] Use Testcontainers `waitingFor ` method to check if the Elasticsearch containers are up. This closes #48

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

martijnvisser pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-connector-elasticsearch.git


The following commit(s) were added to refs/heads/main by this push:
     new 79e7c96  [FLINK-28177][Connector/Elasticsearch][Tests] Use Testcontainers `waitingFor ` method to check if the Elasticsearch containers are up. This closes #48
79e7c96 is described below

commit 79e7c96666c3518777a3914a7902764d98b038e7
Author: dingweiqings <di...@163.com>
AuthorDate: Wed Dec 21 16:36:33 2022 +0800

    [FLINK-28177][Connector/Elasticsearch][Tests] Use Testcontainers `waitingFor ` method to check if the Elasticsearch containers are up. This closes #48
    
    * [FLINK-28177][Connector/Elasticsearch][Tests] Use Testcontainers `waitingFor ` method to check if the Elasticsearch containers are up. This closes #48
---
 .../table/Elasticsearch6DynamicSinkITCase.java           | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/flink-connector-elasticsearch6/src/test/java/org/apache/flink/streaming/connectors/elasticsearch/table/Elasticsearch6DynamicSinkITCase.java b/flink-connector-elasticsearch6/src/test/java/org/apache/flink/streaming/connectors/elasticsearch/table/Elasticsearch6DynamicSinkITCase.java
index 27834fc..32baf0a 100644
--- a/flink-connector-elasticsearch6/src/test/java/org/apache/flink/streaming/connectors/elasticsearch/table/Elasticsearch6DynamicSinkITCase.java
+++ b/flink-connector-elasticsearch6/src/test/java/org/apache/flink/streaming/connectors/elasticsearch/table/Elasticsearch6DynamicSinkITCase.java
@@ -65,13 +65,20 @@ import java.util.Map;
 import static org.apache.flink.streaming.connectors.elasticsearch.table.TestContext.context;
 import static org.apache.flink.table.api.Expressions.row;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.testcontainers.containers.wait.strategy.Wait.forHttp;
 
 /** IT tests for {@link Elasticsearch6DynamicSink}. */
 public class Elasticsearch6DynamicSinkITCase extends TestLogger {
 
     @ClassRule
     public static ElasticsearchContainer elasticsearchContainer =
-            new ElasticsearchContainer(DockerImageName.parse(DockerImageVersions.ELASTICSEARCH_6));
+            new ElasticsearchContainer(DockerImageName.parse(DockerImageVersions.ELASTICSEARCH_6))
+                    .waitingFor(
+                            forHttp("/")
+                                    .withMethod("HEAD")
+                                    .forStatusCode(200)
+                                    .forPort(9200)
+                                    .withStartupTimeout(Duration.ofMinutes(2)));
 
     @SuppressWarnings("deprecation")
     protected final RestHighLevelClient getClient() {
@@ -230,11 +237,8 @@ public class Elasticsearch6DynamicSinkITCase extends TestLogger {
 
     @Test
     public void testWritingDocumentsNoPrimaryKey() throws Exception {
-        EnvironmentSettings settings = EnvironmentSettings.inStreamingMode();
-        settings.getConfiguration().setString("restart-strategy", "fixed-delay");
-        settings.getConfiguration().setInteger("restart-strategy.fixed-delay.attempts", 3);
-        // default fixed delay is 1 seconds
-        TableEnvironment tableEnvironment = TableEnvironment.create(settings);
+        TableEnvironment tableEnvironment =
+                TableEnvironment.create(EnvironmentSettings.inStreamingMode());
 
         String index = "no-primary-key";
         String myType = "MyType";