summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorBradley A. Thornton <bthornto@thethorntons.net>2019-08-16 11:45:39 -0700
committerBradley A. Thornton <bthornto@thethorntons.net>2019-08-16 11:45:39 -0700
commit6a2aa3b8adaf9dd220916e42ec65904820d64092 (patch)
tree391360212f87a5d815f91e05205f38f7c733a10a /test/integration
parent83a80f9f9df748b10eaa36dd3aab4592aaf40b28 (diff)
downloadvyos.vyos-6a2aa3b8adaf9dd220916e42ec65904820d64092.tar.gz
vyos.vyos-6a2aa3b8adaf9dd220916e42ec65904820d64092.zip
based on ansible/ansible e7a8e4805349aec2d8a9538f544ad9e29b2e6318
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/prepare_vyos_tests/tasks/main.yaml5
-rw-r--r--test/integration/targets/vyos_command/tests/cli/cli_command.yaml6
-rw-r--r--test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml8
-rw-r--r--test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml8
-rw-r--r--test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml6
-rw-r--r--test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml2
-rw-r--r--test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml2
-rw-r--r--test/integration/targets/vyos_interfaces/vars/main.yaml21
-rw-r--r--test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml2
-rw-r--r--test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml2
-rw-r--r--test/integration/targets/vyos_lag_interfaces/defaults/main.yaml3
-rw-r--r--test/integration/targets/vyos_lag_interfaces/meta/main.yaml2
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tasks/cli.yaml19
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tasks/main.yaml2
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml8
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml16
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml8
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml14
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml46
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml60
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml54
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml51
-rw-r--r--test/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml69
-rw-r--r--test/integration/targets/vyos_lag_interfaces/vars/main.yaml115
24 files changed, 488 insertions, 41 deletions
diff --git a/test/integration/targets/prepare_vyos_tests/tasks/main.yaml b/test/integration/targets/prepare_vyos_tests/tasks/main.yaml
index 494a1d2..a156ea4 100644
--- a/test/integration/targets/prepare_vyos_tests/tasks/main.yaml
+++ b/test/integration/targets/prepare_vyos_tests/tasks/main.yaml
@@ -1,10 +1,11 @@
---
- name: Ensure required interfaces are present in running-config
- cli_config:
+ network.cli.cli_config:
config: "{{ lines }}"
vars:
lines: |
set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth1
set interfaces ethernet eth2
- set interfaces loopback lo
+ delete interfaces loopback lo
+ ignore_errors: yes
diff --git a/test/integration/targets/vyos_command/tests/cli/cli_command.yaml b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml
index caeb202..08a7675 100644
--- a/test/integration/targets/vyos_command/tests/cli/cli_command.yaml
+++ b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml
@@ -4,7 +4,7 @@
- block:
- name: get output for single command
- cli_command:
+ network.cli.cli_command:
command: show version
register: result
@@ -14,7 +14,7 @@
- "result.stdout is defined"
- name: send invalid command
- cli_command:
+ network.cli.cli_command:
command: 'show foo'
register: result
ignore_errors: yes
@@ -27,7 +27,7 @@
- block:
- name: test failure for local connection
- cli_command:
+ network.cli.cli_command:
command: show version
register: result
ignore_errors: yes
diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
index a431c01..8057705 100644
--- a/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
+++ b/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
@@ -22,7 +22,7 @@
with_items: "{{backup_files.files|default([])}}"
- name: take config backup
- cli_config:
+ network.cli.cli_config:
backup: yes
become: yes
register: result
@@ -43,7 +43,7 @@
- "backup_files.files is defined"
- name: take configuration backup in custom filename and directory path
- cli_config:
+ network.cli.cli_config:
backup: yes
backup_options:
filename: backup.cfg
@@ -66,7 +66,7 @@
- "backup_file.files is defined"
- name: take configuration backup in custom filename
- cli_config:
+ network.cli.cli_config:
backup: yes
backup_options:
filename: backup.cfg
@@ -88,7 +88,7 @@
- "backup_file.files is defined"
- name: take configuration backup in custom path and default filename
- cli_config:
+ network.cli.cli_config:
backup: yes
backup_options:
dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
index e83db1e..e5e3edb 100644
--- a/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
+++ b/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
@@ -2,11 +2,11 @@
- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
- name: setup - remove interface description
- cli_config: &rm
+ network.cli.cli_config: &rm
config: delete interfaces loopback lo description
- name: configure device with config
- cli_config: &conf
+ network.cli.cli_config: &conf
config: set interfaces loopback lo description 'this is a test'
register: result
@@ -15,7 +15,7 @@
- "result.changed == true"
- name: Idempotence
- cli_config: *conf
+ network.cli.cli_config: *conf
register: result
- assert:
@@ -23,6 +23,6 @@
- "result.changed == false"
- name: teardown
- cli_config: *rm
+ network.cli.cli_config: *rm
- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
index 4f9a048..ecc9e8c 100644
--- a/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
+++ b/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
@@ -2,11 +2,11 @@
- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}"
- name: setup
- cli_config: &rm
+ network.cli.cli_config: &rm
config: set system host-name {{ inventory_hostname_short }}
- name: configure using comment
- cli_config:
+ network.cli.cli_config:
config: set system host-name foo
commit_comment: this is a test
register: result
@@ -25,6 +25,6 @@
- "'this is a test' in result.stdout_lines[0][1]"
- name: teardown
- cli_config: *rm
+ network.cli.cli_config: *rm
- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml
index b798bae..0a44fa4 100644
--- a/test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml
+++ b/test/integration/targets/vyos_interfaces/tests/cli/_populate.yaml
@@ -1,6 +1,6 @@
---
- name: Setup
- cli_config:
+ network.cli.cli_config:
config: "{{ lines }}"
vars:
lines: |
diff --git a/test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml
index 6d559c1..ce4723d 100644
--- a/test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml
+++ b/test/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml
@@ -1,6 +1,6 @@
---
- name: Remove Config
- cli_config:
+ network.cli.cli_config:
config: "{{ lines }}"
vars:
lines: |
diff --git a/test/integration/targets/vyos_interfaces/vars/main.yaml b/test/integration/targets/vyos_interfaces/vars/main.yaml
index e3bd818..b973752 100644
--- a/test/integration/targets/vyos_interfaces/vars/main.yaml
+++ b/test/integration/targets/vyos_interfaces/vars/main.yaml
@@ -12,9 +12,6 @@ merged:
- name: "eth2"
enabled: true
- - name: "lo"
- enabled: true
-
commands:
- "set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'"
- "set interfaces ethernet eth1 mtu '1500'"
@@ -28,9 +25,6 @@ merged:
- "set interfaces ethernet eth2 disable"
after:
- - name: "lo"
- enabled: true
-
- name: "eth0"
enabled: true
duplex: "auto"
@@ -85,9 +79,6 @@ populate:
duplex: "auto"
speed: "auto"
- - name: "lo"
- enabled: true
-
replaced:
commands:
- "delete interfaces ethernet eth1 mtu"
@@ -103,9 +94,6 @@ replaced:
- "set interfaces ethernet eth2 mtu '1400'"
after:
- - name: "lo"
- enabled: true
-
- name: "eth1"
description: "Replaced by Ansible"
enabled: true
@@ -144,9 +132,6 @@ overridden:
- "set interfaces ethernet eth2 mtu '1200'"
after:
- - name: "lo"
- enabled: true
-
- name: "eth0"
enabled: true
speed: "auto"
@@ -180,9 +165,6 @@ deleted:
- "delete interfaces ethernet eth2 vif 200 description"
after:
- - name: "lo"
- enabled: true
-
- name: "eth0"
enabled: true
speed: "auto"
@@ -202,9 +184,6 @@ deleted:
round_trip:
after:
- - name: "lo"
- enabled: true
-
- name: "eth0"
enabled: true
speed: "auto"
diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml
index 248a9bb..fc0bbb2 100644
--- a/test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml
+++ b/test/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml
@@ -1,6 +1,6 @@
---
- name: Setup
- cli_config:
+ network.cli.cli_config:
config: "{{ lines }}"
vars:
lines: |
diff --git a/test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml
index 31af5ba..95b2b8c 100644
--- a/test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml
+++ b/test/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml
@@ -1,6 +1,6 @@
---
- name: Remove Config
- cli_config:
+ network.cli.cli_config:
config: "{{ lines }}"
vars:
lines: |
diff --git a/test/integration/targets/vyos_lag_interfaces/defaults/main.yaml b/test/integration/targets/vyos_lag_interfaces/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/test/integration/targets/vyos_lag_interfaces/meta/main.yaml b/test/integration/targets/vyos_lag_interfaces/meta/main.yaml
new file mode 100644
index 0000000..f88bce5
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/meta/main.yaml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_vyos_tests
diff --git a/test/integration/targets/vyos_lag_interfaces/tasks/cli.yaml b/test/integration/targets/vyos_lag_interfaces/tasks/cli.yaml
new file mode 100644
index 0000000..655e51e
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tasks/cli.yaml
@@ -0,0 +1,19 @@
+---
+- name: Collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=network_cli)
+ include: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/vyos_lag_interfaces/tasks/main.yaml b/test/integration/targets/vyos_lag_interfaces/tasks/main.yaml
new file mode 100644
index 0000000..415c99d
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml
new file mode 100644
index 0000000..c479f79
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml
@@ -0,0 +1,8 @@
+---
+- name: Add Bond
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ set interfaces bonding bond0
+ set interfaces bonding bond1
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml
new file mode 100644
index 0000000..6139508
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml
@@ -0,0 +1,16 @@
+---
+- name: Setup
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ set interfaces bonding bond0
+ set interfaces bonding bond0 hash-policy 'layer2'
+ set interfaces bonding bond0 mode 'active-backup'
+ set interfaces ethernet eth1 bond-group bond0
+ set interfaces bonding bond1
+ set interfaces bonding bond0 primary 'eth1'
+ set interfaces bonding bond1 hash-policy 'layer2+3'
+ set interfaces bonding bond1 mode 'active-backup'
+ set interfaces ethernet eth2 bond-group bond1
+ set interfaces bonding bond1 primary 'eth2'
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml
new file mode 100644
index 0000000..1d7ee69
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml
@@ -0,0 +1,8 @@
+---
+- name: Remove Bond
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ delete interfaces bonding bond0
+ delete interfaces bonding bond1
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000..c5d3657
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,14 @@
+---
+- name: Remove Config
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ delete interfaces bonding bond0 hash-policy
+ delete interfaces ethernet eth1 bond-group bond0
+ delete interfaces bonding bond0 mode
+ delete interfaces bonding bond0 primary
+ delete interfaces bonding bond1 hash-policy
+ delete interfaces ethernet eth2 bond-group bond1
+ delete interfaces bonding bond1 mode
+ delete interfaces bonding bond1 primary
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 0000000..db6fb88
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,46 @@
+---
+- debug:
+ msg: "Start vyos_lag_interfaces deleted integration tests ansible_connection={{ ansible_connection }}"
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Delete attributes of given LAG interfaces.
+ vyos.vyos.vyos_lag_interfaces: &deleted
+ config:
+ - name: bond0
+ - name: bond1
+ state: deleted
+ register: result
+
+ - name: Assert that the before dicts were correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['before']) |length == 0 }}"
+
+ - name: Assert that the correct set of commands were generated
+ assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+
+ - name: Assert that the after dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Delete attributes of given interfaces (IDEMPOTENT)
+ vyos.vyos.vyos_lag_interfaces: *deleted
+ register: result
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - "result.changed == false"
+
+ - name: Assert that the before dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml
new file mode 100644
index 0000000..78c9de1
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,60 @@
+---
+- debug:
+ msg: "START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _remove_bond.yaml
+
+- include_tasks: _add_bond.yaml
+
+- block:
+ - name: Merge the provided configuration with the exisiting running configuration
+ vyos.vyos.vyos_lag_interfaces: &merged
+ config:
+ - name: bond0
+ hash_policy: "layer2"
+ mode: "active-backup"
+ members:
+ - member: eth1
+ primary: eth1
+
+ - name: bond1
+ hash_policy: "layer2+3"
+ mode: "active-backup"
+ members:
+ - member: eth2
+ primary: eth2
+ state: merged
+ register: result
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+
+ - name: Assert that after dicts was correctly generated
+ assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
+ vyos.vyos.vyos_lag_interfaces: *merged
+ register: result
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - "result['changed'] == false"
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 0000000..6139d9f
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,54 @@
+---
+- debug:
+ msg: "START vyos_lag_interfaces overridden integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _remove_bond.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Overrides all device configuration with provided configuration
+ vyos.vyos.vyos_lag_interfaces: &overridden
+ config:
+ - name: bond1
+ mode: "active-backup"
+ members:
+ - member: eth2
+ primary: eth2
+ hash_policy: layer2
+ state: overridden
+ register: result
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['before']) |length == 0 }}"
+
+ - name: Assert that correct commands were generated
+ assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+
+ - name: Assert that after dicts were correctly generated
+ assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Overrides all device configuration with provided configurations (IDEMPOTENT)
+ vyos.vyos.vyos_lag_interfaces: *overridden
+ register: result
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - "result['changed'] == false"
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 0000000..ce469e0
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,51 @@
+---
+- debug:
+ msg: "START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Replace device configurations of listed LAG interfaces with provided configurations
+ vyos.vyos.vyos_lag_interfaces: &replaced
+ config:
+ - name: bond1
+ mode: "802.3ad"
+ hash_policy: "layer2"
+ members:
+ - member: eth2
+ state: replaced
+ register: result
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['before']) |length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Replace device configurations of listed LAG interfaces with provided configurarions (IDEMPOTENT)
+ vyos.vyos.vyos_lag_interfaces: *replaced
+ register: result
+
+ - name: Assert that task was idempotent
+ assert:
+ that:
+ - "result['changed'] == false"
+
+ - name: Assert that before dict is correctly generated
+ assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml b/test/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 0000000..eb3814e
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,69 @@
+---
+- debug:
+ msg: "START vyos_lag_interfaces round trip integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _remove_bond.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ vyos.vyos.vyos_lag_interfaces:
+ config:
+ - name: bond0
+ hash_policy: "layer2"
+ mode: "active-backup"
+ members:
+ - member: eth1
+ primary: eth1
+
+ - name: bond1
+ hash_policy: "layer2+3"
+ mode: "active-backup"
+ members:
+ - member: eth2
+ primary: eth2
+
+ state: merged
+ register: base_config
+
+ - name: Gather lag_interfaces facts
+ vyos.vyos.vyos_facts:
+ gather_subset:
+ - default
+ gather_network_resources:
+ - lag_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ vyos.vyos.vyos_lag_interfaces:
+ config:
+ - name: bond0
+ hash_policy: "layer2+3"
+ mode: "802.3ad"
+ members:
+ - member: eth1
+
+ - name: bond1
+ hash_policy: "layer2"
+ mode: "xor-hash"
+ members:
+ - member: eth2
+ state: merged
+ register: result
+
+ - name: Assert that changes were applied
+ assert:
+ that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Revert back to base config using facts round trip
+ vyos.vyos.vyos_lag_interfaces:
+ config: "{{ ansible_facts['network_resources']['lag_interfaces'] }}"
+ state: overridden
+ register: revert
+
+ - name: Assert that config was reverted
+ assert:
+ that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lag_interfaces/vars/main.yaml b/test/integration/targets/vyos_lag_interfaces/vars/main.yaml
new file mode 100644
index 0000000..8726e39
--- /dev/null
+++ b/test/integration/targets/vyos_lag_interfaces/vars/main.yaml
@@ -0,0 +1,115 @@
+---
+merged:
+ before:
+ - name: "bond0"
+
+ - name: "bond1"
+
+ commands:
+ - "set interfaces bonding bond0 hash-policy 'layer2'"
+ - "set interfaces bonding bond0 mode 'active-backup'"
+ - "set interfaces ethernet eth1 bond-group 'bond0'"
+ - "set interfaces bonding bond0 primary 'eth1'"
+ - "set interfaces bonding bond1 hash-policy 'layer2+3'"
+ - "set interfaces bonding bond1 mode 'active-backup'"
+ - "set interfaces ethernet eth2 bond-group 'bond1'"
+ - "set interfaces bonding bond1 primary 'eth2'"
+
+ after:
+ - name: "bond0"
+ hash_policy: "layer2"
+ members:
+ - member: eth1
+ mode: "active-backup"
+ primary: eth1
+
+ - name: "bond1"
+ hash_policy: "layer2+3"
+ members:
+ - member: eth2
+ mode: "active-backup"
+ primary: eth2
+
+populate:
+ - name: "bond0"
+ hash_policy: "layer2"
+ members:
+ - member: eth1
+ mode: "active-backup"
+ primary: eth1
+
+ - name: "bond1"
+ hash_policy: "layer2+3"
+ members:
+ - member: eth2
+ mode: "active-backup"
+ primary: eth2
+
+replaced:
+ commands:
+ - "delete interfaces bonding bond1 primary"
+ - "set interfaces bonding bond1 hash-policy 'layer2'"
+ - "set interfaces bonding bond1 mode '802.3ad'"
+
+ after:
+ - name: "bond0"
+ hash_policy: "layer2"
+ members:
+ - member: eth1
+ mode: "active-backup"
+ primary: eth1
+
+ - name: "bond1"
+ hash_policy: "layer2"
+ members:
+ - member: eth2
+ mode: "802.3ad"
+
+overridden:
+ commands:
+ - "delete interfaces bonding bond0 hash-policy"
+ - "delete interfaces ethernet eth1 bond-group 'bond0'"
+ - "delete interfaces bonding bond0 mode"
+ - "delete interfaces bonding bond0 primary"
+ - "set interfaces bonding bond1 hash-policy 'layer2'"
+
+ after:
+ - name: "bond0"
+ - name: "bond1"
+ hash_policy: "layer2"
+ members:
+ - member: eth2
+ mode: "active-backup"
+ primary: eth2
+
+deleted:
+ commands:
+ - "delete interfaces bonding bond0 hash-policy"
+ - "delete interfaces ethernet eth1 bond-group 'bond0'"
+ - "delete interfaces bonding bond0 mode"
+ - "delete interfaces bonding bond0 primary"
+ - "delete interfaces bonding bond1 hash-policy"
+ - "delete interfaces ethernet eth2 bond-group 'bond1'"
+ - "delete interfaces bonding bond1 mode"
+ - "delete interfaces bonding bond1 primary"
+
+ after:
+ - name: "bond0"
+
+ - name: "bond1"
+
+round_trip:
+ after:
+ - name: "bond0"
+ hash_policy: "layer2+3"
+ members:
+ - member: eth1
+ mode: "802.3ad"
+ primary: eth1
+
+ - name: "bond1"
+ hash_policy: "layer2"
+ members:
+ - member: eth2
+ mode: "xor-hash"
+ primary: eth2