From 3ede6d7c8ce373bc1785b2c2bff66a269f8ebb11 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Wed, 6 Jun 2018 18:04:36 +0530 Subject: [PATCH] add interface_split and interface_range filter plugin tests (#92) Signed-off-by: Trishna Guha --- .../interface_range/meta/main.yaml | 3 ++ .../tasks/interface_range.yaml | 34 +++++++++++++++++++ .../interface_range/tasks/main.yaml | 3 ++ tests/interface_range/test.yml | 4 +++ .../interface_split/meta/main.yaml | 3 ++ .../tasks/interface_split.yaml | 27 +++++++++++++++ .../interface_split/tasks/main.yaml | 3 ++ tests/interface_split/test.yml | 4 +++ tests/test.yml | 2 ++ 9 files changed, 83 insertions(+) create mode 100644 tests/interface_range/interface_range/meta/main.yaml create mode 100644 tests/interface_range/interface_range/tasks/interface_range.yaml create mode 100644 tests/interface_range/interface_range/tasks/main.yaml create mode 100644 tests/interface_range/test.yml create mode 100644 tests/interface_split/interface_split/meta/main.yaml create mode 100644 tests/interface_split/interface_split/tasks/interface_split.yaml create mode 100644 tests/interface_split/interface_split/tasks/main.yaml create mode 100644 tests/interface_split/test.yml diff --git a/tests/interface_range/interface_range/meta/main.yaml b/tests/interface_range/interface_range/meta/main.yaml new file mode 100644 index 0000000..d64f158 --- /dev/null +++ b/tests/interface_range/interface_range/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - ../../../network-engine diff --git a/tests/interface_range/interface_range/tasks/interface_range.yaml b/tests/interface_range/interface_range/tasks/interface_range.yaml new file mode 100644 index 0000000..46f94cf --- /dev/null +++ b/tests/interface_range/interface_range/tasks/interface_range.yaml @@ -0,0 +1,34 @@ +- name: interface_range Ethernet1-3 + debug: + msg: "{{ 'Ethernet1-3' | interface_range }}" + register: result + +- assert: + that: + - "'Ethernet1' in result.msg" + - "'Ethernet2' in result.msg" + - "'Ethernet3' in result.msg" + +- name: interface_range Ethernet1,3-4,5 + debug: + msg: "{{ 'Ethernet1,3-4,5' | interface_range }}" + register: result + +- assert: + that: + - "'Ethernet1' in result.msg" + - "'Ethernet3' in result.msg" + - "'Ethernet4' in result.msg" + - "'Ethernet5' in result.msg" + +- name: interface_range Ethernet1/3-5,8 + debug: + msg: "{{ 'Ethernet1/3-5,8' | interface_range }}" + register: result + +- assert: + that: + - "'Ethernet1/3' in result.msg" + - "'Ethernet1/4' in result.msg" + - "'Ethernet1/5' in result.msg" + - "'Ethernet1/8' in result.msg" diff --git a/tests/interface_range/interface_range/tasks/main.yaml b/tests/interface_range/interface_range/tasks/main.yaml new file mode 100644 index 0000000..f27a5c4 --- /dev/null +++ b/tests/interface_range/interface_range/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: interface_range test + import_tasks: interface_range.yaml diff --git a/tests/interface_range/test.yml b/tests/interface_range/test.yml new file mode 100644 index 0000000..a93f282 --- /dev/null +++ b/tests/interface_range/test.yml @@ -0,0 +1,4 @@ +- hosts: localhost + connection: local + roles: + - interface_range diff --git a/tests/interface_split/interface_split/meta/main.yaml b/tests/interface_split/interface_split/meta/main.yaml new file mode 100644 index 0000000..d64f158 --- /dev/null +++ b/tests/interface_split/interface_split/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - ../../../network-engine diff --git a/tests/interface_split/interface_split/tasks/interface_split.yaml b/tests/interface_split/interface_split/tasks/interface_split.yaml new file mode 100644 index 0000000..4019802 --- /dev/null +++ b/tests/interface_split/interface_split/tasks/interface_split.yaml @@ -0,0 +1,27 @@ +- name: interface_split Ethernet1 + debug: + msg: "{{ 'Ethernet1' | interface_split }}" + register: result + +- assert: + that: + - "'1' in result.msg.index" + - "'Ethernet' in result.msg.name" + +- name: interface_split Ethernet1 name + debug: + msg: "{{ 'Ethernet1' | interface_split('name') }}" + register: result + +- assert: + that: + - "'Ethernet' in result.msg" + +- name: interface_split Ethernet1 index + debug: + msg: "{{ 'Ethernet1' | interface_split('index') }}" + register: result + +- assert: + that: + - "'1' in result.msg" diff --git a/tests/interface_split/interface_split/tasks/main.yaml b/tests/interface_split/interface_split/tasks/main.yaml new file mode 100644 index 0000000..b3e9652 --- /dev/null +++ b/tests/interface_split/interface_split/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: interface_split test + import_tasks: interface_split.yaml diff --git a/tests/interface_split/test.yml b/tests/interface_split/test.yml new file mode 100644 index 0000000..e84e431 --- /dev/null +++ b/tests/interface_split/test.yml @@ -0,0 +1,4 @@ +- hosts: localhost + connection: local + roles: + - interface_split diff --git a/tests/test.yml b/tests/test.yml index 568e64c..b0d7ce7 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -10,3 +10,5 @@ - import_playbook: vlan_expand/test.yml - import_playbook: netcfg_diff/test.yml - import_playbook: yang2spec/test.yml +- import_playbook: interface_range/test.yml +- import_playbook: interface_split/test.yml