summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorTrishna Guha <trishnaguha17@gmail.com>2017-11-07 11:13:03 +0000
committerGitHub <noreply@github.com>2017-11-07 11:13:03 +0000
commit48ab1a1334d1c5273691398ae2629dc0b7ec52a8 (patch)
tree557d16db123043bbe03a1bbf4a2d00c6751844fb /test/integration
parent1857d11034112925a818fb911da502454ef9ac2a (diff)
downloadansible-48ab1a1334d1c5273691398ae2629dc0b7ec52a8.tar.gz
eos_static_route DI module (#32587)
* eos_static_route DI module Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Integration test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add net_static_route test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Validate ip address Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/eos.yaml9
-rw-r--r--test/integration/targets/eos_static_route/defaults/main.yaml3
-rw-r--r--test/integration/targets/eos_static_route/meta/main.yaml2
-rw-r--r--test/integration/targets/eos_static_route/tasks/cli.yaml15
-rw-r--r--test/integration/targets/eos_static_route/tasks/main.yaml2
-rw-r--r--test/integration/targets/eos_static_route/tests/cli/basic.yaml114
-rw-r--r--test/integration/targets/net_static_route/tests/cli/basic.yaml3
-rw-r--r--test/integration/targets/net_static_route/tests/eos/basic.yaml102
8 files changed, 250 insertions, 0 deletions
diff --git a/test/integration/eos.yaml b/test/integration/eos.yaml
index 7eaf91c6f8..0fbcc80584 100644
--- a/test/integration/eos.yaml
+++ b/test/integration/eos.yaml
@@ -103,6 +103,15 @@
failed_modules: "{{ failed_modules }} + [ 'eos_logging' ]"
test_failed: true
+ - block:
+ - include_role:
+ name: eos_static_route
+ when: "limit_to in ['*', 'eos_static_route']"
+ rescue:
+ - set_fact:
+ failed_modules: "{{ failed_modules }} + [ 'eos_static_route' ]"
+ test_failed: true
+
###########
diff --git a/test/integration/targets/eos_static_route/defaults/main.yaml b/test/integration/targets/eos_static_route/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/eos_static_route/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/eos_static_route/meta/main.yaml b/test/integration/targets/eos_static_route/meta/main.yaml
new file mode 100644
index 0000000000..e5c8cd02f0
--- /dev/null
+++ b/test/integration/targets/eos_static_route/meta/main.yaml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_eos_tests
diff --git a/test/integration/targets/eos_static_route/tasks/cli.yaml b/test/integration/targets/eos_static_route/tasks/cli.yaml
new file mode 100644
index 0000000000..d675462dd0
--- /dev/null
+++ b/test/integration/targets/eos_static_route/tasks/cli.yaml
@@ -0,0 +1,15 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/eos_static_route/tasks/main.yaml b/test/integration/targets/eos_static_route/tasks/main.yaml
new file mode 100644
index 0000000000..415c99d8b1
--- /dev/null
+++ b/test/integration/targets/eos_static_route/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/eos_static_route/tests/cli/basic.yaml b/test/integration/targets/eos_static_route/tests/cli/basic.yaml
new file mode 100644
index 0000000000..e68f34be3d
--- /dev/null
+++ b/test/integration/targets/eos_static_route/tests/cli/basic.yaml
@@ -0,0 +1,114 @@
+---
+- debug: msg="START cli/basic.yaml"
+
+- name: setup - remove config used in test
+ eos_config:
+ lines:
+ - no ip route 192.168.3.0/24 192.168.0.1
+ - no ip route 192.168.4.0/24 192.168.0.1
+ - no ip route 192.168.5.0/24 192.168.0.1
+ authorize: yes
+ provider: "{{ cli }}"
+
+- name: configure static route
+ eos_static_route: &single_route
+ address: 192.168.3.0/24
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands"
+
+- name: configure static route(Idempotence)
+ eos_static_route: *single_route
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: delete static route
+ eos_static_route: &delete_single
+ address: 192.168.3.0/24
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ cli }}"
+ state: absent
+ regiser: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'no ip route 192.168.3.0/24 192.168.0.1' in result.commands"
+
+- name: delete static route
+ eos_static_route: *delete_single
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: configure static routes using aggregate
+ eos_static_route: &configure_aggregate
+ aggregate:
+ - { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
+ - { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip route 192.168.4.0/24 192.168.0.1 1' in result.commands"
+ - "'ip route 192.168.5.0/24 192.168.0.1 1' in result.commands"
+
+- name: configure static routes using aggregate(Idemporence)
+ eos_static_route: *configure_aggregate
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: delete static routes using aggregate
+ eos_static_route: &delete_aggregate
+ aggregate:
+ - { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
+ - { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
+ authorize: yes
+ state: absent
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'no ip route 192.168.4.0/24 192.168.0.1' in result.commands"
+ - "'no ip route 192.168.5.0/24 192.168.0.1' in result.commands"
+
+- name: delete static routes using aggregate(Idempotence)
+ eos_static_route: *delete_aggregate
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ eos_config:
+ lines:
+ - no ip route 192.168.3.0/24 192.168.0.1
+ - no ip route 192.168.4.0/24 192.168.0.1
+ - no ip route 192.168.5.0/24 192.168.0.1
+ authorize: yes
+ provider: "{{ cli }}"
+
+- debug: msg="END cli/basic.yaml"
diff --git a/test/integration/targets/net_static_route/tests/cli/basic.yaml b/test/integration/targets/net_static_route/tests/cli/basic.yaml
index ab94d35065..aab6114739 100644
--- a/test/integration/targets/net_static_route/tests/cli/basic.yaml
+++ b/test/integration/targets/net_static_route/tests/cli/basic.yaml
@@ -7,3 +7,6 @@
- include: "{{ role_path }}/tests/vyos/basic.yaml"
when: hostvars[inventory_hostname]['ansible_network_os'] == 'vyos'
+
+- include: "{{ role_path }}/tests/eos/basic.yaml"
+ when: hostvars[inventory_hostname]['ansible_network_os'] == 'eos'
diff --git a/test/integration/targets/net_static_route/tests/eos/basic.yaml b/test/integration/targets/net_static_route/tests/eos/basic.yaml
new file mode 100644
index 0000000000..691d38491b
--- /dev/null
+++ b/test/integration/targets/net_static_route/tests/eos/basic.yaml
@@ -0,0 +1,102 @@
+---
+- name: setup - remove config used in test
+ net_static_route:
+ aggregate:
+ - { address: 192.168.3.0/24, next_hop: 192.168.0.1 }
+ - { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
+ - { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
+ authorize: yes
+ state: absent
+ provider: "{{ cli }}"
+
+- name: configure static route
+ net_static_route: &single_route
+ address: 192.168.3.0/24
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip route 192.168.3.0/24 192.168.0.1 2' in result.commands"
+
+- name: configure static route(Idempotence)
+ net_static_route: *single_route
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: delete static route
+ net_static_route: &delete_single
+ address: 192.168.3.0/24
+ next_hop: 192.168.0.1
+ admin_distance: 2
+ authorize: yes
+ provider: "{{ cli }}"
+ state: absent
+ regiser: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'no ip route 192.168.3.0/24 192.168.0.1' in result.commands"
+
+- name: delete static route
+ net_static_route: *delete_single
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: configure static routes using aggregate
+ net_static_route: &configure_aggregate
+ aggregate:
+ - { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
+ - { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
+ authorize: yes
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'ip route 192.168.4.0/24 192.168.0.1 1' in result.commands"
+ - "'ip route 192.168.5.0/24 192.168.0.1 1' in result.commands"
+
+- name: configure static routes using aggregate(Idemporence)
+ net_static_route: *configure_aggregate
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: delete static routes using aggregate
+ net_static_route: &delete_aggregate
+ aggregate:
+ - { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
+ - { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
+ authorize: yes
+ state: absent
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'no ip route 192.168.4.0/24 192.168.0.1' in result.commands"
+ - "'no ip route 192.168.5.0/24 192.168.0.1' in result.commands"
+
+- name: delete static routes using aggregate(Idempotence)
+ net_static_route: *delete_aggregate
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"