diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 7002adf..cf4a6d6 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -156,6 +156,8 @@ stages: # test: ubuntu1804 - name: Ubuntu 22.04 test: ubuntu2204 + - name: Fedora 35 + test: fedora35 # Currently 20.04 is causing devel to fail. This maybe due to Ubuntu 20.04 running python # 3.8, however, ansible-test requires 3.9+. This means ansible test spins up a controller # and target container which is probably why rabbitmq_publish is not able to connect to @@ -192,6 +194,8 @@ stages: # test: ubuntu1804 - name: Ubuntu 20.04 test: ubuntu2004 + - name: Fedora 35 + test: fedora35 - stage: Docker_2_12 displayName: Docker 2.12 @@ -205,6 +209,8 @@ stages: # test: ubuntu1804 - name: Ubuntu 20.04 test: ubuntu2004 + - name: Fedora 35 + test: fedora35 - stage: Docker_2_11 displayName: Docker 2.11 @@ -231,6 +237,8 @@ stages: test: ubuntu1804 - name: Ubuntu 20.04 test: ubuntu2004 + - name: Fedora 35 + test: fedora35 - stage: Docker_2_10 displayName: Docker 2.10 @@ -257,6 +265,8 @@ stages: test: ubuntu1804 - name: Ubuntu 20.04 test: ubuntu2004 + - name: Fedora 35 + test: fedora35 - stage: Docker_2_9 displayName: Docker 2.9 diff --git a/changelogs/fragments/145-adding-fedora-testing.yml b/changelogs/fragments/145-adding-fedora-testing.yml new file mode 100644 index 0000000..2731f82 --- /dev/null +++ b/changelogs/fragments/145-adding-fedora-testing.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - rabbitmq_* testing - added Fedora testing diff --git a/tests/integration/targets/lookup_rabbitmq/tasks/main.yml b/tests/integration/targets/lookup_rabbitmq/tasks/main.yml index 740f899..1e1fcab 100644 --- a/tests/integration/targets/lookup_rabbitmq/tasks/main.yml +++ b/tests/integration/targets/lookup_rabbitmq/tasks/main.yml @@ -3,3 +3,8 @@ when: - ansible_distribution == 'Ubuntu' - ansible_distribution_release != 'trusty' + + +- include: ubuntu.yml + when: + - ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_binding/tasks/main.yml b/tests/integration/targets/rabbitmq_binding/tasks/main.yml index 4d3414e..3dd0f16 100644 --- a/tests/integration/targets/rabbitmq_binding/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_binding/tasks/main.yml @@ -1,3 +1,6 @@ --- - import_tasks: tests.yml when: ansible_distribution == 'Ubuntu' + +- import_tasks: tests.yml + when: ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_feature_flag/tasks/main.yml b/tests/integration/targets/rabbitmq_feature_flag/tasks/main.yml index 593906f..96e5b33 100644 --- a/tests/integration/targets/rabbitmq_feature_flag/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_feature_flag/tasks/main.yml @@ -1,2 +1,5 @@ - import_tasks: tests.yml when: ansible_distribution == 'Ubuntu' + +- import_tasks: tests.yml + when: ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_global_parameter/tasks/main.yml b/tests/integration/targets/rabbitmq_global_parameter/tasks/main.yml index 593906f..96e5b33 100644 --- a/tests/integration/targets/rabbitmq_global_parameter/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_global_parameter/tasks/main.yml @@ -1,2 +1,5 @@ - import_tasks: tests.yml when: ansible_distribution == 'Ubuntu' + +- import_tasks: tests.yml + when: ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_plugin/tasks/main.yml b/tests/integration/targets/rabbitmq_plugin/tasks/main.yml index 593906f..96e5b33 100644 --- a/tests/integration/targets/rabbitmq_plugin/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_plugin/tasks/main.yml @@ -1,2 +1,5 @@ - import_tasks: tests.yml when: ansible_distribution == 'Ubuntu' + +- import_tasks: tests.yml + when: ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_policy/tasks/main.yml b/tests/integration/targets/rabbitmq_policy/tasks/main.yml index 593906f..96e5b33 100644 --- a/tests/integration/targets/rabbitmq_policy/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_policy/tasks/main.yml @@ -1,2 +1,5 @@ - import_tasks: tests.yml when: ansible_distribution == 'Ubuntu' + +- import_tasks: tests.yml + when: ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_publish/tasks/fedora.yml b/tests/integration/targets/rabbitmq_publish/tasks/fedora.yml new file mode 100644 index 0000000..4136ae1 --- /dev/null +++ b/tests/integration/targets/rabbitmq_publish/tasks/fedora.yml @@ -0,0 +1,274 @@ +- name: Install requests and pika + pip: + name: requests,pika==1.3.0 + state: present + delegate_to: localhost + +- name: RabbitMQ basic publish test + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + queue: 'publish_test' + body: "Hello world from ansible module rabbitmq_publish" + content_type: "text/plain" + register: rabbit_basic_output1 + delegate_to: localhost + +- assert: + that: + - "rabbit_basic_output1 is not failed" + - "'publish_test' in rabbit_basic_output1.result.msg" + - "'publish_test' in rabbit_basic_output1.result.queue" + - "'text/plain' in rabbit_basic_output1.result.content_type" + + +# Testing random queue +- name: Publish to random queue + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + body: "RANDOM QUEUE POST" + content_type: "text/plain" + register: rabbit_random_queue_output + delegate_to: localhost + +- assert: + that: + - "rabbit_random_queue_output is not failed" + - "'amq.gen' in rabbit_random_queue_output.result.msg" + - "'amq.gen' in rabbit_random_queue_output.result.queue" + - "'text/plain' in rabbit_random_queue_output.result.content_type" + +- name: Copy binary to remote + copy: + src: "{{ role_path }}/files/image.gif" + dest: "{{ remote_tmp_dir }}/image.gif" + delegate_to: localhost + +- name: Publish binary to a queue + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + queue: publish_test + src: "{{ remote_tmp_dir }}/image.gif" + register: rabbitmq_publish_file + delegate_to: localhost + +- assert: + that: + - "rabbitmq_publish_file is not failed" + - "'publish_test' in rabbitmq_publish_file.result.queue" + - "'image/gif' in rabbitmq_publish_file.result.content_type" + +- name: Raise error for src and body defined + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + queue: 'publish_test' + src: "{{ remote_tmp_dir }}/image.gif" + body: blah + register: rabbit_basic_fail_output1 + ignore_errors: yes + delegate_to: localhost + +- assert: + that: + - "rabbit_basic_fail_output1 is failed" + - "'parameters are mutually exclusive' in rabbit_basic_fail_output1.msg" + +- name: Publish a file that does not exist + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + queue: 'publish_test' + src: 'aaaaaaajax-loader.gif' + register: file_missing_fail + ignore_errors: yes + delegate_to: localhost + +- assert: + that: + - "file_missing_fail is failed" + - "'Unable to open file' in file_missing_fail.msg" + +- name: Publish with proto/host/port/user/pass + rabbitmq_publish: + proto: amqp + host: localhost + port: 5672 + username: guest + password: guest + vhost: '%2F' + queue: publish_test + body: Testing with proto/host/port/username/password/vhost + register: host_port_output + delegate_to: localhost + +- assert: + that: + - "host_port_output is not failed" + +- name: Publish with host/port/user but missing proto + rabbitmq_publish: + host: localhost + port: 5672 + username: guest + password: guest + vhost: '%2F' + queue: publish_test + body: Testing with proto/host/port/username/password/vhost + ignore_errors: yes + register: host_port_missing_proto_output + delegate_to: localhost + +- assert: + that: + - "host_port_missing_proto_output is failed" + - "'Connection parameters must be passed via' in host_port_missing_proto_output.msg" + +- name: Publish with proto/host/port/user and url + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + proto: amqp + host: localhost + port: 5672 + username: guest + password: guest + vhost: '%2F' + queue: publish_test + body: Testing with proto/host/port/username/password/vhost + ignore_errors: yes + register: host_and_url_output + delegate_to: localhost + +- assert: + that: + - "host_and_url_output is failed" + - "'cannot be specified at the same time' in host_and_url_output.msg" + +- name: Publish headers to queue + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + queue: 'publish_test' + body: blah + headers: + myHeader: Value1 + secondHeader: Value2 + register: test_headers1 + ignore_errors: yes + delegate_to: localhost + +- name: Publish headers with file + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + queue: 'publish_test' + src: "{{ remote_tmp_dir }}/image.gif" + headers: + myHeader: Value1 + secondHeader: Value2 + register: test_headers2 + ignore_errors: yes + delegate_to: localhost + +- name: Collect all messages off the publish queue + set_fact: + messages: "{{ lookup('community.rabbitmq.rabbitmq', url='amqp://guest:guest@127.0.0.1:5672/%2F', queue='publish_test') }}" + delegate_to: localhost + +- name: Check contents of published messages + assert: + that: + - messages|length == 5 + - "'Hello world from ansible module rabbitmq_publish' in messages[0]['msg']" + - "'text/plain' in messages[0]['content_type']" + - "'image/gif' in messages[1]['content_type']" + - "'image.gif' in messages[1]['headers']['filename']" + - "'Testing with proto/host/port/username/password/vhost' in messages[2]['msg']" +# - messages[3]['headers']['myHeader'] is defined +# - messages[4]['headers']['filename'] is defined +# - messages[4]['headers']['secondHeader'] is defined +# + +- name: Check that queue and exchange are mutually exclusive + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + queue: 'fail_queue' + exchange: 'fail_exchange' + body: "Queue and exchange mutually exclusive should fail" + content_type: "text/plain" + register: rabbit_mutually_exclusive + delegate_to: localhost + ignore_errors: true + +- assert: + that: + - "rabbit_basic_fail_output1 is failed" + - "'parameters are mutually exclusive' in rabbit_mutually_exclusive.msg" + +# Publish to exchange testing +# - Create an exchange (pub_test_exchange) and a queue (pub_test_exchange_queue) +# - Bind exchange and queue +# - Send message to exchange +# - Check message arrived in queue + +- name: Add test requisites + block: + - name: Add exchange + rabbitmq_exchange: + name: "pub_test_exchange" + type: fanout + + - name: Add queue + rabbitmq_queue: + name: pub_test_exchange_queue + + - name: Add binding + rabbitmq_binding: + source: pub_test_exchange + destination: pub_test_exchange_queue + type: queue + register: add_binding + + - name: Check that binding succeeds with a change + assert: + that: + - add_binding.changed == true + +- name: RabbitMQ basic exchange publish test + rabbitmq_publish: + url: "amqp://guest:guest@127.0.0.1:5672/%2F" + exchange: 'pub_test_exchange' + body: "Hello world pub_test_exchange exchange from ansible module rabbitmq_publish" + content_type: "text/plain" + register: rabbit_exchange_output1 + delegate_to: localhost + +- assert: + that: + - "rabbit_exchange_output1 is not failed" + - "'pub_test_exchange' in rabbit_exchange_output1.result.msg" + +- name: Wait 2 seconds to make sure message has been delivered + pause: + seconds: 2 + +- name: Retrieve messages from pub_test_exchange_queue + set_fact: + rabbitmq_exchange_msg: "{{ lookup('community.rabbitmq.rabbitmq', url='amqp://guest:guest@127.0.0.1:5672/%2f/pub_test_exchange_queue', queue='pub_test_exchange_queue') }}" + ignore_errors: yes + register: rabbitmq_pub_test_exchange_queue + delegate_to: localhost + +- name: Debug out rabbitmq_pub_test_exchange_queue task result + debug: + var: rabbitmq_pub_test_exchange_queue + +- name: Debug out the set_fact rabbitmq_exchange_msg + debug: + var: rabbitmq_exchange_msg + +- name: Ensure one message was received + assert: + that: + - "rabbitmq_pub_test_exchange_queue is not failed" + - rabbitmq_exchange_msg | length == 1 + +- name: Ensure first message contains a string + assert: + that: + - "'pub_test_exchange exchange' in rabbitmq_exchange_msg[0].msg" diff --git a/tests/integration/targets/rabbitmq_publish/tasks/main.yml b/tests/integration/targets/rabbitmq_publish/tasks/main.yml index 740f899..2239299 100644 --- a/tests/integration/targets/rabbitmq_publish/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_publish/tasks/main.yml @@ -1,5 +1,9 @@ # Rabbitmq lookup -- include: ubuntu.yml +- import_tasks: ubuntu.yml when: - ansible_distribution == 'Ubuntu' - ansible_distribution_release != 'trusty' + +- import_tasks: ubuntu.yml + when: + - ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_upgrade/tasks/main.yml b/tests/integration/targets/rabbitmq_upgrade/tasks/main.yml index 593906f..96e5b33 100644 --- a/tests/integration/targets/rabbitmq_upgrade/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_upgrade/tasks/main.yml @@ -1,2 +1,5 @@ - import_tasks: tests.yml when: ansible_distribution == 'Ubuntu' + +- import_tasks: tests.yml + when: ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_user/tasks/main.yml b/tests/integration/targets/rabbitmq_user/tasks/main.yml index e03d4c7..40cb770 100644 --- a/tests/integration/targets/rabbitmq_user/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_user/tasks/main.yml @@ -8,3 +8,13 @@ - import_tasks: tests.yml environment: RABBITMQ_NODENAME: test + + +- when: ansible_distribution == 'Fedora' + block: + + - import_tasks: tests.yml + + - import_tasks: tests.yml + environment: + RABBITMQ_NODENAME: test diff --git a/tests/integration/targets/rabbitmq_user_limits/tasks/main.yml b/tests/integration/targets/rabbitmq_user_limits/tasks/main.yml index 740f899..2239299 100644 --- a/tests/integration/targets/rabbitmq_user_limits/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_user_limits/tasks/main.yml @@ -1,5 +1,9 @@ # Rabbitmq lookup -- include: ubuntu.yml +- import_tasks: ubuntu.yml when: - ansible_distribution == 'Ubuntu' - ansible_distribution_release != 'trusty' + +- import_tasks: ubuntu.yml + when: + - ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_vhost/tasks/main.yml b/tests/integration/targets/rabbitmq_vhost/tasks/main.yml index 593906f..96e5b33 100644 --- a/tests/integration/targets/rabbitmq_vhost/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_vhost/tasks/main.yml @@ -1,2 +1,5 @@ - import_tasks: tests.yml when: ansible_distribution == 'Ubuntu' + +- import_tasks: tests.yml + when: ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/rabbitmq_vhost_limits/tasks/main.yml b/tests/integration/targets/rabbitmq_vhost_limits/tasks/main.yml index 740f899..88dd599 100644 --- a/tests/integration/targets/rabbitmq_vhost_limits/tasks/main.yml +++ b/tests/integration/targets/rabbitmq_vhost_limits/tasks/main.yml @@ -1,5 +1,10 @@ -# Rabbitmq lookup - include: ubuntu.yml when: - ansible_distribution == 'Ubuntu' - ansible_distribution_release != 'trusty' + + + +- include: ubuntu.yml + when: + - ansible_distribution == 'Fedora' diff --git a/tests/integration/targets/setup_rabbitmq/tasks/fedora.yml b/tests/integration/targets/setup_rabbitmq/tasks/fedora.yml new file mode 100644 index 0000000..4c907fd --- /dev/null +++ b/tests/integration/targets/setup_rabbitmq/tasks/fedora.yml @@ -0,0 +1,91 @@ +--- +# https://stackoverflow.com/questions/25193161/chfn-pam-system-error-intermittently-in-docker-hub-builds/25267015 +- name: Disable chfn + file: + path: /usr/bin/chfn + src: /bin/true + state: link + force: yes + +# main document... +# https://www.rabbitmq.com/install-rpm.html +# https://github.com/rabbitmq/erlang-rpm +# +# https://cloudsmith.io/~rabbitmq/repos/rabbitmq-erlang/setup/#formats-rpm + +- name: Install required keys + ansible.builtin.rpm_key: + state: present + key: "{{ item }}" + loop: + - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" + - "https://packagecloud.io/rabbitmq/erlang/gpgkey" + - "https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey" + +- name: Add erlang repo + ansible.builtin.yum_repository: + name: rabbitmq_erlang + description: RabbitMQ erlang + baseurl: https://packagecloud.io/rabbitmq/erlang/el/8/$basearch + gpgcheck: true + repo_gpgcheck: true + gpgkey: + - https://packagecloud.io/rabbitmq/erlang/gpgkey + - https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc + sslverify: true + sslcacert: /etc/pki/tls/certs/ca-bundle.crt + metadata_expire: 300 + +- name: Add rabbitmq repo + ansible.builtin.yum_repository: + name: rabbitmq_server + description: RabbitMQ server + baseurl: https://packagecloud.io/rabbitmq/rabbitmq-server/el/8/$basearch + gpgcheck: false + repo_gpgcheck: true + gpgkey: + - https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey + - https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc + sslverify: true + sslcacert: /etc/pki/tls/certs/ca-bundle.crt + metadata_expire: 300 + +- name: Install dependencies + ansible.builtin.yum: + name: + - socat + - logrotate + update_cache: true + +- name: Install erlang + ansible.builtin.yum: + name: erlang + enablerepo: "rabbitmq_erlang,rabbitmq_server" + +- name: Install rabbitmq server + ansible.builtin.yum: + name: rabbitmq-server + enablerepo: "rabbitmq_erlang,rabbitmq_server" + + +# Copy configuration into place +# Start daemon - systemctl start rabbitmq-server + +- name: Ensure TLS config + copy: + src: rabbitmq.conf + dest: /etc/rabbitmq/rabbitmq.conf + +- name: Start RabbitMQ service + ansible.builtin.systemd: + name: rabbitmq-server + state: started + +- name: Enable management + command: rabbitmq-plugins enable --online rabbitmq_management + +- name: Install requests + pip: + name: requests + state: present + delegate_to: localhost