-
Notifications
You must be signed in to change notification settings - Fork 61
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
Test: Adding integration tests for cv_device_v3 #621
Merged
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3874d7d
Test: Adding integration test for cv_device_v3 (move_device)
Vibhu-gslab 3a7a02b
Adding tests for state absent (decommission_device)
Shivani-gslab d346824
Addressing review comments
Shivani-gslab 7abdaea
Added tests for factory_reset and provisioning_reset
Shivani-gslab 4f3b398
Added tests for attach and detach bundle and fixed counters for bundl…
Vibhu-gslab 9683160
Added tests for apply/detach configlets
Shivani-gslab 060a980
Added test for deploy_device
Shivani-gslab a3155fb
Fixing pylint issues
Shivani-gslab 0968b78
added back inventory file; revert of d346824e7dd8b716d3011c78d914351f…
sugetha24 3db220d
reapplying partial changes from d346824e7dd8b716d3011c78d914351fe29b7202
sugetha24 20e2d6a
Separating files and fixing review comments
Shivani-gslab 3bbb648
Updating tests
Shivani-gslab 3ba5780
Fixing to clean up lab
Shivani-gslab 87d3c82
Changing for dual_dc topology
Shivani-gslab 9da93f4
minor nit
sugetha24 79b1a3f
Adding terninattr for image bundle
Shivani-gslab 4f6aa67
Minor fixes while testing PR
Shivani-gslab a10ac4f
Removing configlets from bundle playbook
Shivani-gslab 6e040e4
Added comments
sugetha24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
ansible_collections/arista/cvp/molecule/cv_device_v3/converge.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Test cv_device_v3 module | ||
import_playbook: test_move_and_deploy_device.yml | ||
|
||
- name: Test cv_device_v3 module | ||
import_playbook: test_apply_detach_configlet.yml | ||
|
||
- name: Test cv_device_v3 module | ||
import_playbook: test_apply_detach_bundle.yml | ||
|
||
- name: Test cv_device_v3 module | ||
import_playbook: test_decommission_factory_reset_provisioning_reset.yml |
25 changes: 25 additions & 0 deletions
25
ansible_collections/arista/cvp/molecule/cv_device_v3/molecule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
scenario: | ||
test_sequence: | ||
- converge | ||
driver: | ||
name: delegated | ||
platforms: | ||
- name: dummy | ||
managed: false | ||
provisioner: | ||
name: ansible | ||
config_options: | ||
defaults: | ||
jinja2_extensions: 'jinja2.ext.loopcontrols,jinja2.ext.do,jinja2.ext.i18n' | ||
gathering: explicit | ||
command_warnings: False | ||
remote_tmp: /tmp/.ansible-${USER}/tmp | ||
stdout_callback: yaml | ||
playbooks: | ||
converge: converge.yml | ||
ansible_args: | ||
- --inventory | ||
- ${MOLECULE_SCENARIO_DIRECTORY}/../../examples/inventory.yml | ||
verifier: | ||
name: ansible |
142 changes: 142 additions & 0 deletions
142
ansible_collections/arista/cvp/molecule/cv_device_v3/test_apply_detach_bundle.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
--- | ||
- name: Test cv_device_v3 | ||
hosts: CloudVision | ||
connection: local | ||
gather_facts: no | ||
vars: | ||
ansible_command_timeout: 1200 | ||
ansible_connect_timeout: 600 | ||
|
||
DEVICE_NAME: s1-leaf1 | ||
|
||
CVP_CONFIGLETS: | ||
configlet1: '! This is first configlet' | ||
|
||
IMAGE_NAME: "vEOS-lab.swi" | ||
|
||
EXTENSION_NAME: "TerminAttr-1.25.1-1.swix" | ||
|
||
BUNDLE_NAME: "Test_bundle" | ||
|
||
CVP_DEVICES_BUNDLE_ATTACHED: | ||
- fqdn: "{{DEVICE_NAME}}" | ||
parentContainerName: "{{CV_FACTS_V3_RESULT.data.cvp_devices[0].parentContainerName}}" | ||
configlets: | ||
- 'configlet1' | ||
imageBundle: Test_bundle | ||
|
||
CVP_DEVICES_BUNDLE_DETACHED: | ||
- fqdn: "{{DEVICE_NAME}}" | ||
parentContainerName: "{{CV_FACTS_V3_RESULT.data.cvp_devices[0].parentContainerName}}" | ||
configlets: | ||
- 'configlet1' | ||
|
||
CVP_DEVICES_DETACH_CONFIGLET: | ||
- fqdn: "{{DEVICE_NAME}}" | ||
parentContainerName: "{{CV_FACTS_V3_RESULT.data.cvp_devices[0].parentContainerName}}" | ||
configlets: "{{CV_FACTS_V3_RESULT.data.cvp_devices[0].configlets}}" | ||
|
||
tasks: | ||
- name: Collect devices facts from {{inventory_hostname}} | ||
arista.cvp.cv_facts_v3: | ||
facts: | ||
- devices | ||
regexp_filter: "{{DEVICE_NAME}}" | ||
register: CV_FACTS_V3_RESULT | ||
|
||
- name: "Push config" | ||
arista.cvp.cv_configlet_v3: | ||
configlets: "{{CVP_CONFIGLETS}}" | ||
state: present | ||
|
||
- name: "Upload EOS image to {{inventory_hostname}}" | ||
arista.cvp.cv_image_v3: | ||
mode: image | ||
action: add | ||
image: "{{IMAGE_NAME}}" | ||
|
||
- name: "Upload TerminAttr image to {{inventory_hostname}}" | ||
arista.cvp.cv_image_v3: | ||
mode: image | ||
action: add | ||
image: "{{EXTENSION_NAME}}" | ||
|
||
- name: "Create bundle {{inventory_hostname}}" | ||
arista.cvp.cv_image_v3: | ||
mode: bundle | ||
action: add | ||
bundle_name: "{{BUNDLE_NAME}}" | ||
image_list: | ||
- "{{IMAGE_NAME}}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need a Terminattr to be added to the bundle. Please add a terminattr to this bundle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
- "{{EXTENSION_NAME}}" | ||
|
||
- name: "Attach bundle on {{inventory_hostname}}" | ||
arista.cvp.cv_device_v3: | ||
devices: '{{CVP_DEVICES_BUNDLE_ATTACHED}}' | ||
state: present | ||
apply_mode: strict | ||
register: ATTACH_BUNDLE | ||
|
||
- name: "Check attach bundle" | ||
assert: | ||
that: | ||
- ATTACH_BUNDLE.bundle_attached.changed == true | ||
- ATTACH_BUNDLE.bundle_attached.bundle_attached_count == 1 | ||
- ATTACH_BUNDLE.bundle_attached.bundle_attached_list != [] | ||
- ATTACH_BUNDLE.bundle_attached.success == true | ||
- ATTACH_BUNDLE.bundle_attached.taskIds != [] | ||
|
||
- name: Execute Task for attach_bundle | ||
arista.cvp.cv_task_v3: | ||
tasks: | ||
- "{{item}}" | ||
loop: "{{ATTACH_BUNDLE.taskIds}}" | ||
|
||
- name: Pause for 20 seconds to Execute Task | ||
ansible.builtin.pause: | ||
seconds: 20 | ||
|
||
- name: "Detach bundle on {{inventory_hostname}}" | ||
arista.cvp.cv_device_v3: | ||
devices: '{{CVP_DEVICES_BUNDLE_DETACHED}}' | ||
state: present | ||
apply_mode: strict | ||
register: DETACH_BUNDLE | ||
|
||
- name: "Check detach bundle" | ||
assert: | ||
that: | ||
- DETACH_BUNDLE.bundle_detached.changed == true | ||
- DETACH_BUNDLE.bundle_detached.bundle_detached_count == 1 | ||
- DETACH_BUNDLE.bundle_detached.bundle_detached_list != [] | ||
- DETACH_BUNDLE.bundle_detached.success == true | ||
|
||
- name: "Delete bundle {{inventory_hostname}}" | ||
arista.cvp.cv_image_v3: | ||
mode: bundle | ||
action: remove | ||
bundle_name: "{{BUNDLE_NAME}}" | ||
image_list: | ||
- "{{IMAGE_NAME}}" | ||
- "{{EXTENSION_NAME}}" | ||
|
||
- name: "Detach configlet from {{inventory_hostname}}" | ||
arista.cvp.cv_device_v3: | ||
devices: '{{CVP_DEVICES_DETACH_CONFIGLET}}' | ||
state: present | ||
apply_mode: strict | ||
register: DETACH_CONFIGLET | ||
|
||
- name: Execute Task for detach configlet | ||
arista.cvp.cv_task_v3: | ||
tasks: | ||
- "{{DETACH_CONFIGLET.taskIds[0]}}" | ||
|
||
- name: Pause for 20 seconds to Execute Task | ||
ansible.builtin.pause: | ||
seconds: 20 | ||
|
||
- name: "Delete configlet" | ||
arista.cvp.cv_configlet_v3: | ||
configlets: "{{CVP_CONFIGLETS}}" | ||
state: absent |
95 changes: 95 additions & 0 deletions
95
ansible_collections/arista/cvp/molecule/cv_device_v3/test_apply_detach_configlet.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
- name: Test cv_device_v3 | ||
hosts: CloudVision | ||
connection: local | ||
gather_facts: no | ||
vars: | ||
DEVICE_NAME: s1-leaf1 | ||
|
||
CVP_CONFIGLETS: | ||
configlet1: '! This is first configlet' | ||
configlet2: '! This is second configlet' | ||
|
||
CVP_DEVICES_APPLY_CONFIGLET: | ||
- fqdn: "{{DEVICE_NAME}}" | ||
parentContainerName: "{{CV_FACTS_V3_RESULT.data.cvp_devices[0].parentContainerName}}" | ||
configlets: | ||
- 'configlet1' | ||
- 'configlet2' | ||
|
||
CVP_DEVICES_DETACH_CONFIGLET: | ||
- fqdn: "{{DEVICE_NAME}}" | ||
parentContainerName: "{{CV_FACTS_V3_RESULT.data.cvp_devices[0].parentContainerName}}" | ||
configlets: "{{CV_FACTS_V3_RESULT.data.cvp_devices[0].configlets}}" | ||
|
||
tasks: | ||
- name: Collect devices facts from {{inventory_hostname}} | ||
arista.cvp.cv_facts_v3: | ||
facts: | ||
- devices | ||
regexp_filter: "{{DEVICE_NAME}}" | ||
register: CV_FACTS_V3_RESULT | ||
|
||
- name: "Push config" | ||
arista.cvp.cv_configlet_v3: | ||
configlets: "{{CVP_CONFIGLETS}}" | ||
state: present | ||
|
||
- name: "Apply configlet on {{inventory_hostname}}" | ||
arista.cvp.cv_device_v3: | ||
devices: '{{CVP_DEVICES_APPLY_CONFIGLET}}' | ||
state: present | ||
register: CV_DEVICE_V3_RESULT | ||
|
||
- name: "Check apply_configlet with apply_mode loose" | ||
assert: | ||
that: | ||
- CV_DEVICE_V3_RESULT.changed == true | ||
- CV_DEVICE_V3_RESULT.configlets_attached.changed == true | ||
- CV_DEVICE_V3_RESULT.configlets_attached.configlets_attached_count == 2 | ||
- CV_DEVICE_V3_RESULT.configlets_attached.configlets_attached_list == ["s1-leaf1_configlet_attached"] | ||
- CV_DEVICE_V3_RESULT.configlets_attached.success == true | ||
- CV_DEVICE_V3_RESULT.configlets_attached.taskIds != [] | ||
|
||
- name: "Apply same configlet again on {{inventory_hostname}}" | ||
arista.cvp.cv_device_v3: | ||
devices: '{{CVP_DEVICES_APPLY_CONFIGLET}}' | ||
state: present | ||
register: CV_DEVICE_V3_RESULT | ||
|
||
- name: "Check apply_configlet with same configlets" | ||
assert: | ||
that: | ||
- CV_DEVICE_V3_RESULT.changed == false | ||
- CV_DEVICE_V3_RESULT.configlets_attached.changed == false | ||
- CV_DEVICE_V3_RESULT.configlets_attached.configlets_attached_count == 0 | ||
- CV_DEVICE_V3_RESULT.configlets_attached.configlets_attached_list == [] | ||
- CV_DEVICE_V3_RESULT.configlets_attached.success == false | ||
- CV_DEVICE_V3_RESULT.configlets_attached.taskIds == [] | ||
|
||
- name: "Detach configlet from {{inventory_hostname}}" | ||
arista.cvp.cv_device_v3: | ||
devices: '{{CVP_DEVICES_DETACH_CONFIGLET}}' | ||
state: present | ||
apply_mode: strict | ||
register: CV_DEVICE_V3_RESULT | ||
|
||
- name: Execute Task for detach configlet | ||
arista.cvp.cv_task_v3: | ||
tasks: | ||
- "{{CV_DEVICE_V3_RESULT.taskIds[0]}}" | ||
|
||
- name: "Check detach_configlet with apply_mode strict" | ||
assert: | ||
that: | ||
- CV_DEVICE_V3_RESULT.changed == true | ||
- CV_DEVICE_V3_RESULT.configlets_detached.changed == true | ||
- CV_DEVICE_V3_RESULT.configlets_detached.configlets_detached_count == 2 | ||
- CV_DEVICE_V3_RESULT.configlets_detached.configlets_detached_list == ["s1-leaf1_configlet_removed - configlet1 - configlet2"] | ||
- CV_DEVICE_V3_RESULT.configlets_detached.success == true | ||
- CV_DEVICE_V3_RESULT.configlets_detached.taskIds != [] | ||
|
||
- name: "Delete config" | ||
arista.cvp.cv_configlet_v3: | ||
configlets: "{{CVP_CONFIGLETS}}" | ||
state: absent |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we testing push configlet here rather than in
test_apply_detach_configlets.yaml
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are not testing it here, just uploading it to be used while attaching/detaching bundle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it without configlets, removing configlet part.
Thanks!