~singpolyma/biboumi

24dc05dd979264143223e166faa032e75f986b21 — louiz’ 4 years ago 6dc49f3
Run some of the ci tests against a postgresql docker container
5 files changed, 44 insertions(+), 5 deletions(-)

M .gitlab-ci.yml
M CMakeLists.txt
M src/bridge/bridge.cpp
M src/xmpp/biboumi_component.cpp
M tests/database.cpp
M .gitlab-ci.yml => .gitlab-ci.yml +19 -2
@@ 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



M CMakeLists.txt => CMakeLists.txt +1 -1
@@ 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)

#

M src/bridge/bridge.cpp => src/bridge/bridge.cpp +1 -0
@@ 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
}


M src/xmpp/biboumi_component.cpp => src/xmpp/biboumi_component.cpp +6 -0
@@ 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
}


M tests/database.cpp => tests/database.cpp +17 -2
@@ 1,14 1,29 @@
#include "catch.hpp"

#include <biboumi.h>

#ifdef USE_DATABASE

#include <cstdlib>

#include <database/database.hpp>

#include <config/config.hpp>

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());