From 53c7f8cbdee3c798a6947b834d0640935155d85b Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 3 Feb 2020 08:04:08 -0500 Subject: Allow httpapi for EOS resource modules (#66871) * Redo tests to be transport agnostic cli -> eos config * Redirect connection for httpapi * Fix tests * Handle missing platform imports --- lib/ansible/module_utils/network/common/network.py | 25 +++++++++- lib/ansible/module_utils/network/eos/eos.py | 5 +- .../module_utils/network/eos/facts/legacy/base.py | 7 +++ .../module_utils/network/eos/facts/vlans/vlans.py | 3 +- lib/ansible/utils/jsonrpc.py | 2 +- .../targets/eos_interfaces/tasks/cli.yaml | 17 +++++++ .../targets/eos_interfaces/tasks/eapi.yaml | 17 +++++++ .../targets/eos_interfaces/tasks/main.yaml | 18 +------ .../targets/eos_interfaces/tests/cli/deleted.yaml | 43 ----------------- .../targets/eos_interfaces/tests/cli/merged.yaml | 53 --------------------- .../eos_interfaces/tests/cli/overridden.yaml | 41 ---------------- .../targets/eos_interfaces/tests/cli/replaced.yaml | 39 --------------- .../eos_interfaces/tests/cli/reset_config.yml | 35 -------------- .../eos_interfaces/tests/common/deleted.yaml | 43 +++++++++++++++++ .../eos_interfaces/tests/common/merged.yaml | 53 +++++++++++++++++++++ .../eos_interfaces/tests/common/overridden.yaml | 41 ++++++++++++++++ .../eos_interfaces/tests/common/replaced.yaml | 39 +++++++++++++++ .../eos_interfaces/tests/common/reset_config.yml | 35 ++++++++++++++ .../targets/eos_l2_interfaces/tasks/cli.yaml | 22 +++++++++ .../targets/eos_l2_interfaces/tasks/eapi.yaml | 22 +++++++++ .../targets/eos_l2_interfaces/tasks/main.yaml | 23 +-------- .../eos_l2_interfaces/tests/cli/cleanup.yml | 16 ------- .../eos_l2_interfaces/tests/cli/deleted.yaml | 37 --------------- .../eos_l2_interfaces/tests/cli/merged.yaml | 52 -------------------- .../eos_l2_interfaces/tests/cli/overridden.yaml | 38 --------------- .../eos_l2_interfaces/tests/cli/replaced.yaml | 41 ---------------- .../eos_l2_interfaces/tests/cli/reset_config.yml | 31 ------------ .../eos_l2_interfaces/tests/common/cleanup.yml | 16 +++++++ .../eos_l2_interfaces/tests/common/deleted.yaml | 37 +++++++++++++++ .../eos_l2_interfaces/tests/common/merged.yaml | 52 ++++++++++++++++++++ .../eos_l2_interfaces/tests/common/overridden.yaml | 38 +++++++++++++++ .../eos_l2_interfaces/tests/common/replaced.yaml | 41 ++++++++++++++++ .../tests/common/reset_config.yml | 31 ++++++++++++ .../targets/eos_l3_interfaces/tasks/cli.yaml | 17 +++++++ .../targets/eos_l3_interfaces/tasks/eapi.yaml | 17 +++++++ .../targets/eos_l3_interfaces/tasks/main.yaml | 18 +------ .../eos_l3_interfaces/tests/cli/deleted.yaml | 42 ----------------- .../eos_l3_interfaces/tests/cli/merged.yaml | 55 ---------------------- .../eos_l3_interfaces/tests/cli/overridden.yaml | 45 ------------------ .../eos_l3_interfaces/tests/cli/replaced.yaml | 48 ------------------- .../eos_l3_interfaces/tests/cli/reset_config.yml | 37 --------------- .../eos_l3_interfaces/tests/common/deleted.yaml | 42 +++++++++++++++++ .../eos_l3_interfaces/tests/common/merged.yaml | 55 ++++++++++++++++++++++ .../eos_l3_interfaces/tests/common/overridden.yaml | 45 ++++++++++++++++++ .../eos_l3_interfaces/tests/common/replaced.yaml | 48 +++++++++++++++++++ .../tests/common/reset_config.yml | 37 +++++++++++++++ .../targets/eos_lacp_interfaces/tasks/cli.yaml | 17 +++++++ .../targets/eos_lacp_interfaces/tasks/eapi.yaml | 17 +++++++ .../targets/eos_lacp_interfaces/tasks/main.yaml | 18 +------ .../eos_lacp_interfaces/tests/cli/deleted.yaml | 39 --------------- .../eos_lacp_interfaces/tests/cli/merged.yaml | 43 ----------------- .../eos_lacp_interfaces/tests/cli/overridden.yaml | 37 --------------- .../eos_lacp_interfaces/tests/cli/replaced.yaml | 41 ---------------- .../eos_lacp_interfaces/tests/cli/reset_config.yml | 26 ---------- .../eos_lacp_interfaces/tests/common/deleted.yaml | 39 +++++++++++++++ .../eos_lacp_interfaces/tests/common/merged.yaml | 43 +++++++++++++++++ .../tests/common/overridden.yaml | 37 +++++++++++++++ .../eos_lacp_interfaces/tests/common/replaced.yaml | 41 ++++++++++++++++ .../tests/common/reset_config.yml | 26 ++++++++++ .../targets/eos_lag_interfaces/tasks/cli.yaml | 17 +++++++ .../targets/eos_lag_interfaces/tasks/eapi.yaml | 17 +++++++ .../targets/eos_lag_interfaces/tasks/main.yaml | 18 +------ .../eos_lag_interfaces/tests/cli/deleted.yaml | 29 ------------ .../eos_lag_interfaces/tests/cli/merged.yaml | 45 ------------------ .../eos_lag_interfaces/tests/cli/overridden.yaml | 36 -------------- .../eos_lag_interfaces/tests/cli/replaced.yaml | 44 ----------------- .../eos_lag_interfaces/tests/cli/reset_config.yml | 25 ---------- .../eos_lag_interfaces/tests/common/deleted.yaml | 29 ++++++++++++ .../eos_lag_interfaces/tests/common/merged.yaml | 45 ++++++++++++++++++ .../tests/common/overridden.yaml | 36 ++++++++++++++ .../eos_lag_interfaces/tests/common/replaced.yaml | 44 +++++++++++++++++ .../tests/common/reset_config.yml | 25 ++++++++++ .../targets/eos_lldp_global/tasks/cli.yaml | 17 +++++++ .../targets/eos_lldp_global/tasks/eapi.yaml | 17 +++++++ .../targets/eos_lldp_global/tasks/main.yaml | 18 +------ .../targets/eos_lldp_global/tests/cli/deleted.yaml | 28 ----------- .../targets/eos_lldp_global/tests/cli/merged.yaml | 46 ------------------ .../eos_lldp_global/tests/cli/replaced.yaml | 44 ----------------- .../eos_lldp_global/tests/cli/reset_config.yml | 28 ----------- .../eos_lldp_global/tests/common/deleted.yaml | 28 +++++++++++ .../eos_lldp_global/tests/common/merged.yaml | 46 ++++++++++++++++++ .../eos_lldp_global/tests/common/replaced.yaml | 44 +++++++++++++++++ .../eos_lldp_global/tests/common/reset_config.yml | 28 +++++++++++ .../targets/eos_lldp_interfaces/tasks/cli.yaml | 17 +++++++ .../targets/eos_lldp_interfaces/tasks/eapi.yaml | 17 +++++++ .../targets/eos_lldp_interfaces/tasks/main.yaml | 18 +------ .../eos_lldp_interfaces/tests/cli/deleted.yaml | 36 -------------- .../eos_lldp_interfaces/tests/cli/merged.yaml | 44 ----------------- .../eos_lldp_interfaces/tests/cli/overridden.yaml | 34 ------------- .../eos_lldp_interfaces/tests/cli/replaced.yaml | 40 ---------------- .../eos_lldp_interfaces/tests/cli/reset_config.yml | 26 ---------- .../eos_lldp_interfaces/tests/common/deleted.yaml | 36 ++++++++++++++ .../eos_lldp_interfaces/tests/common/merged.yaml | 44 +++++++++++++++++ .../tests/common/overridden.yaml | 34 +++++++++++++ .../eos_lldp_interfaces/tests/common/replaced.yaml | 40 ++++++++++++++++ .../tests/common/reset_config.yml | 26 ++++++++++ test/integration/targets/eos_vlans/tasks/cli.yaml | 17 +++++++ test/integration/targets/eos_vlans/tasks/eapi.yaml | 17 +++++++ test/integration/targets/eos_vlans/tasks/main.yaml | 18 +------ .../targets/eos_vlans/tests/cli/deleted.yaml | 38 --------------- .../targets/eos_vlans/tests/cli/idempotent.yaml | 21 --------- .../targets/eos_vlans/tests/cli/merged.yaml | 42 ----------------- .../targets/eos_vlans/tests/cli/overridden.yaml | 39 --------------- .../targets/eos_vlans/tests/cli/replaced.yaml | 40 ---------------- .../targets/eos_vlans/tests/cli/reset_config.yml | 25 ---------- .../targets/eos_vlans/tests/common/deleted.yaml | 38 +++++++++++++++ .../targets/eos_vlans/tests/common/idempotent.yaml | 21 +++++++++ .../targets/eos_vlans/tests/common/merged.yaml | 42 +++++++++++++++++ .../targets/eos_vlans/tests/common/overridden.yaml | 39 +++++++++++++++ .../targets/eos_vlans/tests/common/replaced.yaml | 40 ++++++++++++++++ .../eos_vlans/tests/common/reset_config.yml | 30 ++++++++++++ 111 files changed, 1888 insertions(+), 1688 deletions(-) create mode 100644 test/integration/targets/eos_interfaces/tasks/cli.yaml create mode 100644 test/integration/targets/eos_interfaces/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_interfaces/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_interfaces/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_interfaces/tests/cli/overridden.yaml delete mode 100644 test/integration/targets/eos_interfaces/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_interfaces/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_interfaces/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_interfaces/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_interfaces/tests/common/overridden.yaml create mode 100644 test/integration/targets/eos_interfaces/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_interfaces/tests/common/reset_config.yml create mode 100644 test/integration/targets/eos_l2_interfaces/tasks/cli.yaml create mode 100644 test/integration/targets/eos_l2_interfaces/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_l2_interfaces/tests/cli/cleanup.yml delete mode 100644 test/integration/targets/eos_l2_interfaces/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_l2_interfaces/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_l2_interfaces/tests/cli/overridden.yaml delete mode 100644 test/integration/targets/eos_l2_interfaces/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_l2_interfaces/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_l2_interfaces/tests/common/cleanup.yml create mode 100644 test/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_l2_interfaces/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml create mode 100644 test/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_l2_interfaces/tests/common/reset_config.yml create mode 100644 test/integration/targets/eos_l3_interfaces/tasks/cli.yaml create mode 100644 test/integration/targets/eos_l3_interfaces/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_l3_interfaces/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_l3_interfaces/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_l3_interfaces/tests/cli/overridden.yaml delete mode 100644 test/integration/targets/eos_l3_interfaces/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_l3_interfaces/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_l3_interfaces/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml create mode 100644 test/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_l3_interfaces/tests/common/reset_config.yml create mode 100644 test/integration/targets/eos_lacp_interfaces/tasks/cli.yaml create mode 100644 test/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_lacp_interfaces/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_lacp_interfaces/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_lacp_interfaces/tests/cli/overridden.yaml delete mode 100644 test/integration/targets/eos_lacp_interfaces/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_lacp_interfaces/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml create mode 100644 test/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_lacp_interfaces/tests/common/reset_config.yml create mode 100644 test/integration/targets/eos_lag_interfaces/tasks/cli.yaml create mode 100644 test/integration/targets/eos_lag_interfaces/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml delete mode 100644 test/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_lag_interfaces/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_lag_interfaces/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_lag_interfaces/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_lag_interfaces/tests/common/overridden.yaml create mode 100644 test/integration/targets/eos_lag_interfaces/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_lag_interfaces/tests/common/reset_config.yml create mode 100644 test/integration/targets/eos_lldp_global/tasks/cli.yaml create mode 100644 test/integration/targets/eos_lldp_global/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_lldp_global/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_lldp_global/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_lldp_global/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_lldp_global/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_lldp_global/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_lldp_global/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_lldp_global/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_lldp_global/tests/common/reset_config.yml create mode 100644 test/integration/targets/eos_lldp_interfaces/tasks/cli.yaml create mode 100644 test/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_lldp_interfaces/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_lldp_interfaces/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_lldp_interfaces/tests/cli/overridden.yaml delete mode 100644 test/integration/targets/eos_lldp_interfaces/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_lldp_interfaces/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml create mode 100644 test/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_lldp_interfaces/tests/common/reset_config.yml create mode 100644 test/integration/targets/eos_vlans/tasks/cli.yaml create mode 100644 test/integration/targets/eos_vlans/tasks/eapi.yaml delete mode 100644 test/integration/targets/eos_vlans/tests/cli/deleted.yaml delete mode 100644 test/integration/targets/eos_vlans/tests/cli/idempotent.yaml delete mode 100644 test/integration/targets/eos_vlans/tests/cli/merged.yaml delete mode 100644 test/integration/targets/eos_vlans/tests/cli/overridden.yaml delete mode 100644 test/integration/targets/eos_vlans/tests/cli/replaced.yaml delete mode 100644 test/integration/targets/eos_vlans/tests/cli/reset_config.yml create mode 100644 test/integration/targets/eos_vlans/tests/common/deleted.yaml create mode 100644 test/integration/targets/eos_vlans/tests/common/idempotent.yaml create mode 100644 test/integration/targets/eos_vlans/tests/common/merged.yaml create mode 100644 test/integration/targets/eos_vlans/tests/common/overridden.yaml create mode 100644 test/integration/targets/eos_vlans/tests/common/replaced.yaml create mode 100644 test/integration/targets/eos_vlans/tests/common/reset_config.yml diff --git a/lib/ansible/module_utils/network/common/network.py b/lib/ansible/module_utils/network/common/network.py index e76d31e983..315a663762 100644 --- a/lib/ansible/module_utils/network/common/network.py +++ b/lib/ansible/module_utils/network/common/network.py @@ -30,12 +30,23 @@ import json from ansible.module_utils._text import to_text, to_native from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.basic import env_fallback +from ansible.module_utils.basic import env_fallback, missing_required_lib from ansible.module_utils.connection import Connection, ConnectionError from ansible.module_utils.network.common.netconf import NetconfConnection from ansible.module_utils.network.common.parsing import Cli from ansible.module_utils.six import iteritems +try: + from ansible.module_utils.network.eos import eos + HAS_EOS = True +except ImportError: + HAS_EOS = False + +try: + from ansible.module_utils.network.nxos import nxos + HAS_NXOS = True +except ImportError: + HAS_NXOS = False NET_TRANSPORT_ARGS = dict( host=dict(required=True), @@ -212,7 +223,17 @@ def get_resource_connection(module): capabilities = get_capabilities(module) network_api = capabilities.get('network_api') - if network_api in ('cliconf', 'nxapi', 'eapi', 'exosapi'): + if network_api == 'eapi': + if HAS_EOS: + module._connection = eos.get_connection(module) + else: + module.fail_json(msg=missing_required_lib("collection arista.eos")) + elif network_api == 'nxapi': + if HAS_NXOS: + module._connection = nxos.get_connection(module) + else: + module.fail_json(msg=missing_required_lib("collection cisco.nxos")) + elif network_api in ('cliconf', 'exosapi'): module._connection = Connection(module._socket_path) elif network_api == 'netconf': module._connection = NetconfConnection(module._socket_path) diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py index 22c675153e..6721c0e54c 100644 --- a/lib/ansible/module_utils/network/eos/eos.py +++ b/lib/ansible/module_utils/network/eos/eos.py @@ -418,6 +418,9 @@ class HttpApi: self._session_support = self._connection.supports_sessions() return self._session_support + def get(self, command, **kwargs): + return self._connection.send_request(command) + def run_commands(self, commands, check_rc=True): """Runs list of commands on remote device and returns results """ @@ -511,7 +514,7 @@ class HttpApi: """ return self.edit_config(config, commit, replace) - def edit_config(self, config, commit=False, replace=False): + def edit_config(self, config, commit=True, replace=False): """Loads the configuration onto the remote devices If the device doesn't support configuration sessions, this will diff --git a/lib/ansible/module_utils/network/eos/facts/legacy/base.py b/lib/ansible/module_utils/network/eos/facts/legacy/base.py index 50bb82e849..6093dedd09 100644 --- a/lib/ansible/module_utils/network/eos/facts/legacy/base.py +++ b/lib/ansible/module_utils/network/eos/facts/legacy/base.py @@ -130,6 +130,13 @@ class Interfaces(FactsBase): self.facts['all_ipv6_addresses'] = list() data = self.responses[0] + if not isinstance(data, dict): + # EAPI kills the whole request on an error. + self.COMMANDS.pop() + super(Interfaces, self).populate() + self.responses.append(None) + data = self.responses[0] + self.facts['interfaces'] = self.populate_interfaces(data) data = self.responses[1] diff --git a/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py b/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py index 0e01b6c216..63d21b169b 100644 --- a/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py +++ b/lib/ansible/module_utils/network/eos/facts/vlans/vlans.py @@ -63,8 +63,7 @@ class VlansFacts(object): if obj: objs.extend(obj) - ansible_facts['ansible_network_resources'].pop('vlans', None) - facts = {} + facts = {'vlans': []} if objs: params = utils.validate_config(self.argument_spec, {'config': objs}) facts['vlans'] = [utils.remove_empties(cfg) for cfg in params['config']] diff --git a/lib/ansible/utils/jsonrpc.py b/lib/ansible/utils/jsonrpc.py index e48c979d4c..0a97c61054 100644 --- a/lib/ansible/utils/jsonrpc.py +++ b/lib/ansible/utils/jsonrpc.py @@ -39,7 +39,7 @@ class JsonRpcServer(object): break if not rpc_method: - error = self.method_not_found() + error = self.method_not_found(rpc_method) response = json.dumps(error) else: try: diff --git a/test/integration/targets/eos_interfaces/tasks/cli.yaml b/test/integration/targets/eos_interfaces/tasks/cli.yaml new file mode 100644 index 0000000000..475fe83154 --- /dev/null +++ b/test/integration/targets/eos_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_interfaces/tasks/eapi.yaml new file mode 100644 index 0000000000..34ce8f6347 --- /dev/null +++ b/test/integration/targets/eos_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_interfaces/tasks/main.yaml b/test/integration/targets/eos_interfaces/tasks/main.yaml index 068963b4c3..970e74171e 100644 --- a/test/integration/targets/eos_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index b447fb6b72..0000000000 --- a/test/integration/targets/eos_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,43 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- name: Returns interfaces to default parameters - eos_interfaces: - config: "{{ config }}" - state: deleted - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" - -- set_fact: - expected_config: - - name: Ethernet1 - duplex: auto - enabled: True - - name: Ethernet2 - duplex: auto - enabled: True - mtu: "3000" - -- assert: - that: - - "expected_config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_interfaces/tests/cli/merged.yaml deleted file mode 100644 index 8030f09d58..0000000000 --- a/test/integration/targets/eos_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,53 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - enabled: True - - name: Ethernet2 - description: 'Configured by Ansible' - speed: '10' - duplex: full - enabled: False - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- name: Merge provided configuration with device configuration - eos_interfaces: - config: "{{ config }}" - state: merged - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" - -- set_fact: - expected_config: - - name: Ethernet1 - description: Interface 1 - speed: 40g - duplex: full - enabled: True - - name: Ethernet2 - description: 'Configured by Ansible' - speed: '10' - duplex: full - enabled: False - mtu: "3000" - -- assert: - that: - - "expected_config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index b1b1777bfe..0000000000 --- a/test/integration/targets/eos_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - duplex: auto - enabled: true - - name: Ethernet2 - duplex: auto - description: 'Configured by Ansible' - enabled: false - - name: Management1 - enabled: true - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- name: Overrides device configuration of all interfaces with provided configuration - eos_interfaces: - config: "{{ config }}" - state: overridden - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" - -- assert: - that: - - "config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index ab9fd6fd2e..0000000000 --- a/test/integration/targets/eos_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - duplex: auto - enabled: True - - name: Ethernet2 - description: 'Configured by Ansible' - duplex: auto - enabled: False - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- name: Replaces device configuration of listed interfaces with provided configuration - eos_interfaces: - config: "{{ config }}" - state: replaced - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" - -- assert: - that: - - "config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_interfaces/tests/cli/reset_config.yml deleted file mode 100644 index 0613582955..0000000000 --- a/test/integration/targets/eos_interfaces/tests/cli/reset_config.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- name: Reset initial config - cli_config: - config: | - interface Ethernet1 - description "Interface 1" - no shutdown - no mtu - speed forced 40gfull - interface Ethernet2 - no description - no shutdown - mtu 3000 - speed auto - become: yes - -- eos_facts: - gather_network_resources: interfaces - become: yes - -- set_fact: - expected_config: - - name: Ethernet1 - description: Interface 1 - speed: 40g - duplex: full - enabled: True - - name: Ethernet2 - enabled: True - mtu: "3000" - duplex: auto - -- assert: - that: - - "expected_config|difference(ansible_facts.network_resources.interfaces) == []" diff --git a/test/integration/targets/eos_interfaces/tests/common/deleted.yaml b/test/integration/targets/eos_interfaces/tests/common/deleted.yaml new file mode 100644 index 0000000000..b447fb6b72 --- /dev/null +++ b/test/integration/targets/eos_interfaces/tests/common/deleted.yaml @@ -0,0 +1,43 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- name: Returns interfaces to default parameters + eos_interfaces: + config: "{{ config }}" + state: deleted + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" + +- set_fact: + expected_config: + - name: Ethernet1 + duplex: auto + enabled: True + - name: Ethernet2 + duplex: auto + enabled: True + mtu: "3000" + +- assert: + that: + - "expected_config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/common/merged.yaml b/test/integration/targets/eos_interfaces/tests/common/merged.yaml new file mode 100644 index 0000000000..8030f09d58 --- /dev/null +++ b/test/integration/targets/eos_interfaces/tests/common/merged.yaml @@ -0,0 +1,53 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + enabled: True + - name: Ethernet2 + description: 'Configured by Ansible' + speed: '10' + duplex: full + enabled: False + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- name: Merge provided configuration with device configuration + eos_interfaces: + config: "{{ config }}" + state: merged + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" + +- set_fact: + expected_config: + - name: Ethernet1 + description: Interface 1 + speed: 40g + duplex: full + enabled: True + - name: Ethernet2 + description: 'Configured by Ansible' + speed: '10' + duplex: full + enabled: False + mtu: "3000" + +- assert: + that: + - "expected_config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/common/overridden.yaml b/test/integration/targets/eos_interfaces/tests/common/overridden.yaml new file mode 100644 index 0000000000..b1b1777bfe --- /dev/null +++ b/test/integration/targets/eos_interfaces/tests/common/overridden.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + duplex: auto + enabled: true + - name: Ethernet2 + duplex: auto + description: 'Configured by Ansible' + enabled: false + - name: Management1 + enabled: true + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- name: Overrides device configuration of all interfaces with provided configuration + eos_interfaces: + config: "{{ config }}" + state: overridden + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" + +- assert: + that: + - "config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/common/replaced.yaml b/test/integration/targets/eos_interfaces/tests/common/replaced.yaml new file mode 100644 index 0000000000..ab9fd6fd2e --- /dev/null +++ b/test/integration/targets/eos_interfaces/tests/common/replaced.yaml @@ -0,0 +1,39 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + duplex: auto + enabled: True + - name: Ethernet2 + description: 'Configured by Ansible' + duplex: auto + enabled: False + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- name: Replaces device configuration of listed interfaces with provided configuration + eos_interfaces: + config: "{{ config }}" + state: replaced + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.interfaces|symmetric_difference(result.after)|length == 0" + +- assert: + that: + - "config|difference(ansible_facts.network_resources.interfaces)|length == 0" diff --git a/test/integration/targets/eos_interfaces/tests/common/reset_config.yml b/test/integration/targets/eos_interfaces/tests/common/reset_config.yml new file mode 100644 index 0000000000..7932f9f948 --- /dev/null +++ b/test/integration/targets/eos_interfaces/tests/common/reset_config.yml @@ -0,0 +1,35 @@ +--- +- name: Reset initial config + eos_config: + lines: | + interface Ethernet1 + description "Interface 1" + no shutdown + no mtu + speed forced 40gfull + interface Ethernet2 + no description + no shutdown + mtu 3000 + speed auto + become: yes + +- eos_facts: + gather_network_resources: interfaces + become: yes + +- set_fact: + expected_config: + - name: Ethernet1 + description: Interface 1 + speed: 40g + duplex: full + enabled: True + - name: Ethernet2 + enabled: True + mtu: "3000" + duplex: auto + +- assert: + that: + - "expected_config|difference(ansible_facts.network_resources.interfaces) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tasks/cli.yaml b/test/integration/targets/eos_l2_interfaces/tasks/cli.yaml new file mode 100644 index 0000000000..92c7271ce9 --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- block: + - name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli + + always: + - name: Clean up test state + include: "{{ role_path }}/tests/common/cleanup.yml ansible_connection=network_cli" diff --git a/test/integration/targets/eos_l2_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_l2_interfaces/tasks/eapi.yaml new file mode 100644 index 0000000000..f67b3d7214 --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tasks/eapi.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- block: + - name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi + + always: + - name: Clean up test state + include: "{{ role_path }}/tests/common/cleanup.yml ansible_connection=httpapi" diff --git a/test/integration/targets/eos_l2_interfaces/tasks/main.yaml b/test/integration/targets/eos_l2_interfaces/tasks/main.yaml index 35abc8e876..970e74171e 100644 --- a/test/integration/targets/eos_l2_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_l2_interfaces/tasks/main.yaml @@ -1,22 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- block: - - name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli - - always: - - name: Clean up test state - include: "{{ role_path }}/tests/cli/cleanup.yml ansible_connection=network_cli" +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/cleanup.yml b/test/integration/targets/eos_l2_interfaces/tests/cli/cleanup.yml deleted file mode 100644 index d71a6a9db4..0000000000 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/cleanup.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: Remove all vlans - cli_config: - config: no vlan 1-4094 - become: yes - -- name: Completely remove vlans from interfaces - cli_config: - config: | - interface {{ item }} - no switchport mode - no switchport access vlan - with_items: - - Ethernet1 - - Ethernet2 - become: yes diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_l2_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index 6bc0099e29..0000000000 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - - name: Ethernet2 - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- name: Delete EOS L2 interfaces as in given arguments. - eos_l2_interfaces: - config: "{{ config }}" - state: deleted - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }} + [{'name': 'Management1'}]" - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_l2_interfaces/tests/cli/merged.yaml deleted file mode 100644 index f49994401a..0000000000 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - trunk: - native_vlan: 10 - - name: Ethernet2 - access: - vlan: 30 - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- name: Merge provided configuration with device configuration - eos_l2_interfaces: - config: "{{ config }}" - state: merged - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: - - name: Ethernet1 - access: - vlan: 20 - trunk: - native_vlan: 10 - - name: Ethernet2 - access: - vlan: 30 - trunk: - native_vlan: 20 - - name: Management1 - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_l2_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index 8fe7f45990..0000000000 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet2 - access: - vlan: 30 - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- name: Override device configuration of all L2 interfaces on device with provided configuration. - eos_l2_interfaces: - config: "{{ config }}" - state: overridden - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }} + [{'name': 'Ethernet1'}, {'name': 'Management1'}]" - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_l2_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index 46c7a2dd07..0000000000 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - trunk: - native_vlan: 20 - trunk_allowed_vlans: - - 5-10 - - "15" - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- name: Replace device configuration of specified L2 interfaces with provided configuration. - eos_l2_interfaces: - config: "{{ config }}" - state: replaced - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }} + [{'name': 'Ethernet2', 'trunk': {'native_vlan': 20}}, {'name': 'Management1'}]" - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_l2_interfaces/tests/cli/reset_config.yml deleted file mode 100644 index f4474ce1b7..0000000000 --- a/test/integration/targets/eos_l2_interfaces/tests/cli/reset_config.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- name: Reset state - cli_config: - config: | - interface Ethernet1 - switchport access vlan 20 - no switchport trunk native vlan - no switchport trunk allowed vlan - interface Ethernet2 - no switchport access vlan - switchport trunk native vlan 20 - switchport mode trunk - become: yes - -- eos_facts: - gather_network_resources: l2_interfaces - become: yes - -- set_fact: - expected_config: - - name: Ethernet1 - access: - vlan: 20 - - name: Ethernet2 - trunk: - native_vlan: 20 - - name: Management1 - -- assert: - that: - - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/common/cleanup.yml b/test/integration/targets/eos_l2_interfaces/tests/common/cleanup.yml new file mode 100644 index 0000000000..7a6f44dd04 --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tests/common/cleanup.yml @@ -0,0 +1,16 @@ +--- +- name: Remove all vlans + eos_config: + lines: no vlan 1-4094 + become: yes + +- name: Completely remove vlans from interfaces + eos_config: + lines: | + interface {{ item }} + no switchport mode + no switchport access vlan + with_items: + - Ethernet1 + - Ethernet2 + become: yes diff --git a/test/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml new file mode 100644 index 0000000000..6bc0099e29 --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tests/common/deleted.yaml @@ -0,0 +1,37 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + - name: Ethernet2 + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- name: Delete EOS L2 interfaces as in given arguments. + eos_l2_interfaces: + config: "{{ config }}" + state: deleted + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }} + [{'name': 'Management1'}]" + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/common/merged.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/merged.yaml new file mode 100644 index 0000000000..f49994401a --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tests/common/merged.yaml @@ -0,0 +1,52 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + trunk: + native_vlan: 10 + - name: Ethernet2 + access: + vlan: 30 + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- name: Merge provided configuration with device configuration + eos_l2_interfaces: + config: "{{ config }}" + state: merged + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: + - name: Ethernet1 + access: + vlan: 20 + trunk: + native_vlan: 10 + - name: Ethernet2 + access: + vlan: 30 + trunk: + native_vlan: 20 + - name: Management1 + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml new file mode 100644 index 0000000000..8fe7f45990 --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tests/common/overridden.yaml @@ -0,0 +1,38 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet2 + access: + vlan: 30 + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- name: Override device configuration of all L2 interfaces on device with provided configuration. + eos_l2_interfaces: + config: "{{ config }}" + state: overridden + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }} + [{'name': 'Ethernet1'}, {'name': 'Management1'}]" + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml b/test/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml new file mode 100644 index 0000000000..46c7a2dd07 --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tests/common/replaced.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + trunk: + native_vlan: 20 + trunk_allowed_vlans: + - 5-10 + - "15" + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- name: Replace device configuration of specified L2 interfaces with provided configuration. + eos_l2_interfaces: + config: "{{ config }}" + state: replaced + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }} + [{'name': 'Ethernet2', 'trunk': {'native_vlan': 20}}, {'name': 'Management1'}]" + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l2_interfaces/tests/common/reset_config.yml b/test/integration/targets/eos_l2_interfaces/tests/common/reset_config.yml new file mode 100644 index 0000000000..cc43075cfd --- /dev/null +++ b/test/integration/targets/eos_l2_interfaces/tests/common/reset_config.yml @@ -0,0 +1,31 @@ +--- +- name: Reset state + eos_config: + lines: | + interface Ethernet1 + switchport access vlan 20 + no switchport trunk native vlan + no switchport trunk allowed vlan + interface Ethernet2 + no switchport access vlan + switchport trunk native vlan 20 + switchport mode trunk + become: yes + +- eos_facts: + gather_network_resources: l2_interfaces + become: yes + +- set_fact: + expected_config: + - name: Ethernet1 + access: + vlan: 20 + - name: Ethernet2 + trunk: + native_vlan: 20 + - name: Management1 + +- assert: + that: + - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tasks/cli.yaml b/test/integration/targets/eos_l3_interfaces/tasks/cli.yaml new file mode 100644 index 0000000000..475fe83154 --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_l3_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_l3_interfaces/tasks/eapi.yaml new file mode 100644 index 0000000000..acddad170e --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_l3_interfaces/tasks/main.yaml b/test/integration/targets/eos_l3_interfaces/tasks/main.yaml index 82d196e4ed..970e74171e 100644 --- a/test/integration/targets/eos_l3_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_l3_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - register: test_cases - delegate_to: localhost - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_l3_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index 43483358f6..0000000000 --- a/test/integration/targets/eos_l3_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - - name: Ethernet2 - other_config: - - name: Management1 - ipv4: - - address: dhcp - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- name: Delete EOS L3 interfaces as in given arguments. - eos_l3_interfaces: - config: "{{ config }}" - state: deleted - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" - become: yes - -- set_fact: - expected_config: "{{ config }} + {{ other_config }}" - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_l3_interfaces/tests/cli/merged.yaml deleted file mode 100644 index dd36fd371d..0000000000 --- a/test/integration/targets/eos_l3_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,55 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - ipv4: - - address: 198.51.100.14/24 - - name: Ethernet2 - ipv4: - - address: 203.0.113.227/31 - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- name: Merge provided configuration with device configuration. - eos_l3_interfaces: - config: "{{ config }}" - state: merged - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" - become: yes - -- set_fact: - expected_config: - - name: Ethernet1 - ipv4: - - address: 198.51.100.14/24 - - address: 203.0.113.27/31 - secondary: true - - name: Ethernet2 - ipv4: - - address: 203.0.113.227/31 - ipv6: - - address: 2001:db8::1/64 - - name: Management1 - ipv4: - - address: dhcp - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_l3_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index d7c7b97e7d..0000000000 --- a/test/integration/targets/eos_l3_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,45 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - ipv6: - - address: 2001:db8:feed::1/96 - - name: Ethernet2 - ipv6: - - address: 2001:db8::1/64 - - name: Management1 - ipv4: - - address: dhcp - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- name: Override device configuration of all L3 interfaces on device with provided configuration. - eos_l3_interfaces: - config: "{{ config }}" - state: overridden - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" - become: yes - -- set_fact: - expected_config: "{{ config }}" - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_l3_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index f1f84ab2a5..0000000000 --- a/test/integration/targets/eos_l3_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet2 - ipv4: - - address: 203.0.113.205/31 - other_config: - - name: Ethernet1 - ipv4: - - address: 192.0.2.12/24 - - address: 203.0.113.27/31 - secondary: true - - name: Management1 - ipv4: - - address: dhcp - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- name: Replace device configuration of specified L3 interfaces with provided configuration. - eos_l3_interfaces: - config: "{{ config }}" - state: replaced - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" - become: yes - -- set_fact: - expected_config: "{{ config }} + {{ other_config }}" - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_l3_interfaces/tests/cli/reset_config.yml deleted file mode 100644 index 3efc086a4b..0000000000 --- a/test/integration/targets/eos_l3_interfaces/tests/cli/reset_config.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: Reset state - cli_config: - config: | - interface Ethernet1 - ip address 192.0.2.12/24 - ip address 203.0.113.27/31 secondary - no ipv6 address - interface Ethernet2 - no ip address - ipv6 address 2001:db8::1/64 - interface Management1 - ip address dhcp - no ipv6 address - become: yes - -- eos_facts: - gather_network_resources: l3_interfaces - become: yes - -- set_fact: - expected_config: - - name: Ethernet1 - ipv4: - - address: 192.0.2.12/24 - - address: 203.0.113.27/31 - secondary: true - - name: Ethernet2 - ipv6: - - address: 2001:db8::1/64 - - name: Management1 - ipv4: - - address: dhcp - -- assert: - that: - - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml new file mode 100644 index 0000000000..43483358f6 --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tests/common/deleted.yaml @@ -0,0 +1,42 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + - name: Ethernet2 + other_config: + - name: Management1 + ipv4: + - address: dhcp + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- name: Delete EOS L3 interfaces as in given arguments. + eos_l3_interfaces: + config: "{{ config }}" + state: deleted + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" + become: yes + +- set_fact: + expected_config: "{{ config }} + {{ other_config }}" + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/common/merged.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/merged.yaml new file mode 100644 index 0000000000..dd36fd371d --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tests/common/merged.yaml @@ -0,0 +1,55 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + ipv4: + - address: 198.51.100.14/24 + - name: Ethernet2 + ipv4: + - address: 203.0.113.227/31 + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- name: Merge provided configuration with device configuration. + eos_l3_interfaces: + config: "{{ config }}" + state: merged + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" + become: yes + +- set_fact: + expected_config: + - name: Ethernet1 + ipv4: + - address: 198.51.100.14/24 + - address: 203.0.113.27/31 + secondary: true + - name: Ethernet2 + ipv4: + - address: 203.0.113.227/31 + ipv6: + - address: 2001:db8::1/64 + - name: Management1 + ipv4: + - address: dhcp + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml new file mode 100644 index 0000000000..d7c7b97e7d --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tests/common/overridden.yaml @@ -0,0 +1,45 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + ipv6: + - address: 2001:db8:feed::1/96 + - name: Ethernet2 + ipv6: + - address: 2001:db8::1/64 + - name: Management1 + ipv4: + - address: dhcp + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- name: Override device configuration of all L3 interfaces on device with provided configuration. + eos_l3_interfaces: + config: "{{ config }}" + state: overridden + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" + become: yes + +- set_fact: + expected_config: "{{ config }}" + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml b/test/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml new file mode 100644 index 0000000000..f1f84ab2a5 --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tests/common/replaced.yaml @@ -0,0 +1,48 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet2 + ipv4: + - address: 203.0.113.205/31 + other_config: + - name: Ethernet1 + ipv4: + - address: 192.0.2.12/24 + - address: 203.0.113.27/31 + secondary: true + - name: Management1 + ipv4: + - address: dhcp + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- name: Replace device configuration of specified L3 interfaces with provided configuration. + eos_l3_interfaces: + config: "{{ config }}" + state: replaced + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []" + become: yes + +- set_fact: + expected_config: "{{ config }} + {{ other_config }}" + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_l3_interfaces/tests/common/reset_config.yml b/test/integration/targets/eos_l3_interfaces/tests/common/reset_config.yml new file mode 100644 index 0000000000..f74d1f521c --- /dev/null +++ b/test/integration/targets/eos_l3_interfaces/tests/common/reset_config.yml @@ -0,0 +1,37 @@ +--- +- name: Reset state + eos_config: + lines: | + interface Ethernet1 + ip address 192.0.2.12/24 + ip address 203.0.113.27/31 secondary + no ipv6 address + interface Ethernet2 + no ip address + ipv6 address 2001:db8::1/64 + interface Management1 + ip address dhcp + no ipv6 address + become: yes + +- eos_facts: + gather_network_resources: l3_interfaces + become: yes + +- set_fact: + expected_config: + - name: Ethernet1 + ipv4: + - address: 192.0.2.12/24 + - address: 203.0.113.27/31 + secondary: true + - name: Ethernet2 + ipv6: + - address: 2001:db8::1/64 + - name: Management1 + ipv4: + - address: dhcp + +- assert: + that: + - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tasks/cli.yaml b/test/integration/targets/eos_lacp_interfaces/tasks/cli.yaml new file mode 100644 index 0000000000..475fe83154 --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml new file mode 100644 index 0000000000..34ce8f6347 --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml b/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml index 068963b4c3..970e74171e 100644 --- a/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_lacp_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_lacp_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index ceed51e75b..0000000000 --- a/test/integration/targets/eos_lacp_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - other_config: - - name: Ethernet2 - rate: fast - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- name: Returns vlans to default parameters - eos_lacp_interfaces: - config: "{{ config }}" - state: deleted - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ other_config }}" - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_lacp_interfaces/tests/cli/merged.yaml deleted file mode 100644 index 8f3a4eadff..0000000000 --- a/test/integration/targets/eos_lacp_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,43 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - rate: fast - - name: Ethernet2 - rate: normal - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- name: Merge provided configuration with device configuration - eos_lacp_interfaces: - config: "{{ config }}" - state: merged - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: - - name: Ethernet1 - port_priority: 30 - rate: fast - - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_lacp_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index b858a822dc..0000000000 --- a/test/integration/targets/eos_lacp_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - rate: fast - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- name: Overrides device configuration of all vlans with provided configuration - eos_lacp_interfaces: - config: "{{ config }}" - state: overridden - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }}" - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_lacp_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index f33b32fd15..0000000000 --- a/test/integration/targets/eos_lacp_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - rate: fast - port_priority: 45 - other_config: - - name: Ethernet2 - rate: fast - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- name: Replaces device configuration of listed vlans with provided configuration - eos_lacp_interfaces: - config: "{{ config }}" - state: replaced - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }} + {{ other_config }}" - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_lacp_interfaces/tests/cli/reset_config.yml deleted file mode 100644 index 45caea1f4a..0000000000 --- a/test/integration/targets/eos_lacp_interfaces/tests/cli/reset_config.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- name: Reset initial config - cli_config: - config: | - interface Ethernet1 - lacp port-priority 30 - lacp rate normal - interface Ethernet2 - no lacp port-priority - lacp rate fast - become: yes - -- eos_facts: - gather_network_resources: lacp_interfaces - become: yes - -- set_fact: - expected_config: - - name: Ethernet1 - port_priority: 30 - - name: Ethernet2 - rate: fast - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml new file mode 100644 index 0000000000..ceed51e75b --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tests/common/deleted.yaml @@ -0,0 +1,39 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + other_config: + - name: Ethernet2 + rate: fast + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- name: Returns vlans to default parameters + eos_lacp_interfaces: + config: "{{ config }}" + state: deleted + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ other_config }}" + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml new file mode 100644 index 0000000000..8f3a4eadff --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tests/common/merged.yaml @@ -0,0 +1,43 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + rate: fast + - name: Ethernet2 + rate: normal + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- name: Merge provided configuration with device configuration + eos_lacp_interfaces: + config: "{{ config }}" + state: merged + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: + - name: Ethernet1 + port_priority: 30 + rate: fast + + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml new file mode 100644 index 0000000000..b858a822dc --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tests/common/overridden.yaml @@ -0,0 +1,37 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + rate: fast + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- name: Overrides device configuration of all vlans with provided configuration + eos_lacp_interfaces: + config: "{{ config }}" + state: overridden + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }}" + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml b/test/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml new file mode 100644 index 0000000000..f33b32fd15 --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tests/common/replaced.yaml @@ -0,0 +1,41 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + rate: fast + port_priority: 45 + other_config: + - name: Ethernet2 + rate: fast + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- name: Replaces device configuration of listed vlans with provided configuration + eos_lacp_interfaces: + config: "{{ config }}" + state: replaced + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lacp_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }} + {{ other_config }}" + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lacp_interfaces/tests/common/reset_config.yml b/test/integration/targets/eos_lacp_interfaces/tests/common/reset_config.yml new file mode 100644 index 0000000000..b4e6851365 --- /dev/null +++ b/test/integration/targets/eos_lacp_interfaces/tests/common/reset_config.yml @@ -0,0 +1,26 @@ +--- +- name: Reset initial config + eos_config: + lines: | + interface Ethernet1 + lacp port-priority 30 + lacp rate normal + interface Ethernet2 + no lacp port-priority + lacp rate fast + become: yes + +- eos_facts: + gather_network_resources: lacp_interfaces + become: yes + +- set_fact: + expected_config: + - name: Ethernet1 + port_priority: 30 + - name: Ethernet2 + rate: fast + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lacp_interfaces) == []" diff --git a/test/integration/targets/eos_lag_interfaces/tasks/cli.yaml b/test/integration/targets/eos_lag_interfaces/tasks/cli.yaml new file mode 100644 index 0000000000..475fe83154 --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lag_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_lag_interfaces/tasks/eapi.yaml new file mode 100644 index 0000000000..34ce8f6347 --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lag_interfaces/tasks/main.yaml b/test/integration/targets/eos_lag_interfaces/tasks/main.yaml index 82d196e4ed..970e74171e 100644 --- a/test/integration/targets/eos_lag_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_lag_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - register: test_cases - delegate_to: localhost - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index dbf63d64bf..0000000000 --- a/test/integration/targets/eos_lag_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: "Port-Channel5" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- name: Delete EOS L3 interfaces as in given arguments. - eos_lag_interfaces: - config: "{{ config }}" - state: deleted - become: yes - register: result - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces == []" diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml deleted file mode 100644 index 2399cc73e1..0000000000 --- a/test/integration/targets/eos_lag_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,45 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: "Port-Channel5" - members: - - member: Ethernet2 - mode: "on" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- name: Merge provided configuration with device configuration. - eos_lag_interfaces: - config: "{{ config }}" - state: merged - become: yes - register: result - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length == 0" - -- set_fact: - expected_config: - - name: "Port-Channel5" - members: - - member: Ethernet1 - mode: "on" - - member: Ethernet2 - mode: "on" - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length == 0" diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index e62d3f335b..0000000000 --- a/test/integration/targets/eos_lag_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: "Port-Channel10" - members: - - member: Ethernet2 - mode: "on" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- name: Override device configuration of all LAGs on device with provided configuration. - eos_lag_interfaces: - config: "{{ config }}" - state: overridden - become: yes - register: result - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length == 0" - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(config)|length == 0" diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index f1e8a255f8..0000000000 --- a/test/integration/targets/eos_lag_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: "Port-Channel10" - members: - - member: Ethernet2 - mode: "on" - other_config: - - name: "Port-Channel5" - members: - - member: Ethernet1 - mode: "on" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- name: Replace device configuration of specified LAGs with provided configuration. - eos_lag_interfaces: - config: "{{ config }}" - state: replaced - become: yes - register: result - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length == 0" - -- set_fact: - expected_config: "{{ config }} + {{ other_config }}" - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length == 0" diff --git a/test/integration/targets/eos_lag_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_lag_interfaces/tests/cli/reset_config.yml deleted file mode 100644 index ba7cf513a2..0000000000 --- a/test/integration/targets/eos_lag_interfaces/tests/cli/reset_config.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- name: Reset state - cli_config: - config: | - interface Ethernet1 - channel-group 5 mode on - interface Ethernet2 - no channel-group - no interface Port-Channel10 - become: yes - -- eos_facts: - gather_network_resources: lag_interfaces - become: yes - -- set_fact: - expected_config: - - name: "Port-Channel5" - members: - - member: Ethernet1 - mode: "on" - -- assert: - that: - - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length == 0" diff --git a/test/integration/targets/eos_lag_interfaces/tests/common/deleted.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/deleted.yaml new file mode 100644 index 0000000000..dbf63d64bf --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tests/common/deleted.yaml @@ -0,0 +1,29 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: "Port-Channel5" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- name: Delete EOS L3 interfaces as in given arguments. + eos_lag_interfaces: + config: "{{ config }}" + state: deleted + become: yes + register: result + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces == []" diff --git a/test/integration/targets/eos_lag_interfaces/tests/common/merged.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/merged.yaml new file mode 100644 index 0000000000..2399cc73e1 --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tests/common/merged.yaml @@ -0,0 +1,45 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: "Port-Channel5" + members: + - member: Ethernet2 + mode: "on" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- name: Merge provided configuration with device configuration. + eos_lag_interfaces: + config: "{{ config }}" + state: merged + become: yes + register: result + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length == 0" + +- set_fact: + expected_config: + - name: "Port-Channel5" + members: + - member: Ethernet1 + mode: "on" + - member: Ethernet2 + mode: "on" + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length == 0" diff --git a/test/integration/targets/eos_lag_interfaces/tests/common/overridden.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/overridden.yaml new file mode 100644 index 0000000000..e62d3f335b --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tests/common/overridden.yaml @@ -0,0 +1,36 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: "Port-Channel10" + members: + - member: Ethernet2 + mode: "on" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- name: Override device configuration of all LAGs on device with provided configuration. + eos_lag_interfaces: + config: "{{ config }}" + state: overridden + become: yes + register: result + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length == 0" + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(config)|length == 0" diff --git a/test/integration/targets/eos_lag_interfaces/tests/common/replaced.yaml b/test/integration/targets/eos_lag_interfaces/tests/common/replaced.yaml new file mode 100644 index 0000000000..f1e8a255f8 --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tests/common/replaced.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: "Port-Channel10" + members: + - member: Ethernet2 + mode: "on" + other_config: + - name: "Port-Channel5" + members: + - member: Ethernet1 + mode: "on" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- name: Replace device configuration of specified LAGs with provided configuration. + eos_lag_interfaces: + config: "{{ config }}" + state: replaced + become: yes + register: result + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.before)|length == 0" + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(result.after)|length == 0" + +- set_fact: + expected_config: "{{ config }} + {{ other_config }}" + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length == 0" diff --git a/test/integration/targets/eos_lag_interfaces/tests/common/reset_config.yml b/test/integration/targets/eos_lag_interfaces/tests/common/reset_config.yml new file mode 100644 index 0000000000..31ef209866 --- /dev/null +++ b/test/integration/targets/eos_lag_interfaces/tests/common/reset_config.yml @@ -0,0 +1,25 @@ +--- +- name: Reset state + eos_config: + lines: | + interface Ethernet1 + channel-group 5 mode on + interface Ethernet2 + no channel-group + no interface Port-Channel10 + become: yes + +- eos_facts: + gather_network_resources: lag_interfaces + become: yes + +- set_fact: + expected_config: + - name: "Port-Channel5" + members: + - member: Ethernet1 + mode: "on" + +- assert: + that: + - "ansible_facts.network_resources.lag_interfaces|symmetric_difference(expected_config)|length == 0" diff --git a/test/integration/targets/eos_lldp_global/tasks/cli.yaml b/test/integration/targets/eos_lldp_global/tasks/cli.yaml new file mode 100644 index 0000000000..475fe83154 --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lldp_global/tasks/eapi.yaml b/test/integration/targets/eos_lldp_global/tasks/eapi.yaml new file mode 100644 index 0000000000..34ce8f6347 --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lldp_global/tasks/main.yaml b/test/integration/targets/eos_lldp_global/tasks/main.yaml index 068963b4c3..970e74171e 100644 --- a/test/integration/targets/eos_lldp_global/tasks/main.yaml +++ b/test/integration/targets/eos_lldp_global/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lldp_global/tests/cli/deleted.yaml b/test/integration/targets/eos_lldp_global/tests/cli/deleted.yaml deleted file mode 100644 index 98233e1a1e..0000000000 --- a/test/integration/targets/eos_lldp_global/tests/cli/deleted.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- eos_facts: - gather_network_resources: lldp_global - become: yes - -- name: Returns LLDP configuration to default parameters - eos_lldp_global: - state: deleted - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == result.before" - -- eos_facts: - gather_network_resources: lldp_global - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == result.after" - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == {}" diff --git a/test/integration/targets/eos_lldp_global/tests/cli/merged.yaml b/test/integration/targets/eos_lldp_global/tests/cli/merged.yaml deleted file mode 100644 index 7cbc16f41d..0000000000 --- a/test/integration/targets/eos_lldp_global/tests/cli/merged.yaml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - holdtime: 100 - tlv_select: - management_address: False - port_description: False - system_description: True - -- eos_facts: - gather_network_resources: lldp_global - become: yes - -- name: Merge provided LLDP configuration with device configuration - eos_lldp_global: - config: "{{ config }}" - state: merged - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == result.before" - -- eos_facts: - gather_network_resources: lldp_global - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == result.after" - -- set_fact: - expected_config: - timer: 3000 - holdtime: 100 - reinit: 5 - tlv_select: - management_address: False - port_description: False - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == expected_config" diff --git a/test/integration/targets/eos_lldp_global/tests/cli/replaced.yaml b/test/integration/targets/eos_lldp_global/tests/cli/replaced.yaml deleted file mode 100644 index f8cbcd13cc..0000000000 --- a/test/integration/targets/eos_lldp_global/tests/cli/replaced.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - holdtime: 100 - tlv_select: - management_address: False - port_description: False - system_description: True - -- eos_facts: - gather_network_resources: lldp_global - become: yes - -- name: Replaces device configuration with provided LLDP configuration - eos_lldp_global: - config: "{{ config }}" - state: replaced - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == result.before" - -- eos_facts: - gather_network_resources: lldp_global - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == result.after" - -- set_fact: - expected_config: - holdtime: 100 - tlv_select: - management_address: False - port_description: False - -- assert: - that: - - "ansible_facts.network_resources.lldp_global == expected_config" diff --git a/test/integration/targets/eos_lldp_global/tests/cli/reset_config.yml b/test/integration/targets/eos_lldp_global/tests/cli/reset_config.yml deleted file mode 100644 index 4e5fd33746..0000000000 --- a/test/integration/targets/eos_lldp_global/tests/cli/reset_config.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Reset initial config - cli_config: - config: | - lldp timer 3000 - lldp holdtime 100 - lldp reinit 5 - no lldp tlv-select management-address - no lldp tlv-select system-description - lldp tlv-select port-description - become: yes - -- eos_facts: - gather_network_resources: lldp_global - become: yes - -- set_fact: - expected_config: - timer: 3000 - holdtime: 100 - reinit: 5 - tlv_select: - management_address: False - system_description: False - -- assert: - that: - - "expected_config == ansible_facts.network_resources.lldp_global" diff --git a/test/integration/targets/eos_lldp_global/tests/common/deleted.yaml b/test/integration/targets/eos_lldp_global/tests/common/deleted.yaml new file mode 100644 index 0000000000..98233e1a1e --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tests/common/deleted.yaml @@ -0,0 +1,28 @@ +--- +- include_tasks: reset_config.yml + +- eos_facts: + gather_network_resources: lldp_global + become: yes + +- name: Returns LLDP configuration to default parameters + eos_lldp_global: + state: deleted + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == result.before" + +- eos_facts: + gather_network_resources: lldp_global + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == result.after" + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == {}" diff --git a/test/integration/targets/eos_lldp_global/tests/common/merged.yaml b/test/integration/targets/eos_lldp_global/tests/common/merged.yaml new file mode 100644 index 0000000000..7cbc16f41d --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tests/common/merged.yaml @@ -0,0 +1,46 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: False + port_description: False + system_description: True + +- eos_facts: + gather_network_resources: lldp_global + become: yes + +- name: Merge provided LLDP configuration with device configuration + eos_lldp_global: + config: "{{ config }}" + state: merged + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == result.before" + +- eos_facts: + gather_network_resources: lldp_global + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == result.after" + +- set_fact: + expected_config: + timer: 3000 + holdtime: 100 + reinit: 5 + tlv_select: + management_address: False + port_description: False + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == expected_config" diff --git a/test/integration/targets/eos_lldp_global/tests/common/replaced.yaml b/test/integration/targets/eos_lldp_global/tests/common/replaced.yaml new file mode 100644 index 0000000000..f8cbcd13cc --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tests/common/replaced.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + holdtime: 100 + tlv_select: + management_address: False + port_description: False + system_description: True + +- eos_facts: + gather_network_resources: lldp_global + become: yes + +- name: Replaces device configuration with provided LLDP configuration + eos_lldp_global: + config: "{{ config }}" + state: replaced + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == result.before" + +- eos_facts: + gather_network_resources: lldp_global + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == result.after" + +- set_fact: + expected_config: + holdtime: 100 + tlv_select: + management_address: False + port_description: False + +- assert: + that: + - "ansible_facts.network_resources.lldp_global == expected_config" diff --git a/test/integration/targets/eos_lldp_global/tests/common/reset_config.yml b/test/integration/targets/eos_lldp_global/tests/common/reset_config.yml new file mode 100644 index 0000000000..441edf3891 --- /dev/null +++ b/test/integration/targets/eos_lldp_global/tests/common/reset_config.yml @@ -0,0 +1,28 @@ +--- +- name: Reset initial config + eos_config: + lines: | + lldp timer 3000 + lldp holdtime 100 + lldp reinit 5 + no lldp tlv-select management-address + no lldp tlv-select system-description + lldp tlv-select port-description + become: yes + +- eos_facts: + gather_network_resources: lldp_global + become: yes + +- set_fact: + expected_config: + timer: 3000 + holdtime: 100 + reinit: 5 + tlv_select: + management_address: False + system_description: False + +- assert: + that: + - "expected_config == ansible_facts.network_resources.lldp_global" diff --git a/test/integration/targets/eos_lldp_interfaces/tasks/cli.yaml b/test/integration/targets/eos_lldp_interfaces/tasks/cli.yaml new file mode 100644 index 0000000000..475fe83154 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml b/test/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml new file mode 100644 index 0000000000..34ce8f6347 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml b/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml index 068963b4c3..970e74171e 100644 --- a/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml +++ b/test/integration/targets/eos_lldp_interfaces/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/deleted.yaml b/test/integration/targets/eos_lldp_interfaces/tests/cli/deleted.yaml deleted file mode 100644 index b3f94f93da..0000000000 --- a/test/integration/targets/eos_lldp_interfaces/tests/cli/deleted.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - expected_config: - - name: Ethernet2 - transmit: False - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- name: Returns interface lldp parameterss to default parameters - eos_lldp_interfaces: - config: "{{ config }}" - state: deleted - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces == expected_config" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/merged.yaml b/test/integration/targets/eos_lldp_interfaces/tests/cli/merged.yaml deleted file mode 100644 index 4d56ca50a6..0000000000 --- a/test/integration/targets/eos_lldp_interfaces/tests/cli/merged.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - transmit: False - - name: Ethernet2 - transmit: False - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- name: Merge provided configuration with device configuration - eos_lldp_interfaces: - config: "{{ config }}" - state: merged - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: - - name: Ethernet1 - transmit: False - receive: False - - name: Ethernet2 - transmit: False - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/overridden.yaml b/test/integration/targets/eos_lldp_interfaces/tests/cli/overridden.yaml deleted file mode 100644 index 82ad0beb89..0000000000 --- a/test/integration/targets/eos_lldp_interfaces/tests/cli/overridden.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - transmit: False - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- name: Override the LLDP configuration of all interfaces with provided configuration - eos_lldp_interfaces: - config: "{{ config }}" - state: overridden - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" - -- assert: - that: - - "config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/replaced.yaml b/test/integration/targets/eos_lldp_interfaces/tests/cli/replaced.yaml deleted file mode 100644 index 56f3d34580..0000000000 --- a/test/integration/targets/eos_lldp_interfaces/tests/cli/replaced.yaml +++ /dev/null @@ -1,40 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - name: Ethernet1 - transmit: False - other_config: - - name: Ethernet2 - transmit: False - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- name: Replace existing LLDP configuration of specified interfaces with provided configuration - eos_lldp_interfaces: - config: "{{ config }}" - state: replaced - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- assert: - that: - - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }} + {{ other_config }}" - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/cli/reset_config.yml b/test/integration/targets/eos_lldp_interfaces/tests/cli/reset_config.yml deleted file mode 100644 index 99688d8478..0000000000 --- a/test/integration/targets/eos_lldp_interfaces/tests/cli/reset_config.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- name: Reset initial config - cli_config: - config: | - interface Ethernet1 - no lldp receive - lldp transmit - interface Ethernet2 - lldp receive - no lldp transmit - become: yes - -- eos_facts: - gather_network_resources: lldp_interfaces - become: yes - -- set_fact: - expected_config: - - name: Ethernet1 - receive: False - - name: Ethernet2 - transmit: False - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml new file mode 100644 index 0000000000..b3f94f93da --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tests/common/deleted.yaml @@ -0,0 +1,36 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + expected_config: + - name: Ethernet2 + transmit: False + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- name: Returns interface lldp parameterss to default parameters + eos_lldp_interfaces: + config: "{{ config }}" + state: deleted + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces == expected_config" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml new file mode 100644 index 0000000000..4d56ca50a6 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tests/common/merged.yaml @@ -0,0 +1,44 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + transmit: False + - name: Ethernet2 + transmit: False + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- name: Merge provided configuration with device configuration + eos_lldp_interfaces: + config: "{{ config }}" + state: merged + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: + - name: Ethernet1 + transmit: False + receive: False + - name: Ethernet2 + transmit: False + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml new file mode 100644 index 0000000000..82ad0beb89 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tests/common/overridden.yaml @@ -0,0 +1,34 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + transmit: False + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- name: Override the LLDP configuration of all interfaces with provided configuration + eos_lldp_interfaces: + config: "{{ config }}" + state: overridden + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" + +- assert: + that: + - "config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml b/test/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml new file mode 100644 index 0000000000..56f3d34580 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tests/common/replaced.yaml @@ -0,0 +1,40 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - name: Ethernet1 + transmit: False + other_config: + - name: Ethernet2 + transmit: False + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- name: Replace existing LLDP configuration of specified interfaces with provided configuration + eos_lldp_interfaces: + config: "{{ config }}" + state: replaced + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- assert: + that: + - "ansible_facts.network_resources.lldp_interfaces|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }} + {{ other_config }}" + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_lldp_interfaces/tests/common/reset_config.yml b/test/integration/targets/eos_lldp_interfaces/tests/common/reset_config.yml new file mode 100644 index 0000000000..c2085aef61 --- /dev/null +++ b/test/integration/targets/eos_lldp_interfaces/tests/common/reset_config.yml @@ -0,0 +1,26 @@ +--- +- name: Reset initial config + eos_config: + lines: | + interface Ethernet1 + no lldp receive + lldp transmit + interface Ethernet2 + lldp receive + no lldp transmit + become: yes + +- eos_facts: + gather_network_resources: lldp_interfaces + become: yes + +- set_fact: + expected_config: + - name: Ethernet1 + receive: False + - name: Ethernet2 + transmit: False + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.lldp_interfaces) == []" diff --git a/test/integration/targets/eos_vlans/tasks/cli.yaml b/test/integration/targets/eos_vlans/tasks/cli.yaml new file mode 100644 index 0000000000..475fe83154 --- /dev/null +++ b/test/integration/targets/eos_vlans/tasks/cli.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_network_cli diff --git a/test/integration/targets/eos_vlans/tasks/eapi.yaml b/test/integration/targets/eos_vlans/tasks/eapi.yaml new file mode 100644 index 0000000000..34ce8f6347 --- /dev/null +++ b/test/integration/targets/eos_vlans/tasks/eapi.yaml @@ -0,0 +1,17 @@ +--- +- name: collect all eapi test cases + find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + delegate_to: localhost + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test cases (connection=httpapi) + include: "{{ test_case_to_run }} ansible_connection=httpapi" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + tags: connection_httpapi diff --git a/test/integration/targets/eos_vlans/tasks/main.yaml b/test/integration/targets/eos_vlans/tasks/main.yaml index 068963b4c3..970e74171e 100644 --- a/test/integration/targets/eos_vlans/tasks/main.yaml +++ b/test/integration/targets/eos_vlans/tasks/main.yaml @@ -1,17 +1,3 @@ --- -- name: collect all cli test cases - find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - -- name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: connection_network_cli +- { include: cli.yaml, tags: ['cli'] } +- { include: eapi.yaml, tags: ['eapi'] } diff --git a/test/integration/targets/eos_vlans/tests/cli/deleted.yaml b/test/integration/targets/eos_vlans/tests/cli/deleted.yaml deleted file mode 100644 index 6cd5130428..0000000000 --- a/test/integration/targets/eos_vlans/tests/cli/deleted.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - vlan_id: 20 - -- eos_facts: - gather_network_resources: vlans - become: yes - -- name: Returns vlans to default parameters - eos_vlans: - config: "{{ config }}" - state: deleted - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: vlans - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: - - vlan_id: 10 - name: ten - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/cli/idempotent.yaml b/test/integration/targets/eos_vlans/tests/cli/idempotent.yaml deleted file mode 100644 index d88e318ba9..0000000000 --- a/test/integration/targets/eos_vlans/tests/cli/idempotent.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- eos_facts: - gather_network_resources: vlans - become: yes - -- name: Ensures that facts are idempotent through replace - eos_vlans: - config: "{{ ansible_facts.network_resources.vlans }}" - state: replaced - register: result - become: yes - -- eos_facts: - gather_network_resources: vlans - become: yes - -- assert: - that: - - "result.changed == False" - - "result.commands == []" - - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" diff --git a/test/integration/targets/eos_vlans/tests/cli/merged.yaml b/test/integration/targets/eos_vlans/tests/cli/merged.yaml deleted file mode 100644 index 5ad3f08597..0000000000 --- a/test/integration/targets/eos_vlans/tests/cli/merged.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - vlan_id: 20 - state: suspend - -- eos_facts: - gather_network_resources: vlans - become: yes - -- name: Merge provided configuration with device configuration - eos_vlans: - config: "{{ config }}" - state: merged - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: vlans - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: - - vlan_id: 10 - name: ten - - vlan_id: 20 - name: twenty - state: suspend - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/cli/overridden.yaml b/test/integration/targets/eos_vlans/tests/cli/overridden.yaml deleted file mode 100644 index ea406b6b47..0000000000 --- a/test/integration/targets/eos_vlans/tests/cli/overridden.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - vlan_id: 20 - state: suspend - - vlan_id: 50 - name: fifty - -- eos_facts: - gather_network_resources: vlans - become: yes - -- name: Overrides device configuration of all vlans with provided configuration - eos_vlans: - config: "{{ config }}" - state: overridden - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: vlans - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }}" - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/cli/replaced.yaml b/test/integration/targets/eos_vlans/tests/cli/replaced.yaml deleted file mode 100644 index ca502ff156..0000000000 --- a/test/integration/targets/eos_vlans/tests/cli/replaced.yaml +++ /dev/null @@ -1,40 +0,0 @@ ---- -- include_tasks: reset_config.yml - -- set_fact: - config: - - vlan_id: 20 - state: suspend - other_config: - - vlan_id: 10 - name: ten - -- eos_facts: - gather_network_resources: vlans - become: yes - -- name: Replaces device configuration of listed vlans with provided configuration - eos_vlans: - config: "{{ config }}" - state: replaced - register: result - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" - -- eos_facts: - gather_network_resources: vlans - become: yes - -- assert: - that: - - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" - -- set_fact: - expected_config: "{{ config }} + {{ other_config }}" - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/cli/reset_config.yml b/test/integration/targets/eos_vlans/tests/cli/reset_config.yml deleted file mode 100644 index 513a1199b1..0000000000 --- a/test/integration/targets/eos_vlans/tests/cli/reset_config.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- name: Reset initial config - cli_config: - config: | - no vlan 1-4094 - vlan 10 - name ten - vlan 20 - name twenty - become: yes - -- eos_facts: - gather_network_resources: vlans - become: yes - -- set_fact: - expected_config: - - vlan_id: 10 - name: ten - - vlan_id: 20 - name: twenty - -- assert: - that: - - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/common/deleted.yaml b/test/integration/targets/eos_vlans/tests/common/deleted.yaml new file mode 100644 index 0000000000..6cd5130428 --- /dev/null +++ b/test/integration/targets/eos_vlans/tests/common/deleted.yaml @@ -0,0 +1,38 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - vlan_id: 20 + +- eos_facts: + gather_network_resources: vlans + become: yes + +- name: Returns vlans to default parameters + eos_vlans: + config: "{{ config }}" + state: deleted + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: vlans + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: + - vlan_id: 10 + name: ten + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/common/idempotent.yaml b/test/integration/targets/eos_vlans/tests/common/idempotent.yaml new file mode 100644 index 0000000000..d88e318ba9 --- /dev/null +++ b/test/integration/targets/eos_vlans/tests/common/idempotent.yaml @@ -0,0 +1,21 @@ +--- +- eos_facts: + gather_network_resources: vlans + become: yes + +- name: Ensures that facts are idempotent through replace + eos_vlans: + config: "{{ ansible_facts.network_resources.vlans }}" + state: replaced + register: result + become: yes + +- eos_facts: + gather_network_resources: vlans + become: yes + +- assert: + that: + - "result.changed == False" + - "result.commands == []" + - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" diff --git a/test/integration/targets/eos_vlans/tests/common/merged.yaml b/test/integration/targets/eos_vlans/tests/common/merged.yaml new file mode 100644 index 0000000000..5ad3f08597 --- /dev/null +++ b/test/integration/targets/eos_vlans/tests/common/merged.yaml @@ -0,0 +1,42 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - vlan_id: 20 + state: suspend + +- eos_facts: + gather_network_resources: vlans + become: yes + +- name: Merge provided configuration with device configuration + eos_vlans: + config: "{{ config }}" + state: merged + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: vlans + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: + - vlan_id: 10 + name: ten + - vlan_id: 20 + name: twenty + state: suspend + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/common/overridden.yaml b/test/integration/targets/eos_vlans/tests/common/overridden.yaml new file mode 100644 index 0000000000..ea406b6b47 --- /dev/null +++ b/test/integration/targets/eos_vlans/tests/common/overridden.yaml @@ -0,0 +1,39 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - vlan_id: 20 + state: suspend + - vlan_id: 50 + name: fifty + +- eos_facts: + gather_network_resources: vlans + become: yes + +- name: Overrides device configuration of all vlans with provided configuration + eos_vlans: + config: "{{ config }}" + state: overridden + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: vlans + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }}" + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/common/replaced.yaml b/test/integration/targets/eos_vlans/tests/common/replaced.yaml new file mode 100644 index 0000000000..ca502ff156 --- /dev/null +++ b/test/integration/targets/eos_vlans/tests/common/replaced.yaml @@ -0,0 +1,40 @@ +--- +- include_tasks: reset_config.yml + +- set_fact: + config: + - vlan_id: 20 + state: suspend + other_config: + - vlan_id: 10 + name: ten + +- eos_facts: + gather_network_resources: vlans + become: yes + +- name: Replaces device configuration of listed vlans with provided configuration + eos_vlans: + config: "{{ config }}" + state: replaced + register: result + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []" + +- eos_facts: + gather_network_resources: vlans + become: yes + +- assert: + that: + - "ansible_facts.network_resources.vlans|symmetric_difference(result.after) == []" + +- set_fact: + expected_config: "{{ config }} + {{ other_config }}" + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" diff --git a/test/integration/targets/eos_vlans/tests/common/reset_config.yml b/test/integration/targets/eos_vlans/tests/common/reset_config.yml new file mode 100644 index 0000000000..38736d88b5 --- /dev/null +++ b/test/integration/targets/eos_vlans/tests/common/reset_config.yml @@ -0,0 +1,30 @@ +--- +- name: Reset initial config + eos_config: + before: + no vlan 1-4094 + defaults: yes + match: exact + lines: | + vlan 10 + name ten + state active + vlan 20 + name twenty + state active + become: yes + +- eos_facts: + gather_network_resources: vlans + become: yes + +- set_fact: + expected_config: + - vlan_id: 10 + name: ten + - vlan_id: 20 + name: twenty + +- assert: + that: + - "expected_config|symmetric_difference(ansible_facts.network_resources.vlans) == []" -- cgit v1.2.1