Declaring rabbitmq exchanges in travis build setup

Viewed 174

I'd like to set up some RabbitMQ exchanges in the Travis environment before executing my integration tests.

.travis.yml

services:
  - rabbitmq

before_script:
  - src/it/bin/configure_rabbitmq.sh

configure_rabbitmq.sh

#!/usr/bin/env bash

if [ -f ./rabbitmqadmin ]; then
    echo "rabbitmqadmin already present"
else
    wget http://localhost:15672/cli/rabbitmqadmin
    chmod +x rabbitmqadmin
fi

./rabbitmqadmin declare vhost name=guest
for r in a b c d e; do
    ./rabbitmqadmin --vhost=guest declare exchange name=set-$r-testing type=fanout durable=true -u guest -p guest
done

failure log

$ src/it/bin/configure_rabbitmq.sh
--2018-08-31 01:56:05--  http://localhost:15672/cli/rabbitmqadmin
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:15672... connected.
HTTP request sent, awaiting response... 200 OK
Length: 37698 (37K) [application/octet-stream]
Saving to: ‘rabbitmqadmin’
     0K .......... .......... .......... ......               100%  181K=0.2s
2018-08-31 01:56:06 (181 KB/s) - ‘rabbitmqadmin’ saved [37698/37698]
vhost declared
*** Access refused: /api/exchanges/guest/set-a-testing
*** Access refused: /api/exchanges/guest/set-b-testing
*** Access refused: /api/exchanges/guest/set-c-testing
*** Access refused: /api/exchanges/guest/set-d-testing
*** Access refused: /api/exchanges/guest/set-e-testing
The command "src/it/bin/configure_rabbitmq.sh" failed and exited with 1 during .

What is preventing my authorisation to create these exchanges?

1 Answers

The Travis RabbitMQ docs state:

RabbitMQ requires setuid flags, so you can only run RabbitMQ on standard, OS X or Trusty infrastructure (ie, your .travis.yml must contain sudo: required).

Adding sudo: required may likely resolve this.

Related