roll up of bug fixs for nxos_evpn_global (#21961)

* updates nxos_evpn_global module
* adds integration test cases
* adds unit test cases
This commit is contained in:
Peter Sprygada
2017-02-26 06:45:26 -05:00
committed by GitHub
parent 06acf8ac2e
commit 0cb2019293
12 changed files with 260 additions and 120 deletions

View File

@@ -13,3 +13,4 @@
- { role: nxos_facts, when: "limit_to in ['*', 'nxos_facts']" }
- { role: nxos_template, when: "limit_to in ['*', 'nxos_template']" }
- { role: nxos_nxapi, when: "limit_to in ['*', 'nxos_nxapi']" }
- { role: nxos_evpn_global, when: "limit_to in ['*', 'nxos_evpn_global']" }

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,50 @@
---
- debug: msg="START cli/nv_overlay_evpn"
- name: setup
nxos_config:
lines: no nv overlay evpn
match: none
provider: "{{ cli }}"
- name: enable nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- name: verify nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: disable nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: no
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- name: verify nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: no
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- debug: msg="END cli/nv_overlay_evpn"

View File

@@ -0,0 +1,50 @@
---
- debug: msg="START nxapi/nv_overlay_evpn"
- name: setup
nxos_config:
lines: no nv overlay evpn
match: none
provider: "{{ nxapi }}"
- name: enable nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: yes
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == true"
- name: verify nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: yes
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- name: disable nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: no
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == true"
- name: verify nv overlay evpn
nxos_evpn_global:
nv_overlay_evpn: no
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
- debug: msg="END nxapi/nv_overlay_evpn"

View File

@@ -0,0 +1,3 @@
hostname switch01
nv overlay evpn

View File

@@ -0,0 +1 @@
hostname switch01

View File

@@ -0,0 +1,64 @@
#
# (c) 2016 Red Hat Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import json
from ansible.compat.tests.mock import patch
from ansible.modules.network.nxos import nxos_evpn_global
from .nxos_module import TestNxosModule, load_fixture, set_module_args
class TestNxosEvpnGlobalModule(TestNxosModule):
module = nxos_evpn_global
def setUp(self):
self.mock_get_config = patch('ansible.modules.network.nxos.nxos_evpn_global.get_config')
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch('ansible.modules.network.nxos.nxos_evpn_global.load_config')
self.load_config = self.mock_load_config.start()
def tearDown(self):
self.mock_get_config.stop()
self.mock_load_config.stop()
def load_fixtures(self, commands=None):
self.load_config.return_value = None
def start_configured(self, *args, **kwargs):
self.get_config.return_value = load_fixture('nxos_evpn_global/configured.cfg')
return self.execute_module(*args, **kwargs)
def start_unconfigured(self, *args, **kwargs):
self.get_config.return_value = load_fixture('nxos_evpn_global/unconfigured.cfg')
return self.execute_module(*args, **kwargs)
def test_nxos_evpn_global_enable(self):
set_module_args(dict(nv_overlay_evpn=True))
commands = ['nv overlay evpn']
self.start_unconfigured(changed=True, commands=commands)
def test_nxos_evpn_global_disable(self):
set_module_args(dict(nv_overlay_evpn=False))
commands = ['no nv overlay evpn']
self.start_configured(changed=True, commands=commands)