Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ansible lint fixes for tests #504

Open
wants to merge 7 commits into
base: release/1.9.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ok-to-test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ jobs:
echo '${{ secrets.FC_CONFIG }}' > tests/integration/targets/prepare_fc_env/vars/main.yml
echo '${{ secrets.PC_CONFIG }}' > tests/integration/targets/prepare_env/vars/main.yml
echo '${{ secrets.NDB_CONFIG }}' > tests/integration/targets/prepare_ndb_env/vars/main.yml
ansible-playbook tests/integration/targets/prepare_env/tasks/prepare_env.yml
ansible-playbook tests/integration/targets/prepare_ndb_env/tasks/prepare_env.yml
ansible-playbook tests/integration/targets/prepare_fc_env/tasks/prepare_fc_env.yml
ansible-playbook tests/integration/targets/prepare_foundation_env/tasks/prepare_foundation_env.yml
ansible-playbook tests/integration/targets/prepare_env/playbooks/prepare_env.yml
ansible-playbook tests/integration/targets/prepare_ndb_env/playbooks/prepare_env.yml
ansible-playbook tests/integration/targets/prepare_fc_env/playbooks/prepare_fc_env.yml
ansible-playbook tests/integration/targets/prepare_foundation_env/playbooks/prepare_foundation_env.yml
ansible-test integration --continue-on-error --python ${{ matrix.python-version }} --coverage $flag
ansible-test coverage report > coverage.txt
ansible-playbook tests/integration/targets/prepare_env/tasks/cleanup.yml
ansible-playbook tests/integration/targets/prepare_foundation_env/tasks/cleanup.yml
ansible-playbook tests/integration/targets/prepare_env/playbooks/cleanup.yml
ansible-playbook tests/integration/targets/prepare_foundation_env/playbooks/cleanup.yml

- name: Code Coverage Check
if: ${{ always() }}
Expand Down
212 changes: 155 additions & 57 deletions README.md

Large diffs are not rendered by default.

53 changes: 29 additions & 24 deletions tests/integration/targets/ntnx_acps/tasks/create_acps.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
---
- name: Generate random name
set_fact:
ansible.builtin.set_fact:
random_name: "{{query('community.general.random_string',numbers=false, special=false,length=12)}}"

- set_fact:
- name: Set ACP names
ansible.builtin.set_fact:
acp1_name: "{{random_name[0]}}1"
acp2_name: "{{random_name[0]}}2"
acp3_name: "{{random_name[0]}}3"
acp4_name: "{{random_name[0]}}4"
acp5_name: "{{random_name[0]}}5"


- name: Create min ACP
ntnx_acps:
state: present
wait: True
wait: true
name: "{{acp1_name}}"
role:
uuid: "{{ acp.role.uuid }}"
register: result
check_mode: true
ignore_errors: True
ignore_errors: true

- name: Creation Status
assert:
ansible.builtin.assert:
that:
- result.response is defined
- result.changed == false
Expand All @@ -38,21 +38,22 @@
wait: true
name: "{{acp2_name}}"
role:
uuid: '{{ acp.role.uuid }}'
uuid: "{{ acp.role.uuid }}"
check_mode: false
register: result
ignore_errors: True
ignore_errors: true

- name: Creation Status
assert:
ansible.builtin.assert:
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
- result.response.spec.name == "{{acp2_name}}"
fail_msg: " Unable to create Min ACP "
success_msg: " Min ACP created successfully "

- set_fact:
- name: Add ACP uuid to todelete list
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
##########################################################
- name: Create ACP with user reference
Expand All @@ -64,10 +65,10 @@
user_uuids:
- "{{ acp.user_uuid }}"
register: result
ignore_errors: True
ignore_errors: true

- name: Creation Status
assert:
ansible.builtin.assert:
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
Expand All @@ -77,7 +78,8 @@
fail_msg: " Unable to Create ACP with user reference "
success_msg: " ACP with user reference created successfully "

- set_fact:
- name: Add ACP uuid to todelete list
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
##########################################################
- name: Create ACP with user ad user group reference
Expand All @@ -91,10 +93,10 @@
user_group_uuids:
- "{{ acp.user_group_uuid }}"
register: result
ignore_errors: True
ignore_errors: true

- name: Creation Status
assert:
ansible.builtin.assert:
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
Expand All @@ -105,7 +107,8 @@
fail_msg: " Unable to Create ACP with user and user group reference "
success_msg: " ACP with user and user group reference created successfully "

- set_fact:
- name: Add ACP uuid to todelete list
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
##########################################################
- name: Create ACP with all specfactions
Expand Down Expand Up @@ -134,7 +137,7 @@
operator: IN
rhs:
uuid_list:
- "{{ network.dhcp.uuid }}"
- "{{ network.dhcp.uuid }}"
- scope_filter:
- lhs: CATEGORY
operator: IN
Expand All @@ -148,10 +151,10 @@
rhs:
collection: ALL
register: result
ignore_errors: True
ignore_errors: true

- name: Creation Status
assert:
ansible.builtin.assert:
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
Expand All @@ -175,7 +178,8 @@
fail_msg: " Unable to Create ACP all specfactions "
success_msg: " ACP with all specfactions created successfully "

- set_fact:
- name: Add ACP uuid to todelete list
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
##########################################################
- name: Delete all created acps
Expand All @@ -184,16 +188,17 @@
acp_uuid: "{{ item }}"
register: result
loop: "{{ todelete }}"
ignore_errors: True
ignore_errors: true

- name: check listing status
assert:
- name: Check listing status
ansible.builtin.assert:
that:
- result.changed is defined
- result.changed == true
- result.msg == "All items completed"
fail_msg: "unable to delete all created acp's"
success_msg: "All acp's deleted successfully"

- set_fact:
- name: Reset todelete list
ansible.builtin.set_fact:
todelete: []
18 changes: 8 additions & 10 deletions tests/integration/targets/ntnx_acps/tasks/delete_acp.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
- name: Generate random name
set_fact:
ansible.builtin.set_fact:
random_name: "{{query('community.general.random_string',numbers=false, special=false,length=12)}}"

- set_fact:
- name: Set ACP name
ansible.builtin.set_fact:
acp1_name: "{{random_name[0]}}1"

- name: Create ACP with all specfactions
Expand All @@ -18,23 +19,21 @@
- "{{ acp.user_group_uuid }}"
filters:
- scope_filter:
-
lhs: PROJECT
- lhs: PROJECT
operator: IN
rhs:
uuid_list:
- "{{ project.uuid }}"
entity_filter:
-
lhs: ALL
- lhs: ALL
operator: IN
rhs:
collection: ALL
register: result
ignore_errors: True
ignore_errors: true

- name: Creation Status
assert:
ansible.builtin.assert:
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
Expand All @@ -50,7 +49,6 @@
fail_msg: " Unable to Create ACP all specfactions "
success_msg: " ACP with all specfactions created successfully "


- name: Delete acp
ntnx_acps:
state: absent
Expand All @@ -59,7 +57,7 @@
ignore_errors: true

- name: Creation Status
assert:
ansible.builtin.assert:
that:
- result.response is defined
- result.response.status == 'SUCCEEDED'
Expand Down
23 changes: 14 additions & 9 deletions tests/integration/targets/ntnx_acps/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
---
- module_defaults:
- name: Set module defaults
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
validate_certs: "{{ validate_certs }}"
nutanix_host: "{{ ip }}"
nutanix_username: "{{ username }}"
nutanix_password: "{{ password }}"
validate_certs: "{{ validate_certs }}"
block:
- import_tasks: "create_acps.yml"
- import_tasks: "delete_acp.yml"
- import_tasks: "update_acps.yml"
- import_tasks: "negative_scenarios.yml"
- name: Import "create_acps.yml"
ansible.builtin.import_tasks: "create_acps.yml"
- name: Import "delete_acp.yml"
ansible.builtin.import_tasks: "delete_acp.yml"
- name: Import "update_acps.yml"
ansible.builtin.import_tasks: "update_acps.yml"
- name: Import "negative_scenarios.yml"
ansible.builtin.import_tasks: "negative_scenarios.yml"
111 changes: 56 additions & 55 deletions tests/integration/targets/ntnx_acps/tasks/negative_scenarios.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
- debug:
msg: "Started Negative Creation Cases"
- name: Started Negative Creation Cases
ansible.builtin.debug:
msg: "Started Negative Creation Cases"

- name: Unknown role name
ntnx_acps:
state: present
name: MinACP2
role:
name: "unknown987"
register: result
ignore_errors: true
- name: Unknown role name
ntnx_acps:
state: present
name: MinACP2
role:
name: "unknown987"
register: result
ignore_errors: true

- name: Creation Status
assert:
that:
- result.failed==True
- result.msg=="Failed generating acp spec"
success_msg: ' Success: returned error as expected '
fail_msg: ' Fail ACP created successfully with unknown role name '
- name: Creation Status
ansible.builtin.assert:
that:
- result.failed==True
- result.msg=="Failed generating acp spec"
success_msg: " Success: returned error as expected "
fail_msg: " Fail ACP created successfully with unknown role name "
#######################################################
- name: Unknown role uuid
ntnx_acps:
state: present
name: MinACP2
role:
uuid: 00000000-0000-0000-0000-000000000000
register: result
ignore_errors: True
- name: Creation Status
assert:
that:
- result.failed==True
- result.status_code==405
success_msg: ' Success: returned error as expected '
fail_msg: ' Fail acp created successfully with unknown role uuid '
- name: Unknown role uuid
ntnx_acps:
state: present
name: MinACP2
role:
uuid: 00000000-0000-0000-0000-000000000000
register: result
ignore_errors: true
- name: Creation Status
ansible.builtin.assert:
that:
- result.failed==True
- result.status_code==405
success_msg: " Success: returned error as expected "
fail_msg: " Fail acp created successfully with unknown role uuid "
#######################################################
- name: Delete acp with unknown uuid
ntnx_acps:
state: absent
acp_uuid: 5
ignore_errors: True
register: result
- name: Creation Status
assert:
that:
- result.status_code==400
success_msg: ' Success: returned error as expected '
fail_msg: ' Fail deleting acp with unknown uuid '
- name: Delete acp with unknown uuid
ntnx_acps:
state: absent
acp_uuid: 5
ignore_errors: true
register: result
- name: Creation Status
ansible.builtin.assert:
that:
- result.status_code==400
success_msg: " Success: returned error as expected "
fail_msg: " Fail deleting acp with unknown uuid "
#######################################################
- name: Delete acp with missing uuid
ntnx_acps:
state: absent
ignore_errors: True
register: result
- name: Delete acp with missing uuid
ntnx_acps:
state: absent
ignore_errors: true
register: result

- name: Creation Status
assert:
that:
- result.failed==True
success_msg: ' Success: returned error as expected '
fail_msg: ' Fail deleting acp with missing uuid '
- name: Creation Status
ansible.builtin.assert:
that:
- result.failed==True
success_msg: " Success: returned error as expected "
fail_msg: " Fail deleting acp with missing uuid "
Loading
Loading