From e6ff4143d535427e2822ef5ad504f0e36b0047c0 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Mon, 18 Jul 2016 12:33:52 +0100 Subject: [PATCH] [Test] Integrate functional tests with Travis CI --- .travis.yml | 14 +++++++++----- .../cases/statistics/redis-keyed-siphash.robot | 2 +- .../cases/statistics/redis-keyed-xxhash.robot | 2 +- .../cases/statistics/redis-plain-siphash.robot | 2 +- .../cases/statistics/redis-plain-xxhash.robot | 2 +- test/functional/configs/redis-server.conf | 3 ++- test/functional/lib/rspamd.robot | 4 ++++ test/functional/lib/vars.py | 1 + 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2c8bf754..519bbdaa5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,20 +7,24 @@ language: c # - linux # - osx +python: + - "3.4" + before_script: - sudo apt-get update -qq - - sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libpcre3-dev libsqlite3-dev libmagic-dev ragel make libssl-dev + - sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make ragel redis-server # - echo $TRAVIS_OS_NAME # - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq ; fi # - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev libpcre3-dev libsqlite3-dev libhiredis-dev ; fi # - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi # - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install cmake gmime glib luajit pcre hiredis sqlite libevent ; fi -script: - - mkdir _build - - cd _build - - cmake .. -DCMAKE_INSTALL_PREFIX=../_install -DCMAKE_C_COMPILER=$CC +script: + - chmod a+rx /home/travis + - cmake . -DCMAKE_INSTALL_PREFIX=./_install -DCMAKE_C_COMPILER=$CC - cmake --build . --target install + - sudo pip install robotframework + - sudo robot test/functional/cases compiler: - clang diff --git a/test/functional/cases/statistics/redis-keyed-siphash.robot b/test/functional/cases/statistics/redis-keyed-siphash.robot index f598915cd..ec95efcd1 100644 --- a/test/functional/cases/statistics/redis-keyed-siphash.robot +++ b/test/functional/cases/statistics/redis-keyed-siphash.robot @@ -4,7 +4,7 @@ Suite Teardown Redis Statistics Teardown Resource lib.robot *** Variables *** -${REDIS_SERVER} servers = "${LOCAL_ADDR}:${REDIS_PORT}" +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" ${STATS_BACKEND} redis ${STATS_HASH} hash = "siphash"; ${STATS_KEY} key = "${KEY_PVT1}"; diff --git a/test/functional/cases/statistics/redis-keyed-xxhash.robot b/test/functional/cases/statistics/redis-keyed-xxhash.robot index ca87895c5..5a7b2daf3 100644 --- a/test/functional/cases/statistics/redis-keyed-xxhash.robot +++ b/test/functional/cases/statistics/redis-keyed-xxhash.robot @@ -4,7 +4,7 @@ Suite Teardown Redis Statistics Teardown Resource lib.robot *** Variables *** -${REDIS_SERVER} servers = "${LOCAL_ADDR}:${REDIS_PORT}" +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" ${STATS_BACKEND} redis ${STATS_HASH} hash = "xxhash"; ${STATS_KEY} key = "${KEY_PVT1}"; diff --git a/test/functional/cases/statistics/redis-plain-siphash.robot b/test/functional/cases/statistics/redis-plain-siphash.robot index 2946e8903..d436b1a68 100644 --- a/test/functional/cases/statistics/redis-plain-siphash.robot +++ b/test/functional/cases/statistics/redis-plain-siphash.robot @@ -4,7 +4,7 @@ Suite Teardown Redis Statistics Teardown Resource lib.robot *** Variables *** -${REDIS_SERVER} servers = "${LOCAL_ADDR}:${REDIS_PORT}" +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" ${STATS_BACKEND} redis ${STATS_HASH} hash = "siphash"; diff --git a/test/functional/cases/statistics/redis-plain-xxhash.robot b/test/functional/cases/statistics/redis-plain-xxhash.robot index de69465f0..0c45ac16b 100644 --- a/test/functional/cases/statistics/redis-plain-xxhash.robot +++ b/test/functional/cases/statistics/redis-plain-xxhash.robot @@ -4,7 +4,7 @@ Suite Teardown Redis Statistics Teardown Resource lib.robot *** Variables *** -${REDIS_SERVER} servers = "${LOCAL_ADDR}:${REDIS_PORT}" +${REDIS_SERVER} servers = "${REDIS_ADDR}:${REDIS_PORT}" ${STATS_BACKEND} redis ${STATS_HASH} hash = "xxhash"; diff --git a/test/functional/configs/redis-server.conf b/test/functional/configs/redis-server.conf index 2973ae8d9..e44f8ab02 100644 --- a/test/functional/configs/redis-server.conf +++ b/test/functional/configs/redis-server.conf @@ -1,4 +1,5 @@ -bind ${LOCAL_ADDR} +bind ${REDIS_ADDR} daemonize yes +logfile ${TMPDIR}/redis.log pidfile ${TMPDIR}/redis.pid port ${REDIS_PORT} diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot index eb70d4c43..7bba2706c 100644 --- a/test/functional/lib/rspamd.robot +++ b/test/functional/lib/rspamd.robot @@ -75,11 +75,15 @@ Run Redis ${template} = Get File ${TESTDIR}/configs/redis-server.conf ${config} = Replace Variables ${template} Create File ${TMPDIR}/redis-server.conf ${config} + Log ${config} ${result} = Run Process redis-server ${TMPDIR}/redis-server.conf + Run Keyword If ${result.rc} != 0 Log ${result.stderr} Should Be Equal As Integers ${result.rc} 0 ${REDIS_PID} = Get File ${TMPDIR}/redis.pid Run Keyword If '${REDIS_SCOPE}' == 'Test' Set Test Variable ${REDIS_PID} ... ELSE IF '${REDIS_SCOPE}' == 'Suite' Set Suite Variable ${REDIS_PID} + ${redis_log} = Get File ${TMPDIR}/redis.log + Log ${redis_log} Run Rspamc [Arguments] @{args} diff --git a/test/functional/lib/vars.py b/test/functional/lib/vars.py index 316669911..d76d58d84 100644 --- a/test/functional/lib/vars.py +++ b/test/functional/lib/vars.py @@ -4,6 +4,7 @@ LOCAL_ADDR = 'localhost' PORT_CONTROLLER = 56790 PORT_FUZZY = 56791 PORT_NORMAL = 56789 +REDIS_ADDR = '127.0.0.1' REDIS_PORT = 56379 RSPAMD_GROUP = 'nogroup' RSPAMD_USER = 'nobody' -- 2.39.5