mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
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:
@@ -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']" }
|
||||
|
||||
2
test/integration/targets/nxos_evpn_global/meta/main.yml
Normal file
2
test/integration/targets/nxos_evpn_global/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_nxos_tests
|
||||
15
test/integration/targets/nxos_evpn_global/tasks/cli.yaml
Normal file
15
test/integration/targets/nxos_evpn_global/tasks/cli.yaml
Normal 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
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
||||
28
test/integration/targets/nxos_evpn_global/tasks/nxapi.yaml
Normal file
28
test/integration/targets/nxos_evpn_global/tasks/nxapi.yaml
Normal 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 }}"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -0,0 +1,3 @@
|
||||
hostname switch01
|
||||
nv overlay evpn
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
hostname switch01
|
||||
64
test/units/modules/network/nxos/test_nxos_evpn_global.py
Normal file
64
test/units/modules/network/nxos/test_nxos_evpn_global.py
Normal 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)
|
||||
|
||||
Reference in New Issue
Block a user