Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Travis: Execute acceptance tests on dockerized RMQ. #47

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
- 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
10 changes: 10 additions & 0 deletions scripts/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"

services:
rabbitmq:
image: rabbitmq:${RABBITMQ_VERSION:-3.8}-management-alpine
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USERNAME:-guest}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-guest}
ports:
- 15672:15672
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make things more explicit, could you also pass the environment variables that you defined for the username, password in here?

env:
  RABBITMQ_DEFAULT_USER: ${RABBITMQ_USERNAME:guest}
  RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:guest}

16 changes: 16 additions & 0 deletions scripts/wait-rabbitmq-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

TIMEOUT=30

echo "Waiting for RabbitMQ to be up"
i=0
until curl -s "${RABBITMQ_ENDPOINT}/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