This is an automated email from the ASF dual-hosted git repository. jcamacho pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
commit 1dcd05541b815f4ab12c15517aea99d901c7233c Author: Stamatis Zampetakis <zabe...@gmail.com> AuthorDate: Tue Nov 17 11:13:22 2020 +0100 HIVE-24395: Intermittent failures to initialize dockerized Postgres metastore in tests (Stamatis Zampetakis, reviewed by Zoltan Haindrich) Ensure the Postgres init process is complete the database port is open and accepting connections before declaring the container ready. Closes apache/hive#1347 --- .../hadoop/hive/metastore/dbinstall/rules/Postgres.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/dbinstall/rules/Postgres.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/dbinstall/rules/Postgres.java index 5840095..e1b25c3 100644 --- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/dbinstall/rules/Postgres.java +++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/dbinstall/rules/Postgres.java @@ -17,6 +17,10 @@ */ package org.apache.hadoop.hive.metastore.dbinstall.rules; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Socket; + /** * JUnit TestRule for Postgres. */ @@ -63,7 +67,15 @@ public class Postgres extends DatabaseRule { @Override public boolean isContainerReady(String logOutput) { - return logOutput.contains("database system is ready to accept connections"); + if (logOutput.contains("PostgreSQL init process complete; ready for start up")) { + try (Socket socket = new Socket()) { + socket.connect(new InetSocketAddress("localhost", 5432), 1000); + return true; + } catch (IOException e) { + return false; + } + } + return false; } @Override