From 89732a1e5fa327c0fe06cc5cf7e4e49c64f8cbfd Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Mon, 21 May 2018 07:49:45 +0200 Subject: [PATCH] rabbitmq_plugin: add integration tests (#40389) * rabbitmq_plugin: add integration tests * Use import_tasks instead of include --- .../targets/rabbitmq_plugin/aliases | 5 ++ .../targets/rabbitmq_plugin/meta/main.yml | 2 + .../targets/rabbitmq_plugin/tasks/main.yml | 2 + .../targets/rabbitmq_plugin/tasks/tests.yml | 69 +++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 test/integration/targets/rabbitmq_plugin/aliases create mode 100644 test/integration/targets/rabbitmq_plugin/meta/main.yml create mode 100644 test/integration/targets/rabbitmq_plugin/tasks/main.yml create mode 100644 test/integration/targets/rabbitmq_plugin/tasks/tests.yml diff --git a/test/integration/targets/rabbitmq_plugin/aliases b/test/integration/targets/rabbitmq_plugin/aliases new file mode 100644 index 0000000000..c9a649c10c --- /dev/null +++ b/test/integration/targets/rabbitmq_plugin/aliases @@ -0,0 +1,5 @@ +destructive +posix/ci/group1 +skip/osx +skip/freebsd +skip/rhel diff --git a/test/integration/targets/rabbitmq_plugin/meta/main.yml b/test/integration/targets/rabbitmq_plugin/meta/main.yml new file mode 100644 index 0000000000..05ab59000b --- /dev/null +++ b/test/integration/targets/rabbitmq_plugin/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_rabbitmq diff --git a/test/integration/targets/rabbitmq_plugin/tasks/main.yml b/test/integration/targets/rabbitmq_plugin/tasks/main.yml new file mode 100644 index 0000000000..593906fb74 --- /dev/null +++ b/test/integration/targets/rabbitmq_plugin/tasks/main.yml @@ -0,0 +1,2 @@ +- import_tasks: tests.yml + when: ansible_distribution == 'Ubuntu' diff --git a/test/integration/targets/rabbitmq_plugin/tasks/tests.yml b/test/integration/targets/rabbitmq_plugin/tasks/tests.yml new file mode 100644 index 0000000000..74286a8b9b --- /dev/null +++ b/test/integration/targets/rabbitmq_plugin/tasks/tests.yml @@ -0,0 +1,69 @@ +- block: + - set_fact: + plugin_name: rabbitmq_top + + - name: Enable plugin + rabbitmq_plugin: + name: "{{ plugin_name }}" + state: enabled + register: result + + - name: Get rabbitmq-plugins output + shell: "rabbitmq-plugins list | grep {{ plugin_name }}" + register: cli_result + + - name: Check that the plugin is enabled + assert: + that: + - result is changed + - result is success + - '"{{ plugin_name }}" in result.enabled' + - result.disabled== [] + - '"[E" in cli_result.stdout' + + - name: Enable plugin (idempotency) + rabbitmq_plugin: + name: "{{ plugin_name }}" + state: enabled + register: result + + - name: Check idempotency + assert: + that: + - result is not changed + + - name: Disable plugin + rabbitmq_plugin: + name: "{{ plugin_name }}" + state: disabled + register: result + + - name: Get rabbitmq-plugins output + shell: "rabbitmq-plugins list | grep {{ plugin_name }}" + register: cli_result + + - name: Check that the plugin is disabled + assert: + that: + - result is changed + - result is success + - result.enabled == [] + - '"{{ plugin_name }}" in result.disabled' + - '"[E" not in cli_result.stdout' + + - name: Disable plugin (idempotency) + rabbitmq_plugin: + name: "{{ plugin_name }}" + state: disabled + register: result + + - name: Check idempotency + assert: + that: + - result is not changed + + always: + - name: Disable plugin + rabbitmq_plugin: + name: "{{ plugin_name }}" + state: disabled