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

CI: cv_deploy molecule test to use new infra #4441

Open
wants to merge 8 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions ansible_collections/arista/avd/molecule/cv_deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## How to test

Refer to [cv_workflow README.md](../cv_workflow/README.md)
gmuloc marked this conversation as resolved.
Show resolved Hide resolved
50 changes: 50 additions & 0 deletions ansible_collections/arista/avd/molecule/cv_deploy/cc_false.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
- name: Converge - cv_run_change_control = false
hosts: SITE1_FABRIC
connection: local
gather_facts: false
vars:
cv_server: www.cv-staging.corp.arista.io
cv_token: "{{ lookup('env', 'CVAAS_AAWG_CI') }}"
cv_verify_certs: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cv_verify_certs: false
cv_verify_certs: true

cv_skip_missing_devices: true
eos_config_dir: "{{ playbook_dir }}/intended/configs/test_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/test_configs"
intended_tag_device: avd-ci-leaf1
intended_tags: "{{ lookup('file', structured_dir ~ '/' ~ intended_tag_device ~ '.yml')| from_yaml }}"

tasks:
- name: Generate random string
ansible.builtin.set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"
run_once: true

- name: Set facts
ansible.builtin.set_fact:
cv_workspace_name: avd-cv-deploy-{{ r }}
cv_workspace_description: sample description
cv_change_control_name: cc_cv_deploy-{{ r }}
cv_change_control_description: sample description
cv_register_detailed_results: true
run_once: true

- name: Provision with cv_run_change_control = false
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_submit_workspace: true
cv_run_change_control: false
cv_submit_workspace_force: true

- name: Display CVP result
run_once: true
ansible.builtin.debug:
msg: '{{ cv_deploy_results }}'

- name: Check CVP returns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Check CVP returns
- name: Check CVP returns
run_once: true

ansible.builtin.assert:
that:
# Change control
- cv_deploy_results.change_control.requested_state == "pending approval"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- cv_deploy_results.change_control.requested_state == "pending approval"
- cv_deploy_results.change_control.requested_state == "pending approval"
- name: Cleanup orphan CC
run_once: true
uri:
url: https://{{ cv_server }}/api/resources/changecontrol/v1/ChangeControlConfig?key.id={{ cv_deploy_results.change_control.id }}
validate_certs: yes
return_content: yes
headers:
Accept: "application/json"
Content-Type: "application/json"
Authorization: "Bearer {{ lookup('env', 'CVAAS_AAWG_CI') }}"
method: DELETE
body_format: json
force_basic_auth: yes
timeout: 10
register: cvp_abandon_cc_result
until: cvp_abandon_cc_result.status == 200
retries: 3
delay: 3
ignore_errors: True
when: cv_deploy_results.change_control.state | lower in ['pending approval', 'approved']

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---
- name: Cleanup - Configuration deployment with CVP
hosts: localhost
hosts: SITE1_FABRIC
connection: local
gather_facts: false
vars:
cv_server: www.cv-staging.corp.arista.io
cv_token: "{{ lookup('env', 'CVAAS_AAWG_CI') }}"
cv_verify_certs: false
cv_devices: [ci-s1-leaf1, ci-s1-leaf2, ci-s1-leaf3, ci-s1-leaf4, ci-s1-spine1, ci-s1-spine2 ]
cv_skip_missing_devices: true
eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs"
Expand Down
238 changes: 10 additions & 228 deletions ansible_collections/arista/avd/molecule/cv_deploy/converge.yml
Original file line number Diff line number Diff line change
@@ -1,233 +1,15 @@
---
- name: Converge - Configuration deployment with CVP
hosts: localhost
connection: local
gather_facts: false
vars:
cv_server: www.cv-staging.corp.arista.io
cv_token: "{{ lookup('env', 'CVAAS_AAWG_CI') }}"
cv_verify_certs: false
cv_devices: [ci-s1-leaf1, ci-s1-leaf2, ci-s1-leaf3, ci-s1-leaf4, ci-s1-spine1, ci-s1-spine2 ]
cv_skip_missing_devices: true
eos_config_dir: "{{ playbook_dir }}/intended/configs/test_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/test_configs"
intended_tag_device: ci-s1-leaf1
intended_tags: "{{ lookup('file', structured_dir ~ '/' ~ intended_tag_device ~ '.yml')| from_yaml }}"
- name: Test cv deploy
import_playbook: cv_deploy.yml

tasks:
- name: Generate random string
ansible.builtin.set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"
run_once: true
- name: Test Provisions with Workspace Pending
import_playbook: workspace_pending.yml

- name: Set facts
ansible.builtin.set_fact:
cv_workspace_name: avd-cv-deploy-{{ r }}
cv_workspace_description: sample description
cv_change_control_name: cc_cv_deploy-{{ r }}
cv_change_control_description: sample description
cv_register_detailed_results: true
run_once: true
- name: Test Workspace Force True
import_playbook: workspace_force_true.yml

###########################
######## cv_deploy ########
###########################
- name: Test = Provision CVP with AVD configuration
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_submit_workspace: true
cv_submit_workspace_force: true
cv_run_change_control: true
- name: Test Workspace Force False
import_playbook: workspace_force_false.yml

- name: 'Display CVP result'
run_once: true
ansible.builtin.debug:
msg: '{{ cv_deploy_results }}'

- name: Check CVP returns
ansible.builtin.assert:
that:
# workspace
- cv_deploy_results.workspace.name == cv_workspace_name
- cv_deploy_results.workspace.state == "submitted"
- cv_deploy_results.workspace.state
# errors and warnings
- cv_deploy_results.errors == []
- cv_deploy_results.warnings == []
# tags
- cv_deploy_results.deployed_device_tags != []
- cv_deploy_results.deployed_interface_tags != []
# Change control
# - cv_deploy_results.change_control.id == cc_id
- cv_deploy_results.change_control.name == cv_change_control_name
- cv_deploy_results.change_control.requested_state == "completed"
- cv_deploy_results.change_control.description == cv_change_control_description

- name: Check tags from output
ansible.builtin.assert:
that:
- item.0.label == item.1.label
- item.0.value == item.1.value
loop: "{{ cv_deploy_results.deployed_device_tags | zip(cv_deploy_results.device_tags) | list }}"

- name: Extract all device tags from structured configs
ansible.builtin.set_fact:
expected_device_tags: "{{ intended_tags.metadata.cv_tags.device_tags }}"
output_device_tags: "{{ cv_deploy_results.deployed_device_tags }}"

- name: Check output device tags == intended device tags
ansible.builtin.assert:
that:
- item.0.name == item.1.label
- item.0.value == item.1.value
loop: "{{ expected_device_tags | zip(output_device_tags) | list }}"

- name: Extract all interface tags from role output
ansible.builtin.set_fact:
output_interface_tags: "{{ cv_deploy_results.deployed_interface_tags }}"

- name: Extract all interface tags from structured configs
ansible.builtin.set_fact:
expected_interface_tags: "{{ expected_interface_tags | default([]) + [item.tags | list | first | combine({'interface': item.interface})] }}"
loop: "{{ intended_tags.metadata.cv_tags.interface_tags }}"
loop_control:
label: "{{ item.interface }}"

- name: Check output interface tags == intended interface tags
ansible.builtin.assert:
that:
- item.0.name == item.1.label
- item.0.value == item.1.value
loop: "{{ expected_interface_tags | zip(output_interface_tags) | list }}"

- name: Convert unstructed data into yaml
ansible.builtin.set_fact:
deivces_structure: '{{ cv_deploy_results.deployed_configs | from_yaml }}'
output_devices: []

- name: Extract devices from output
ansible.builtin.set_fact:
output_devices: "{{ output_devices + [item.device.hostname] }}"
loop: "{{ deivces_structure }}"
loop_control:
label: "{{ item.configlet_name }}"

- name: Check output devices == intended devices
ansible.builtin.assert:
that:
- output_devices == cv_devices

- name: Cleanup
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs"
cv_submit_workspace: true
cv_submit_workspace_force: true
cv_run_change_control: true

- name: Test = Provision with workspace "Pending"
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_submit_workspace: false

- name: Check CVP returns
ansible.builtin.assert:
that:
# workspace
- cv_deploy_results.workspace.state == cv_deploy_results.workspace.requested_state

- name: Cleanup
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs"
cv_submit_workspace: true
cv_submit_workspace_force: true
cv_run_change_control: true

- name: Test = Provision with cv_submit_workspace_force = false
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_devices: [ci-s1-leaf1, ci-s1-leaf2, ci-s1-leaf3, ci-s1-leaf4, ci-s1-spine1, ci-s1-spine2, ci-s1-core1 ]
cv_submit_workspace_force: false
ignore_errors: yes
register: cvp_errors

- name: 'Display CVP result'
run_once: true
ansible.builtin.debug:
msg: '{{ cv_deploy_results }}'

- name: Check CVP returns
ansible.builtin.assert:
that:
# errors and warnings
- "'Failed to submit workspace' in cv_deploy_results.errors[0]"

- name: Cleanup
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs"
cv_submit_workspace: true
cv_submit_workspace_force: true
cv_run_change_control: true

- name: Test = Provision with cv_submit_workspace_force = true
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_devices: [ci-s1-leaf1, ci-s1-leaf2, ci-s1-leaf3, ci-s1-leaf4, ci-s1-spine1, ci-s1-spine2, ci-s1-core1 ]
cv_submit_workspace_force: true

- name: 'Display CVP result'
run_once: true
ansible.builtin.debug:
msg: '{{ cv_deploy_results }}'

- name: Check CVP returns
ansible.builtin.assert:
that:
# errors and warnings
- cv_deploy_results.errors == []

- name: Test = Provision with cv_run_change_control = false
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_submit_workspace: true
cv_run_change_control: false

- name: 'Display CVP result'
run_once: true
ansible.builtin.debug:
msg: '{{ cv_deploy_results }}'

- name: Check CVP returns
ansible.builtin.assert:
that:
# Change control
- cv_deploy_results.change_control.requested_state == "pending approval"
- name: Test Change Control False
import_playbook: cc_false.yml
Loading
Loading