From 2a4352de4a058a9c4f0ff3cd00fe1c0f04610d6b Mon Sep 17 00:00:00 2001 From: Cyril Gaudin Date: Mon, 6 Jan 2020 16:51:04 +0100 Subject: [PATCH] Travis: Execute acceptance tests on dockerized RMQ. --- .travis.yml | 20 ++++++++++++++++++-- scripts/docker-compose.yml | 7 +++++++ scripts/wait-rabbitmq-docker.sh | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 scripts/docker-compose.yml create mode 100755 scripts/wait-rabbitmq-docker.sh diff --git a/.travis.yml b/.travis.yml index a9e18cd6..e2fbc567 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,17 @@ language: go go: - "1.13.x" +env: + global: + - GOFLAGS=-mod=vendor GO111MODULE=on + - RABBITMQ_ENDPOINT="http://127.0.0.1:15672" + - RABBITMQ_USERNAME="guest" + - RABBITMQ_PASSWORD="guest" + jobs: + - RABBITMQ_VERSION=3.8 + - RABBITMQ_VERSION=3.7 + - RABBITMQ_VERSION=3.6 + install: # This script is used by the Travis build to install a cookie for # go.googlesource.com so rate limits are higher when using `go get` to fetch @@ -17,13 +28,18 @@ script: - make test - make vet - make website-test +- docker-compose -f $(pwd)/scripts/docker-compose.yml up -d +- $(pwd)/scripts/wait-rabbitmq-docker.sh $(pwd)/scripts/docker-compose.yml +- make testacc +- docker-compose -f $(pwd)/scripts/docker-compose.yml down + branches: only: - master + - travis + matrix: fast_finish: true allow_failures: - go: tip -env: - - GOFLAGS=-mod=vendor GO111MODULE=on diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml new file mode 100644 index 00000000..7a6a713b --- /dev/null +++ b/scripts/docker-compose.yml @@ -0,0 +1,7 @@ +version: "3" + +services: + rabbitmq: + image: rabbitmq:${RABBITMQ_VERSION:-3.8}-management-alpine + ports: + - 15672:15672 diff --git a/scripts/wait-rabbitmq-docker.sh b/scripts/wait-rabbitmq-docker.sh new file mode 100755 index 00000000..9b67c5bb --- /dev/null +++ b/scripts/wait-rabbitmq-docker.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +COMPOSE_FILE=${1:-"docker-compose.yml"} + +TIMEOUT=30 + +if [ ! -e "$COMPOSE_FILE" ]; then + echo "Unable to find docker-compose file: $COMPOSE_FILE" + exit 1 +fi + +echo "Waiting for RabbitMQ to be up" +i=0 +until curl -s http://localhost:15672/api > /dev/null; do + i=$((i + 1)) + if [ $i -eq $TIMEOUT ]; then + echo + echo "Timeout while waiting for RabbitMQ to be up" + exit 1 + fi + printf "." + sleep 2 +done +