summaryrefslogtreecommitdiff
path: root/test/integration/targets/vyos_lag_interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/vyos_lag_interfaces')
-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
14 files changed, 467 insertions, 0 deletions
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