summaryrefslogtreecommitdiff
path: root/test/integration/targets/vyos_command/tests
diff options
context:
space:
mode:
authorBradley A. Thornton <bthornto@thethorntons.net>2019-08-08 12:29:41 -0700
committerBradley A. Thornton <bthornto@thethorntons.net>2019-08-08 12:29:41 -0700
commita330106b2e2c811db49477d71b8a472c964d2aeb (patch)
treeae05d893d8bed2d04db942d4c103996b26b10be7 /test/integration/targets/vyos_command/tests
parent5472435af823398fc63e049d7efe0938b532f3c9 (diff)
downloadvyos.vyos-a330106b2e2c811db49477d71b8a472c964d2aeb.tar.gz
vyos.vyos-a330106b2e2c811db49477d71b8a472c964d2aeb.zip
fixed
Diffstat (limited to 'test/integration/targets/vyos_command/tests')
-rw-r--r--test/integration/targets/vyos_command/tests/cli/bad_operator.yaml19
-rw-r--r--test/integration/targets/vyos_command/tests/cli/cli_command.yaml41
-rw-r--r--test/integration/targets/vyos_command/tests/cli/contains.yaml20
-rw-r--r--test/integration/targets/vyos_command/tests/cli/invalid.yaml22
-rw-r--r--test/integration/targets/vyos_command/tests/cli/output.yaml44
-rw-r--r--test/integration/targets/vyos_command/tests/cli/timeout.yaml18
6 files changed, 164 insertions, 0 deletions
diff --git a/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml
new file mode 100644
index 00000000..bf3334f2
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,19 @@
+---
+- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}"
+
+- name: test bad operator
+ vyos.vyos.vyos_command:
+ commands:
+ - show version
+ - show interfaces
+ wait_for:
+ - result[0] is 'VyOS'
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - result.failed == true
+ - result.msg is defined
+
+- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/vyos_command/tests/cli/cli_command.yaml b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml
new file mode 100644
index 00000000..caeb2021
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml
@@ -0,0 +1,41 @@
+---
+- debug:
+ msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}"
+
+- block:
+ - name: get output for single command
+ cli_command:
+ command: show version
+ register: result
+
+ - assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+
+ - name: send invalid command
+ cli_command:
+ command: 'show foo'
+ register: result
+ ignore_errors: yes
+
+ - assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+ when: "ansible_connection == 'network_cli'"
+
+- block:
+ - name: test failure for local connection
+ cli_command:
+ command: show version
+ register: result
+ ignore_errors: yes
+
+ - assert:
+ that:
+ - 'result.failed == true'
+ - "'Connection type local is not valid for this module' in result.msg"
+ when: "ansible_connection == 'local'"
+
+- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/vyos_command/tests/cli/contains.yaml b/test/integration/targets/vyos_command/tests/cli/contains.yaml
new file mode 100644
index 00000000..b8665fa7
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/contains.yaml
@@ -0,0 +1,20 @@
+---
+- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}"
+
+- name: test contains operator
+ vyos.vyos.vyos_command:
+ commands:
+ - show version
+ - show interface
+ wait_for:
+ - result[0] contains VyOS
+ - result[1] contains eth0
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+ - result.stdout_lines is defined
+
+- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/vyos_command/tests/cli/invalid.yaml b/test/integration/targets/vyos_command/tests/cli/invalid.yaml
new file mode 100644
index 00000000..672f6e81
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/invalid.yaml
@@ -0,0 +1,22 @@
+---
+- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}"
+
+- name: run invalid command
+ vyos.vyos.vyos_command:
+ commands: show foo
+ register: result
+ ignore_errors: yes
+
+- assert: { that: result.failed }
+
+- name: run commands that include invalid command
+ vyos.vyos.vyos_command:
+ commands:
+ - show version
+ - show foo
+ register: result
+ ignore_errors: yes
+
+- assert: { that: result.failed }
+
+- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/vyos_command/tests/cli/output.yaml b/test/integration/targets/vyos_command/tests/cli/output.yaml
new file mode 100644
index 00000000..bdc8b2a8
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/output.yaml
@@ -0,0 +1,44 @@
+---
+- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}"
+
+- name: get output for single command
+ vyos.vyos.vyos_command:
+ commands: show version
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+ - result.stdout_lines is defined
+
+- name: get output for multiple commands
+ vyos.vyos.vyos_command:
+ commands:
+ - show version
+ - show interfaces
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+ - result.stdout | length == 2
+
+- name: Get output for multiple commands that call less explicitly
+ vyos.vyos.vyos_command:
+ commands:
+ # NOTE: We only test show commands that will output <ANSIBLE_VYOS_TERMINAL_LENGTH
+ # Otherwise you will get ": "command timeout triggered"
+ - show hardware cpu detail
+ - show hardware mem
+ - show license
+ register: result
+
+- assert:
+ that:
+ - result.changed == false
+ - result.stdout_lines is defined
+ - result.stdout_lines[2] | length >= 20
+
+- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}"
diff --git a/test/integration/targets/vyos_command/tests/cli/timeout.yaml b/test/integration/targets/vyos_command/tests/cli/timeout.yaml
new file mode 100644
index 00000000..e4716ed6
--- /dev/null
+++ b/test/integration/targets/vyos_command/tests/cli/timeout.yaml
@@ -0,0 +1,18 @@
+---
+- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}"
+
+- name: test bad condition
+ vyos.vyos.vyos_command:
+ commands:
+ - show version
+ wait_for:
+ - result[0] contains bad_value_string
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - result.failed == true
+ - result.msg is defined
+
+- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}"