From b109c462a7a81d9ae34b6de30853191075e12e0b Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Wed, 10 Feb 2021 03:40:59 +0200 Subject: [PATCH] Tests: Wait for DB to start. --- test/oatpp-postgresql/tests.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/oatpp-postgresql/tests.cpp b/test/oatpp-postgresql/tests.cpp index 0c9daaa..918c200 100644 --- a/test/oatpp-postgresql/tests.cpp +++ b/test/oatpp-postgresql/tests.cpp @@ -6,12 +6,34 @@ #include "types/FloatTest.hpp" #include "types/InterpretationTest.hpp" + +#include "oatpp-postgresql/orm.hpp" #include "oatpp/core/base/Environment.hpp" +#include +#include + namespace { void runTests() { + OATPP_LOGI("Tests", "DB-URL='%s'", TEST_DB_URL); + auto connectionProvider = std::make_shared(TEST_DB_URL); + for(v_int32 i = 0; i < 6; i ++) { + try { + auto connection = connectionProvider->get(); + if(connection) { + OATPP_LOGD("Tests", "Database is up! We've got a connection!"); + break; + } + } catch (...) { + // DO NOTHING + } + + OATPP_LOGD("Tests", "Database is not ready. Sleep 10s..."); + std::this_thread::sleep_for(std::chrono::seconds(10)); + } + OATPP_RUN_TEST(oatpp::test::postgresql::ql_template::ParserTest); OATPP_RUN_TEST(oatpp::test::postgresql::types::IntTest);