forked from cisco-en-programmability/dnacenter-ansible
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the integration tests for the configurating templates, exportin…
…g the templates and importing the templates (#70)
- Loading branch information
Showing
10 changed files
with
474 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
--- | ||
testcase: "*" |
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 @@ | ||
dependencies: [] |
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,34 @@ | ||
--- | ||
- name: collect ccc test cases | ||
find: | ||
paths: "{{ role_path }}/tests" | ||
patterns: "{{ testcase }}.yml" | ||
connection: local | ||
register: ccc_cases | ||
tags: sanity | ||
|
||
- debug: | ||
msg: "CCC Cases: {{ ccc_cases }}" | ||
|
||
- set_fact: | ||
test_cases: | ||
files: "{{ ccc_cases.files }}" | ||
tags: sanity | ||
|
||
- debug: | ||
msg: "Test Cases: {{ test_cases }}" | ||
|
||
- name: set test_items | ||
set_fact: | ||
test_items: "{{ test_cases.files | map(attribute='path') | list }}" | ||
tags: sanity | ||
|
||
- debug: | ||
msg: "Test Items: {{ test_items }}" | ||
|
||
- name: run test cases (connection=httpapi) | ||
include_tasks: "{{ test_case_to_run }}" | ||
loop: "{{ test_items }}" | ||
loop_control: | ||
loop_var: test_case_to_run | ||
tags: sanity |
35 changes: 35 additions & 0 deletions
35
...ration/ccc_template_management/tests/10.195.243.53_1.8.212_Tue Jul 02 2024_templates.json
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,35 @@ | ||
[ | ||
{ | ||
"name": "test_template", | ||
"tags": [], | ||
"author": "admin", | ||
"deviceTypes": [ | ||
{ | ||
"productFamily": "Switches and Hubs" | ||
} | ||
], | ||
"softwareType": "IOS", | ||
"softwareVariant": "XE", | ||
"templateContent": "hostname cat9k-1\\n", | ||
"templateParams": [], | ||
"rollbackTemplateParams": [], | ||
"composite": false, | ||
"containingTemplates": [], | ||
"language": "VELOCITY", | ||
"promotedTemplateContent": "hostname cat9k-1\\n", | ||
"promotedTemplateParams": [], | ||
"customParamsOrder": false, | ||
"createTime": 1719914895959, | ||
"lastUpdateTime": 1719914895959, | ||
"latestVersionTime": 1719914896486, | ||
"validationErrors": { | ||
"templateErrors": [], | ||
"rollbackTemplateErrors": [], | ||
"templateId": "10a9a332-44f8-419e-8274-45ad74a38e9b", | ||
"templateVersion": null | ||
}, | ||
"noOfConflicts": 0, | ||
"projectAssociated": true, | ||
"documentDatabase": false | ||
} | ||
] |
112 changes: 112 additions & 0 deletions
112
tests/integration/ccc_template_management/tests/test_export_template_and_project.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,112 @@ | ||
--- | ||
- debug: msg="Starting export template and project test" | ||
- debug: msg="Role Path {{ role_path }}" | ||
|
||
- block: | ||
- name: Load vars and declare dnac vars | ||
include_vars: | ||
file: "{{ role_path }}/vars/vars_export_template_and_project.yml" | ||
name: vars_map | ||
vars: | ||
dnac_login: &dnac_login | ||
dnac_host: "{{ dnac_host }}" | ||
dnac_username: "{{ dnac_username }}" | ||
dnac_password: "{{ dnac_password }}" | ||
dnac_verify: "{{ dnac_verify }}" | ||
dnac_port: "{{ dnac_port }}" | ||
dnac_version: "{{ dnac_version }}" | ||
dnac_debug: "{{ dnac_debug }}" | ||
dnac_log: true | ||
dnac_log_level: DEBUG | ||
config_verify: true | ||
|
||
# - debug: | ||
# msg: "{{ vars_map.create_template_details }}" | ||
|
||
# - debug: | ||
# msg: "{{ vars_map.export_project_details }}" | ||
|
||
# - debug: | ||
# msg: "{{ vars_map.export_template_details }}" | ||
|
||
############################################# | ||
# Pre Tests Clean Up # | ||
############################################# | ||
|
||
- name: Create template before test | ||
cisco.dnac.template_workflow_manager: | ||
<<: *dnac_login | ||
state: merged | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.template_details }}" | ||
|
||
############################################# | ||
# EXPORT PROJECT # | ||
############################################# | ||
|
||
- name: Export project from export_project_details | ||
cisco.dnac.template_workflow_manager: | ||
<<: *dnac_login | ||
state: merged | ||
config: | ||
- "{{ item }}" | ||
register: result_export_project | ||
loop: "{{ vars_map.export_project_details }}" | ||
tags: merged | ||
|
||
# - name: Debug item | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_export_project.results }}" | ||
# when: result_export_project is defined | ||
|
||
- name: Assert export of project | ||
assert: | ||
that: | ||
- item.changed == true | ||
loop: "{{ result_export_project.results }}" | ||
when: result_export_project is defined | ||
|
||
############################################# | ||
# EXPORT TEMPLATE # | ||
############################################# | ||
|
||
- name: Export template from export_template_details | ||
cisco.dnac.template_workflow_manager: | ||
<<: *dnac_login | ||
state: merged | ||
config: | ||
- "{{ item }}" | ||
register: result_export_template | ||
loop: "{{ vars_map.export_template_details }}" | ||
tags: merged | ||
|
||
# - name: Debug item | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_export_template.results }}" | ||
# when: result_export_template is defined | ||
|
||
- name: Assert export of template | ||
assert: | ||
that: | ||
- item.changed == true | ||
loop: "{{ result_export_template.results }}" | ||
when: result_export_template is defined | ||
|
||
############################################# | ||
# POST TEST CLEAN UP # | ||
############################################# | ||
|
||
# - name: Pause for 10 seconds after each updation | ||
# pause: | ||
# seconds: 10 | ||
|
||
- name: Delete template after test | ||
cisco.dnac.template_workflow_manager: | ||
<<: *dnac_login | ||
state: deleted | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.template_details }}" |
129 changes: 129 additions & 0 deletions
129
tests/integration/ccc_template_management/tests/test_import_template_and_project.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,129 @@ | ||
--- | ||
- debug: msg="Starting import template and project test" | ||
- debug: msg="Role Path {{ role_path }}" | ||
|
||
- block: | ||
- name: Load vars and declare dnac vars | ||
include_vars: | ||
file: "{{ role_path }}/vars/vars_import_template_and_project.yml" | ||
name: vars_map | ||
vars: | ||
dnac_login: &dnac_login | ||
dnac_host: "{{ dnac_host }}" | ||
dnac_username: "{{ dnac_username }}" | ||
dnac_password: "{{ dnac_password }}" | ||
dnac_verify: "{{ dnac_verify }}" | ||
dnac_port: "{{ dnac_port }}" | ||
dnac_version: "{{ dnac_version }}" | ||
dnac_debug: "{{ dnac_debug }}" | ||
dnac_log: true | ||
dnac_log_level: DEBUG | ||
config_verify: true | ||
|
||
# - debug: | ||
# msg: "{{ vars_map.template_details }}" | ||
|
||
# - debug: | ||
# msg: "{{ vars_map.project_details }}" | ||
|
||
# - debug: | ||
# msg: "{{ vars_map.import_template_details }}" | ||
|
||
# - debug: | ||
# msg: "{{ vars_map.import_project_details }}" | ||
|
||
############################################# | ||
# Pre Tests Clean Up # | ||
############################################# | ||
|
||
- name: Clean up template before test | ||
cisco.dnac.template_workflow_manager: | ||
<<: *dnac_login | ||
state: deleted | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.template_details }}" | ||
|
||
# - name: Clean up project before test | ||
# cisco.dnac.template_workflow_manager: | ||
# <<: *dnac_login | ||
# state: deleted | ||
# config: | ||
# - "{{ item }}" | ||
# loop: "{{ vars_map.project_details }}" | ||
|
||
# ############################################# | ||
# # IMPORT PROJECT # | ||
# ############################################# | ||
|
||
# - name: Import project from import_project_details | ||
# cisco.dnac.template_workflow_manager: | ||
# <<: *dnac_login | ||
# state: merged | ||
# config: | ||
# - "{{ item }}" | ||
# register: result_import_project | ||
# loop: "{{ vars_map.import_project_details }}" | ||
# tags: merged | ||
|
||
# # - name: Debug item | ||
# # debug: | ||
# # var: item | ||
# # loop: "{{ result_import_project.results }}" | ||
# # when: result_import_project is defined | ||
|
||
# - name: Assert import project | ||
# assert: | ||
# that: | ||
# - item.changed == true | ||
# - "'imported the project' in item.response[2].import.response.importProject" | ||
# loop: "{{ result_import_project.results }}" | ||
# when: result_import_project is defined | ||
|
||
############################################# | ||
# IMPORT TEMPLATE # | ||
############################################# | ||
|
||
- name: Import template from import_template_details | ||
cisco.dnac.template_workflow_manager: | ||
<<: *dnac_login | ||
state: merged | ||
config: | ||
- "{{ item }}" | ||
register: result_import_template | ||
loop: "{{ vars_map.import_template_details }}" | ||
tags: merged | ||
|
||
# - name: Debug item | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_import_template.results }}" | ||
# when: result_import_template is defined | ||
|
||
- name: Assert import template | ||
assert: | ||
that: | ||
- item.changed == true | ||
- "'imported the templates' in item.response[2].import.response.importTemplate" | ||
loop: "{{ result_import_template.results }}" | ||
when: result_import_template is defined | ||
|
||
############################################# | ||
# Pre Tests Clean Up # | ||
############################################# | ||
|
||
- name: Clean up template before test | ||
cisco.dnac.template_workflow_manager: | ||
<<: *dnac_login | ||
state: deleted | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.template_details }}" | ||
|
||
# - name: Clean up project before test | ||
# cisco.dnac.template_workflow_manager: | ||
# <<: *dnac_login | ||
# state: deleted | ||
# config: | ||
# - "{{ item }}" | ||
# loop: "{{ vars_map.project_details }}" |
Oops, something went wrong.