nxos_vxlan_vtep fixes and integration tests (#27405)

* fix issue 27404

* conflict resolve
This commit is contained in:
saichint 2017-07-31 05:37:31 -07:00 committed by Nathaniel Case
parent 97aaf103e8
commit 350018de73
10 changed files with 136 additions and 8 deletions

View file

@ -150,7 +150,7 @@ def get_value(arg, config, module):
value = ''
if arg == 'description':
if NO_DESC_REGEX.search(config):
value = ''
value = False
elif PARAM_TO_COMMAND_KEYMAP[arg] in config:
value = REGEX.search(config).group('value').strip()
elif arg == 'source_interface':
@ -169,7 +169,7 @@ def get_value(arg, config, module):
def get_existing(module, args):
existing = {}
netcfg = CustomNetworkConfig(indent=2, contents=get_config(module))
netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=['all']))
interface_string = 'interface {0}'.format(module.params['interface'].lower())
parents = [interface_string]
@ -294,18 +294,14 @@ def main():
proposed = {}
for key, value in proposed_args.items():
if key != 'interface':
if str(value).lower() == 'true':
value = True
elif str(value).lower() == 'false':
value = False
elif str(value).lower() == 'default':
if str(value).lower() == 'default':
value = PARAM_TO_DEFAULT_KEYMAP.get(key)
if value is None:
if key in BOOL_PARAMS:
value = False
else:
value = 'default'
if existing.get(key) != value:
if str(existing.get(key)).lower() != str(value).lower():
proposed[key] = value
candidate = CustomNetworkConfig(indent=3)

View file

@ -213,6 +213,15 @@
failed_modules: "{{ failed_modules }} + [ 'nxos_portchannel' ]"
test_failed: true
- block:
- include_role:
name: nxos_vxlan_vtep
when: "limit_to in ['*', 'nxos_vxlan_vtep']"
rescue:
- set_fact:
failed_modules: "{{ failed_modules }} + [ 'nxos_vxlan_vtep' ]"
test_failed: true
- block:
- include_role:
name: nxos_logging

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_nxos_tests

View file

@ -0,0 +1,15 @@
---
- name: collect all cli test cases
find:
paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: nxapi.yaml, tags: ['nxapi'] }

View file

@ -0,0 +1,28 @@
---
- name: collect all nxapi test cases
find:
paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: enable nxapi
nxos_config:
lines:
- feature nxapi
- nxapi http port 80
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable nxapi
nxos_config:
lines:
- no feature nxapi
provider: "{{ cli }}"

View file

@ -0,0 +1,4 @@
---
- set_fact: connection="{{ cli }}"
- import_tasks: targets/nxos_vxlan_vtep/tests/common/sanity.yaml

View file

@ -0,0 +1,65 @@
---
- - debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vxlan_vtep sanity test"
- block:
- name: "Enable feature nv overlay"
nxos_config:
commands:
- feature nv overlay
provider: "{{ connection }}"
match: none
- name: configure vxlan_vtep
nxos_vxlan_vtep: &configure
interface: nve1
description: default
host_reachability: true
source_interface: Loopback0
source_interface_hold_down_time: 30
shutdown: true
provider: "{{ connection }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Conf Idempotence"
nxos_vxlan_vtep: *configure
register: result
- assert: &false
that:
- "result.changed == false"
- name: remove vxlan_vtep
nxos_vxlan_vtep: &remove
interface: nve1
description: default
host_reachability: true
source_interface: Loopback0
source_interface_hold_down_time: 30
shutdown: true
state: absent
provider: "{{ connection }}"
register: result
- assert: *true
- name: "Remove Idempotence"
nxos_vxlan_vtep: *remove
register: result
- assert: *false
when: (platform | search('N9K'))
always:
- name: "Disable feature nv overlay"
nxos_feature:
feature: nve
state: disabled
provider: "{{ connection }}"
ignore_errors: yes
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vxlan_vtep sanity test"

View file

@ -0,0 +1,4 @@
---
- set_fact: connection="{{ nxapi }}"
- import_tasks: targets/nxos_vxlan_vtep/tests/common/sanity.yaml