summaryrefslogtreecommitdiff
path: root/test/integration/targets/ios_facts
diff options
context:
space:
mode:
authorJohn R Barker <john@johnrbarker.com>2016-10-28 19:50:29 +0100
committerGitHub <noreply@github.com>2016-10-28 19:50:29 +0100
commite0cc7b34151def2ce0b08dbe3cb995107a2d6a0f (patch)
tree09df24fe1a91723d5fe716d8b9da843b383d5204 /test/integration/targets/ios_facts
parent4a067c3f502aa2254d8f35d8598895df8f3d1365 (diff)
downloadansible-e0cc7b34151def2ce0b08dbe3cb995107a2d6a0f.tar.gz
Migrate Network Tests into ansible/ansible (#18233)
* Docs Networking tests * Copy networking tests from test-network-modules * Networking transport settings - group_vars * Network playbooks * Debug should be off by default * Update nxos.yaml * Remove items from top level * Use dependencies, not pre-tasks * Remove trailing blank lines * Remove backup files * newlines
Diffstat (limited to 'test/integration/targets/ios_facts')
-rw-r--r--test/integration/targets/ios_facts/defaults/main.yaml3
-rw-r--r--test/integration/targets/ios_facts/tasks/cli.yaml17
-rw-r--r--test/integration/targets/ios_facts/tasks/main.yaml3
-rw-r--r--test/integration/targets/ios_facts/tests/cli/all_facts.yaml31
-rw-r--r--test/integration/targets/ios_facts/tests/cli/default_facts.yaml31
-rw-r--r--test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml48
-rw-r--r--test/integration/targets/ios_facts/tests/cli/not_hardware.yaml30
7 files changed, 163 insertions, 0 deletions
diff --git a/test/integration/targets/ios_facts/defaults/main.yaml b/test/integration/targets/ios_facts/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/ios_facts/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/ios_facts/tasks/cli.yaml b/test/integration/targets/ios_facts/tasks/cli.yaml
new file mode 100644
index 0000000000..b916410f16
--- /dev/null
+++ b/test/integration/targets/ios_facts/tasks/cli.yaml
@@ -0,0 +1,17 @@
+---
+- 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/ios_facts/tasks/main.yaml b/test/integration/targets/ios_facts/tasks/main.yaml
new file mode 100644
index 0000000000..aea4ecccf1
--- /dev/null
+++ b/test/integration/targets/ios_facts/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
+
diff --git a/test/integration/targets/ios_facts/tests/cli/all_facts.yaml b/test/integration/targets/ios_facts/tests/cli/all_facts.yaml
new file mode 100644
index 0000000000..c6e9219e7a
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/all_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/all_facts.yaml"
+
+
+- name: test getting all facts
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - all
+ register: result
+
+
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'config' in result.ansible_facts.ansible_net_gather_subset"
+ - "'hardware' in result.ansible_facts.ansible_net_gather_subset"
+ - "'default' in result.ansible_facts.ansible_net_gather_subset"
+ - "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+ # Check that these facts not only are present, but are valid (positive integers)
+ - "result.ansible_facts.ansible_net_memfree_mb > 1"
+ - "result.ansible_facts.ansible_net_memtotal_mb > 1"
+
+- debug: msg="END cli/all_facts.yaml"
diff --git a/test/integration/targets/ios_facts/tests/cli/default_facts.yaml b/test/integration/targets/ios_facts/tests/cli/default_facts.yaml
new file mode 100644
index 0000000000..2218fc6860
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/default_facts.yaml
@@ -0,0 +1,31 @@
+---
+- debug: msg="START cli/default_facts.yaml"
+
+
+- name: test getting default facts
+ ios_facts:
+ provider: "{{ cli }}"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'hardware' in result.ansible_facts.ansible_net_gather_subset"
+ - "'default' in result.ansible_facts.ansible_net_gather_subset"
+ - "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
+ - "result.ansible_facts.ansible_net_filesystems is defined"
+ # ... and not present
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_filesystems is defined" #hw
+ - "result.ansible_facts.ansible_net_memtotal_mb > 10" #hw
+ - "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
+
+ # ... and not present
+ - "result.ansible_facts.ansible_net_config is not defined" # config
+
+- debug: msg="END cli/default.yaml"
diff --git a/test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml b/test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml
new file mode 100644
index 0000000000..b0c2799254
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/invalid_subset.yaml
@@ -0,0 +1,48 @@
+---
+- debug: msg="START cli/invalid_subset.yaml"
+
+
+- name: test invalid subset (foobar)
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "foobar"
+ register: result
+ ignore_errors: true
+
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+
+###############
+# FIXME Future
+# We may in the future want to add a test for
+
+- name: test subset specified multiple times
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ - "hardware"
+ register: result
+ ignore_errors: true
+
+- assert:
+ that:
+ # Failures shouldn't return changes
+ - "result.changed == false"
+ # It's a failure
+ - "result.failed == true"
+ # Sensible Failure message
+ - "result.msg == 'Bad subset'"
+ ignore_errors: true
+
+
+
+- debug: msg="END cli/invalid_subset.yaml"
diff --git a/test/integration/targets/ios_facts/tests/cli/not_hardware.yaml b/test/integration/targets/ios_facts/tests/cli/not_hardware.yaml
new file mode 100644
index 0000000000..319e4bcc2c
--- /dev/null
+++ b/test/integration/targets/ios_facts/tests/cli/not_hardware.yaml
@@ -0,0 +1,30 @@
+---
+- debug: msg="START cli/not_hardware_facts.yaml"
+
+
+- name: test not hardware
+ ios_facts:
+ provider: "{{ cli }}"
+ gather_subset:
+ - "!hardware"
+ register: result
+
+- assert:
+ that:
+ # _facts modules should never report a change
+ - "result.changed == false"
+
+ # Correct subsets are present
+ - "'config' in result.ansible_facts.ansible_net_gather_subset"
+
+ - "'default' in result.ansible_facts.ansible_net_gather_subset"
+ - "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
+ # ... and not present
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+
+ # Items from those subsets are present
+ - "result.ansible_facts.ansible_net_interfaces | length > 1" # more than one interface returned
+ # ... and not present
+ - "result.ansible_facts.ansible_net_filesystems is not defined"
+
+- debug: msg="END cli/not_hardware_facts.yaml"