Skip to content

Commit

Permalink
Add tests for check mode (StephenSorriaux#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgivanov committed Jun 5, 2019
1 parent dfd8120 commit 9ab4ad0
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ script:
- molecule converge -- --tags test_delete
- molecule converge -- --tags test_acl_create
- molecule converge -- --tags test_acl_delete
- molecule prepare --force
- molecule converge -- --tags test_check_mode_topic_delete
- molecule converge -- --tags test_check_mode_topic_update
- molecule converge -- --tags test_check_mode_topic_create
- molecule converge -- --tags test_check_mode_acl_delete
- molecule converge -- --tags test_check_mode_acl_create
123 changes: 119 additions & 4 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
- name: wait for topic deletion completion
pause:
seconds: 10
tags: test_delete
tags:
- test_delete
- test_check_mode_topic_create

- name: acl create
block:
Expand All @@ -117,15 +119,17 @@
sasl_plain_username: admin
sasl_plain_password: admin-secret
with_items: "{{ ansible_kafka_supported_versions }}"
tags: test_acl_create
tags:
- test_acl_create
- test_check_mode_acl_delete

- name: acl delete
block:
- name: set fact for current test
set_fact:
acl_defaut_configuration: "{{ acl_defaut_configuration | combine({'state': 'absent'}) }}"
cacheable: 'yes'
- name: create acl
- name: delete acl
kafka_lib:
resource: 'acl'
api_version: "{{ item.protocol_version }}"
Expand All @@ -140,4 +144,115 @@
sasl_plain_username: admin
sasl_plain_password: admin-secret
with_items: "{{ ansible_kafka_supported_versions }}"
tags: test_acl_delete
tags:
- test_acl_delete
- test_check_mode_acl_create

- name: create topic for check mode tests
block:
- name: set fact for current test
set_fact:
topic_defaut_configuration: "{{ topic_defaut_configuration | combine({'state': 'present'}) }}"
cacheable: 'yes'
- name: create topic for check mode tests
kafka_lib:
resource: "topic"
api_version: "{{ item.protocol_version }}"
name: "{{ topic_name }}"
partitions: "{{ topic_defaut_configuration.partitions }}"
replica_factor: "{{ topic_defaut_configuration.replica_factor }}"
options: "{{ topic_defaut_configuration.options|default({}) }}"
state: present
zookeeper: "{{ hostvars['zookeeper-' + item.instance_suffix]['ansible_eth0']['ipv4']['address'] }}:2181"
bootstrap_servers: "{{ bootstrap_plain }}"
with_items: "{{ ansible_kafka_supported_versions }}"
- name: wait 10 seconds
pause:
seconds: 10
tags:
- test_check_mode_topic_delete
- test_check_mode_topic_update

- name: delete topic (check mode)
kafka_lib:
resource: "topic"
api_version: "{{ item.protocol_version }}"
name: "{{ topic_name }}"
state: absent
zookeeper: "{{ hostvars['zookeeper-' + item.instance_suffix]['ansible_eth0']['ipv4']['address'] }}:2181"
bootstrap_servers: "{{ bootstrap_plain }}"
with_items: "{{ ansible_kafka_supported_versions }}"
check_mode: true
changed_when: false
tags: test_check_mode_topic_delete

- name: update topic (check mode)
kafka_lib:
resource: "topic"
api_version: "{{ item.protocol_version }}"
name: "{{ topic_name }}"
partitions: "{{ 1 + topic_defaut_configuration.partitions|int }}"
replica_factor: "{{ 1 + topic_defaut_configuration.replica_factor|int }}"
options:
'retention.ms': 1000
state: present
zookeeper: "{{ hostvars['zookeeper-' + item.instance_suffix]['ansible_eth0']['ipv4']['address'] }}:2181"
bootstrap_servers: "{{ bootstrap_plain }}"
with_items: "{{ ansible_kafka_supported_versions }}"
check_mode: true
changed_when: false
tags: test_check_mode_topic_update

- name: create topic (check mode)
kafka_lib:
resource: "topic"
api_version: "{{ item.protocol_version }}"
name: "{{ topic_name }}"
partitions: "{{ topic_defaut_configuration.partitions }}"
replica_factor: "{{ topic_defaut_configuration.replica_factor }}"
options: "{{ topic_defaut_configuration.options|default({}) }}"
state: present
zookeeper: "{{ hostvars['zookeeper-' + item.instance_suffix]['ansible_eth0']['ipv4']['address'] }}:2181"
bootstrap_servers: "{{ bootstrap_plain }}"
check_mode: true
changed_when: false
with_items: "{{ ansible_kafka_supported_versions }}"
tags: test_check_mode_topic_create

- name: delete ACL (check mode)
kafka_lib:
resource: 'acl'
api_version: "{{ item.protocol_version }}"
acl_resource_type: "topic"
name: "*"
acl_principal: "User:common"
acl_operation: "write"
acl_permission: "allow"
state: "absent"
bootstrap_servers: "{{ bootstrap_sasl }}"
security_protocol: SASL_PLAINTEXT
sasl_plain_username: admin
sasl_plain_password: admin-secret
check_mode: true
changed_when: false
with_items: "{{ ansible_kafka_supported_versions }}"
tags: test_check_mode_acl_delete

- name: create ACL (check mode)
kafka_lib:
resource: 'acl'
api_version: "{{ item.protocol_version }}"
acl_resource_type: "topic"
name: "*"
acl_principal: "User:common"
acl_operation: "write"
acl_permission: "allow"
state: "present"
bootstrap_servers: "{{ bootstrap_sasl }}"
security_protocol: SASL_PLAINTEXT
sasl_plain_username: admin
sasl_plain_password: admin-secret
check_mode: true
changed_when: false
with_items: "{{ ansible_kafka_supported_versions }}"
tags: test_check_mode_acl_create

0 comments on commit 9ab4ad0

Please sign in to comment.