7 votes

Comment utiliser Rabbit dans un fichier gitlab-ci.yml ?

Je veux tester avec gitlab-ci.yml un serveur rpc nameko.

Je ne peux pas réussir à faire travailler le Rabitt à l'intérieur. .gitlab-ci.yml : :

image: python:latest

before_script:
  - apt-get update -yq
  - apt-get install -y python-dev python-pip tree
  - curl -I http://guest:guest@rabbitmq:8080/api/overview

mytest:
  artifacts:
    paths:
    - dist
  script:
  - pip install -r requirements.txt 
  - pip install .
  - pytest --amqp-uri=amqp://guest:guest@rabbitmq:5672 --rabbit-ctl-uri=http://guest:guest@rabbitmq:15672 tests
  # - python setup.py test
  - python setup.py bdist_wheel

look:
  stage: deploy
  script:
  - ls -lah dist
services:
  - rabbitmq:3-management

Le Lapin démarre correctement : :

2017-04-13T18:19:23.436309219Z 
2017-04-13T18:19:23.436409026Z               RabbitMQ 3.6.9. Copyright (C) 2007-2016 Pivotal Software, Inc.
2017-04-13T18:19:23.436432568Z   ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
2017-04-13T18:19:23.436451431Z   ##  ##
2017-04-13T18:19:23.436468542Z   ##########  Logs: tty
2017-04-13T18:19:23.436485607Z   ######  ##        tty
2017-04-13T18:19:23.436501886Z   ##########
2017-04-13T18:19:23.436519036Z               Starting broker...
2017-04-13T18:19:23.440790736Z 
2017-04-13T18:19:23.440809836Z =INFO REPORT==== 13-Apr-2017::18:19:23 ===
2017-04-13T18:19:23.440819014Z Starting RabbitMQ 3.6.9 on Erlang 19.3
2017-04-13T18:19:23.440827601Z Copyright (C) 2007-2016 Pivotal Software, Inc.
2017-04-13T18:19:23.440835737Z Licensed under the MPL.  See http://www.rabbitmq.com/
2017-04-13T18:19:23.443408721Z 
2017-04-13T18:19:23.443429311Z =INFO REPORT==== 13-Apr-2017::18:19:23 ===
2017-04-13T18:19:23.443439837Z node           : rabbit@ea1a207b738e
2017-04-13T18:19:23.443449307Z home dir       : /var/lib/rabbitmq
2017-04-13T18:19:23.443460663Z config file(s) : /etc/rabbitmq/rabbitmq.config
2017-04-13T18:19:23.443470393Z cookie hash    : h6vFB5LezZ4GR1nGuQOVSg==
2017-04-13T18:19:23.443480053Z log            : tty
2017-04-13T18:19:23.443489256Z sasl log       : tty
2017-04-13T18:19:23.443498676Z database dir   : /var/lib/rabbitmq/mnesia/rabbit@ea1a207b738e
2017-04-13T18:19:27.717290199Z 
2017-04-13T18:19:27.717345348Z =INFO REPORT==== 13-Apr-2017::18:19:27 ===
2017-04-13T18:19:27.717355143Z Memory limit set to 3202MB of 8005MB total.
2017-04-13T18:19:27.726821043Z 
2017-04-13T18:19:27.726841925Z =INFO REPORT==== 13-Apr-2017::18:19:27 ===
2017-04-13T18:19:27.726850927Z Disk free limit set to 50MB
2017-04-13T18:19:27.732864417Z 
2017-04-13T18:19:27.732882507Z =INFO REPORT==== 13-Apr-2017::18:19:27 ===
2017-04-13T18:19:27.732891347Z Limiting to approx 1048476 file handles (943626 sockets)
2017-04-13T18:19:27.733030868Z 
2017-04-13T18:19:27.733041770Z =INFO REPORT==== 13-Apr-2017::18:19:27 ===
2017-04-13T18:19:27.733049763Z FHC read buffering:  OFF
2017-04-13T18:19:27.733126168Z FHC write buffering: ON
2017-04-13T18:19:27.793026622Z 
2017-04-13T18:19:27.793043832Z =INFO REPORT==== 13-Apr-2017::18:19:27 ===
2017-04-13T18:19:27.793052900Z Database directory at /var/lib/rabbitmq/mnesia/rabbit@ea1a207b738e is empty. Initialising from scratch...
2017-04-13T18:19:27.800414211Z 
2017-04-13T18:19:27.800429311Z =INFO REPORT==== 13-Apr-2017::18:19:27 ===
2017-04-13T18:19:27.800438013Z     application: mnesia
2017-04-13T18:19:27.800464988Z     exited: stopped
2017-04-13T18:19:27.800473228Z     type: temporary
2017-04-13T18:19:28.129404329Z 
2017-04-13T18:19:28.129482072Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.129491680Z Waiting for Mnesia tables for 30000 ms, 9 retries left
2017-04-13T18:19:28.153509130Z 
2017-04-13T18:19:28.153526528Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.153535638Z Waiting for Mnesia tables for 30000 ms, 9 retries left
2017-04-13T18:19:28.193558406Z 
2017-04-13T18:19:28.193600316Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.193611144Z Waiting for Mnesia tables for 30000 ms, 9 retries left
2017-04-13T18:19:28.194448672Z 
2017-04-13T18:19:28.194464866Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.194475629Z Priority queues enabled, real BQ is rabbit_variable_queue
2017-04-13T18:19:28.208882072Z 
2017-04-13T18:19:28.208912016Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.208921824Z Starting rabbit_node_monitor
2017-04-13T18:19:28.211145158Z 
2017-04-13T18:19:28.211169236Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.211182089Z Management plugin: using rates mode 'basic'
2017-04-13T18:19:28.224499311Z 
2017-04-13T18:19:28.224527962Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.224538810Z msg_store_transient: using rabbit_msg_store_ets_index to provide index
2017-04-13T18:19:28.226355958Z 
2017-04-13T18:19:28.226376272Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.226385706Z msg_store_persistent: using rabbit_msg_store_ets_index to provide index
2017-04-13T18:19:28.227832476Z 
2017-04-13T18:19:28.227870221Z =WARNING REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.227891823Z msg_store_persistent: rebuilding indices from scratch
2017-04-13T18:19:28.230832501Z 
2017-04-13T18:19:28.230872729Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.230893941Z Adding vhost '/'
2017-04-13T18:19:28.385440862Z 
2017-04-13T18:19:28.385520360Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.385540022Z Creating user 'guest'
2017-04-13T18:19:28.398092244Z 
2017-04-13T18:19:28.398184254Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.398206496Z Setting user tags for user 'guest' to [administrator]
2017-04-13T18:19:28.413704571Z 
2017-04-13T18:19:28.413789806Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.413810378Z Setting permissions for 'guest' in '/' to '.*', '.*', '.*'
2017-04-13T18:19:28.451109821Z 
2017-04-13T18:19:28.451162892Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.451172185Z started TCP Listener on [::]:5672
2017-04-13T18:19:28.475429729Z 
2017-04-13T18:19:28.475491074Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.475501172Z Management plugin started. Port: 15672
2017-04-13T18:19:28.475821397Z 
2017-04-13T18:19:28.475835599Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.475844143Z Statistics database started.
2017-04-13T18:19:28.487572236Z  completed with 6 plugins.
2017-04-13T18:19:28.487797794Z 
2017-04-13T18:19:28.487809763Z =INFO REPORT==== 13-Apr-2017::18:19:28 ===
2017-04-13T18:19:28.487818426Z Server startup complete; 6 plugins started.
2017-04-13T18:19:28.487826288Z  * rabbitmq_management
2017-04-13T18:19:28.487833914Z  * rabbitmq_web_dispatch
2017-04-13T18:19:28.487841610Z  * rabbitmq_management_agent
2017-04-13T18:19:28.487861057Z  * amqp_client
2017-04-13T18:19:28.487875546Z  * cowboy
2017-04-13T18:19:28.487883514Z  * cowlib

*********

Mais je reçois cette erreur

$ pytest --amqp-uri=amqp://guest:guest@rabbitmq:5672 --rabbit-ctl-uri=http://guest:guest@rabbitmq:15672 tests
============================= test session starts ==============================
platform linux -- Python 3.6.1, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
...
E           Exception: Connection error for the RabbitMQ management HTTP API at http://guest:guest@rabbitmq:15672/api/overview, is it enabled?
...
source:565: DeprecationWarning: invalid escape sequence \*
ERROR: Job failed: exit code 1

3voto

Yeasin Ar Rahman Points 314

Je l'ai utilisé de la manière suivante et cela a fonctionné pour moi

image: "ruby:2.3.3" //not required by rabbitmq

services:
  - rabbitmq:latest

variables:
  RABBITMQ_DEFAULT_USER: guest
  RABBITMQ_DEFAULT_PASS: guest
  AMQP_URL: 'amqp://guest:guest@rabbitmq:5672'

Maintenant vous pouvez utiliser l'AMQP_URL env pour se connecter au serveur rabbimq. La règle générale est que toute services déclarée portera le nom (par ex. rabbitmq de rabbitmq:latest) comme hôte ou url ou serveur. Cependant, si vous l'exécutez sur votre propre serveur ou cluster Kubernetes, ce sera localhost ou 127.0.0.1. À mon humble avis, cela pourrait être un problème dans votre code. J'espère que cela vous aidera. :)

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X