From 24dc05dd979264143223e166faa032e75f986b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 3 Dec 2017 16:28:38 +0100 Subject: Run some of the ci tests against a postgresql docker container --- .gitlab-ci.yml | 21 +++++++++++++++++++-- CMakeLists.txt | 2 +- src/bridge/bridge.cpp | 1 + src/xmpp/biboumi_component.cpp | 6 ++++++ tests/database.cpp | 19 +++++++++++++++++-- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b70297..cd6b307 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,6 +17,7 @@ variables: SYSTEMD: "-DWITH_SYSTEMD=1" LIBIDN: "-DWITH_LIBIDN=1" SQLITE3: "-DWITH_SQLITE3=1" + POSTGRESQL: "-WITH_POSTGRESQL=1" # ## Build jobs @@ -27,10 +28,10 @@ variables: tags: - docker script: - - "echo Running cmake with the following parameters: -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${SQLITE3}" + - "echo Running cmake with the following parameters: -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${SQLITE3} ${POSTGRESQL}" - mkdir build/ - cd build/ - - cmake .. -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${SQLITE3} + - cmake .. -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${UDNS} ${SYSTEMD} ${LIBIDN} ${SQLITE3} ${POSTGRESQL} - make everything -j$(nproc || echo 1) - make coverage_check -j$(nproc || echo 1) artifacts: @@ -64,21 +65,27 @@ build:alpine: build:1: variables: BOTAN: "-DWITHOUT_BOTAN=1" + POSTGRESQL: "-DWITHOUT_POSTGRESQL=1" <<: *fedora_build build:2: variables: UDNS: "-DWITHOUT_UDNS=1" + POSTGRESQL: "-DWITHOUT_POSTGRESQL=1" <<: *fedora_build build:3: variables: SQLITE3: "-DWITHOUT_SQLITE3=1" + TEST_POSTGRES_URI: "postgres@postgres/postgres" + services: + - postgres:latest <<: *fedora_build build:4: variables: SQLITE3: "-DWITHOUT_SQLITE3=1" + POSTGRESQL: "-DWITHOUT_POSTGRESQL=1" BOTAN: "-DWITHOUT_BOTAN=1" LIBIDN: "-DWITHOUT_LIBIDN=1" <<: *fedora_build @@ -87,17 +94,27 @@ build:5: variables: SQLITE3: "-DWITHOUT_SQLITE3=1" UDNS: "-DWITHOUT_UDNS=1" + TEST_POSTGRES_URI: "postgres@postgres/postgres" + services: + - postgres:latest <<: *fedora_build build:6: variables: BOTAN: "-DWITHOUT_BOTAN=1" UDNS: "-DWITHOUT_UDNS=1" + POSTGRESQL: "-DWITHOUT_POSTGRESQL=1" <<: *fedora_build build:7: variables: UDNS: "-DWITHOUT_UDNS=1" + POSTGRESQL: "-DWITHOUT_POSTGRESQL=1" + <<: *fedora_build + +build:8: + variables: + POSTGRESQL: "-DWITHOUT_POSTGRESQL=1" <<: *fedora_build diff --git a/CMakeLists.txt b/CMakeLists.txt index ba11aa6..155b73a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ endif() # ## Find optional instrumentation libraries that will be used in debug only # -find_library(LIBASAN NAMES asan libasan.so.3 libasan.so.2 libasan.so.1) +find_library(LIBASAN NAMES asan libasan.so.4 libasan.so.3 libasan.so.2 libasan.so.1) find_library(LIBUBSAN NAMES ubsan libubsan.so.0) # diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 925b226..57f0628 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -1031,6 +1031,7 @@ void Bridge::send_room_history(const std::string& hostname, std::string chan_nam (void)hostname; (void)chan_name; (void)resource; + (void)history_limit; #endif } diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 0b2bba0..51ca78d 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -1080,6 +1080,9 @@ void BiboumiComponent::on_irc_client_connected(const std::string& irc_hostname, const auto local_jid = irc_hostname + "@" + this->served_hostname; if (Database::has_roster_item(local_jid, jid)) this->send_presence_to_contact(local_jid, jid, ""); +#else + (void)irc_hostname; + (void)jid; #endif } @@ -1089,6 +1092,9 @@ void BiboumiComponent::on_irc_client_disconnected(const std::string& irc_hostnam const auto local_jid = irc_hostname + "@" + this->served_hostname; if (Database::has_roster_item(local_jid, jid)) this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, "unavailable"); +#else + (void)irc_hostname; + (void)jid; #endif } diff --git a/tests/database.cpp b/tests/database.cpp index aeddea3..20a446b 100644 --- a/tests/database.cpp +++ b/tests/database.cpp @@ -1,14 +1,29 @@ #include "catch.hpp" +#include + +#ifdef USE_DATABASE + +#include + #include #include TEST_CASE("Database") { -#ifdef USE_DATABASE -// Database::open("postgresql://test"); +#ifdef PQ_FOUND + std::string postgresql_uri{"postgresql://"}; + const char* env_value = ::getenv("TEST_POSTGRES_URI"); + if (env_value != nullptr) + postgresql_uri += env_value; + else + postgresql_uri += "/test"; + Database::open(postgresql_uri); +#else Database::open(":memory:"); +#endif + Database::raw_exec("DELETE FROM " + Database::irc_server_options.get_name()); Database::raw_exec("DELETE FROM " + Database::irc_channel_options.get_name()); -- cgit v1.2.3