Run tests with a RabbitMQ image

I have an application that uses a Postgres database and RabbitMQ as a message broker. For the database I’m using the convenience image cimg/postgres which works perfectly fine. For RabbitMQ there 's no convenience image as far as I can tell. I’m hence pulling it and starting it from docker hub like this;

dev-run-system-test:
    resource_class: xlarge
    docker:
      - image: cimg/python:3.10.7
        environment:
          PG_TEST_PORT: 5432
      - image: cimg/postgres:15.4
        environment:
          POSTGRES_USER: test_user
          POSTGRES_PASSWORD: test_password
          POSTGRES_DB: test_db
          POSTGRES_PORT: 5432
      - image: rabbitmq:3.11.23
        environment:
          RABBITMQ_DEFAULT_USER: dev_user
          RABBITMQ_DEFAULT_PASS: dev_user
    steps:
      - run-system-test:
          script: scripts/system-test.sh

The container itself seems to be starting just fine according to the logs but I cannot connect to it from my python application. Which is kind of expected as I haven’t exposed any ports. However, is there a way to to this? If not, how can I approach this problem to test my application with the help of a RabbitMQ container?

1 Like

The rabbitmq:3.11.23 docker image is built with the following exposed ports

 4369 5671 5672 15691 15692 25672

With 5672 being the listening port. These should be available to your code.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.