diff options
Diffstat (limited to 'test/integration/targets/eos_eapi')
13 files changed, 405 insertions, 0 deletions
diff --git a/test/integration/targets/eos_eapi/defaults/main.yaml b/test/integration/targets/eos_eapi/defaults/main.yaml new file mode 100644 index 0000000000..2a4e223ff0 --- /dev/null +++ b/test/integration/targets/eos_eapi/defaults/main.yaml @@ -0,0 +1,4 @@ +--- +testcase: "*" +test_items: [] + diff --git a/test/integration/targets/eos_eapi/meta/main.yml b/test/integration/targets/eos_eapi/meta/main.yml new file mode 100644 index 0000000000..e5c8cd02f0 --- /dev/null +++ b/test/integration/targets/eos_eapi/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_eos_tests diff --git a/test/integration/targets/eos_eapi/tasks/cli.yaml b/test/integration/targets/eos_eapi/tasks/cli.yaml new file mode 100644 index 0000000000..b916410f16 --- /dev/null +++ b/test/integration/targets/eos_eapi/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/eos_eapi/tasks/main.yaml b/test/integration/targets/eos_eapi/tasks/main.yaml new file mode 100644 index 0000000000..415c99d8b1 --- /dev/null +++ b/test/integration/targets/eos_eapi/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/eos_eapi/tests/cli/badtransport.yaml b/test/integration/targets/eos_eapi/tests/cli/badtransport.yaml new file mode 100644 index 0000000000..32b51555d7 --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/badtransport.yaml @@ -0,0 +1,16 @@ +- debug: msg="START CLI/BADTRANSPORT.YAML" + +- name: Expect transport other than cli to fail + eos_eapi: + provider: "{{ eapi }}" + register: eos_eapi_output + connection: local + ignore_errors: yes + +- debug: var=eos_eapi_output + when: debug + +- assert: + that: eos_eapi_output.failed and eos_eapi_output.msg |search('transport') + +- debug: msg="START CLI/BADTRANSPORT.YAML" diff --git a/test/integration/targets/eos_eapi/tests/cli/config.yaml b/test/integration/targets/eos_eapi/tests/cli/config.yaml new file mode 100644 index 0000000000..15cebd9518 --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/config.yaml @@ -0,0 +1,52 @@ +- debug: msg="START cli/config.yaml" + + +#---- +- name: Setup + eos_config: + lines: no management api http-commands + match: none + provider: "{{ cli }}" + connection: local + +- name: Get running-config + eos_command: + commands: show running-config + provider: "{{ cli }}" + register: config + connection: local + +- name: Set config + eos_eapi: + config: "{{ config.stdout[0] }}" + provider: "{{ cli }}" + register: config + connection: local + +- name: Ensure that this triggered a change + assert: + that: + - "config.changed == true" + +#--- +- name: Get running-config again + eos_command: + commands: show running-config + provider: "{{ cli }}" + register: config + connection: local + +- name: Set config + eos_eapi: + config: "{{ config.stdout[0] }}" + provider: "{{ cli }}" + register: config + connection: local + + +- name: Idempotency check + assert: + that: + - "config.changed == false" + +- debug: msg="END cli/config.yaml" diff --git a/test/integration/targets/eos_eapi/tests/cli/configure.yaml b/test/integration/targets/eos_eapi/tests/cli/configure.yaml new file mode 100644 index 0000000000..27c29f1190 --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/configure.yaml @@ -0,0 +1,43 @@ +- debug: msg="START CLI/CONFIGURE.YAML" + +- name: Change endpoint ports + eos_eapi: + enable_http: false + http_port: 81 + https_port: 4443 + enable_local_http: yes + local_http_port: 8181 + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- name: Expect endpoint ports to be set + assert: + that: + - http_config.stdout[0].httpServer.port == 81 + - http_config.stdout[0].httpsServer.port == 4443 + - http_config.stdout[0].localHttpServer.port == 8181 + +- name: Change endpoint ports again + eos_eapi: + http_port: 81 + https_port: 4443 + enable_local_http: yes + local_http_port: 8181 + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="END CLI/CONFIGURE.YAML" diff --git a/test/integration/targets/eos_eapi/tests/cli/off.yaml b/test/integration/targets/eos_eapi/tests/cli/off.yaml new file mode 100644 index 0000000000..68e73fa047 --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/off.yaml @@ -0,0 +1,50 @@ +- debug: msg="START CLI/OFF.YAML" + +- name: Turn all endpoints off + eos_eapi: + enable_http: no + enable_https: no + enable_local_http: no + enable_socket: no + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- debug: var=eos_eapi_output + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- debug: var=http_config + +- name: Expect all EAPI endpoints to be in off state + assert: + that: + - http_config.stdout[0].httpServer.running == false + - http_config.stdout[0].httpsServer.running == false + - http_config.stdout[0].localHttpServer.running == false + - http_config.stdout[0].unixSocketServer.running == false + +- name: Turn all endpoints off again + eos_eapi: + enable_http: no + enable_https: no + enable_local_http: no + enable_socket: no + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="END CLI/OFF.YAML" diff --git a/test/integration/targets/eos_eapi/tests/cli/on.yaml b/test/integration/targets/eos_eapi/tests/cli/on.yaml new file mode 100644 index 0000000000..ec8e8ba467 --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/on.yaml @@ -0,0 +1,48 @@ +- debug: msg="START CLI/ON.YAML" + +- name: Turn on all endpoints + eos_eapi: + enable_http: yes + enable_https: yes + enable_local_http: yes + enable_socket: yes + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- debug: var=http_config + when: debug + +- name: Expect all EAPI endpoints to be in on state + assert: + that: + - http_config.stdout[0].httpServer.running == true + - http_config.stdout[0].httpsServer.running == true + - http_config.stdout[0].localHttpServer.running == true + - http_config.stdout[0].unixSocketServer.running == true + +- name: Turn on all endpoints again + eos_eapi: + enable_http: yes + enable_https: yes + enable_local_http: yes + enable_socket: yes + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- debug: var=eos_eapi_output + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="START CLI/ON.YAML" diff --git a/test/integration/targets/eos_eapi/tests/cli/start.yaml b/test/integration/targets/eos_eapi/tests/cli/start.yaml new file mode 100644 index 0000000000..e7ac7e46cd --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/start.yaml @@ -0,0 +1,39 @@ +- debug: msg="START CLI/START.YAML" + +- name: Set state to started + eos_eapi: + state: started + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- debug: var=http_config + when: debug + +- name: Expect EAPI state is on + assert: + that: http_config.stdout[0].enabled == true + +- name: Set state to running again + eos_eapi: + state: started + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="STOP CLI/START.YAML" diff --git a/test/integration/targets/eos_eapi/tests/cli/stop.yaml b/test/integration/targets/eos_eapi/tests/cli/stop.yaml new file mode 100644 index 0000000000..1b380fa940 --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/stop.yaml @@ -0,0 +1,39 @@ +- debug: msg="START CLI/STOP.YAML" + +- name: Set state to stopped + eos_eapi: + state: stopped + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- debug: var=http_config + when: debug + +- name: Expect EAPI state is off + assert: + that: http_config.stdout[0].enabled == false + +- name: Set state to stopped again + eos_eapi: + state: stopped + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- debug: var=eos_eapi_output + when: debug + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="STOP CLI/ENABLE.YAML" diff --git a/test/integration/targets/eos_eapi/tests/cli/vrf.yaml b/test/integration/targets/eos_eapi/tests/cli/vrf.yaml new file mode 100644 index 0000000000..b21387fb2d --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/vrf.yaml @@ -0,0 +1,57 @@ +- debug: msg="START cli/vrf.yaml" + + +#---- +- name: Set invalid VRF + eos_eapi: + vrf: foobar + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + ignore_errors: true + +- name: Ensure that setting VRF failed + assert: + that: + - "eos_eapi_output.failed == true" + - "eos_eapi_output.changed == false" + - eos_eapi_output.msg == "vrf 'foobar' is not configured" + +#---- +- name: Set VRF to default + eos_eapi: + vrf: default + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + ignore_errors: true + + +- name: Set VRF to default again (idempotent) + eos_eapi: + vrf: default + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- name: Ensure idempotent + assert: + that: + - "eos_eapi_output.changed == false" + + +# ----- +# FIXME Future: Idempotent test +# Add in an extra vrt and swap between that and default to ensure idempotency +- name: DEBUG show vrf + eos_command: + commands: show vrf + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + when: false + +#- debug: +# msg: "{{ eos_eapi_output }}" + +- debug: msg="END cli/vrf.yaml" diff --git a/test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml b/test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml new file mode 100644 index 0000000000..a11afef7c2 --- /dev/null +++ b/test/integration/targets/eos_eapi/tests/cli/zzz_reset.yaml @@ -0,0 +1,36 @@ +- debug: msg="START CLI/RESET.YAML" + +- name: Change endpoint ports back to default values + eos_eapi: + enable_local_http: yes + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- eos_command: + commands: + - show management api http-commands | json + provider: "{{ cli }}" + register: http_config + connection: local + +- name: Expect endpoint ports to have default port values + assert: + that: + - http_config.stdout[0].httpServer.port == 80 + - http_config.stdout[0].httpsServer.port == 443 + - http_config.stdout[0].localHttpServer.port == 8080 + +- name: Change endpoint ports back to default values again + eos_eapi: + enable_local_http: yes + provider: "{{ cli }}" + register: eos_eapi_output + connection: local + +- name: Expect action to be idempotent + assert: + that: + - "eos_eapi_output.changed == false" + +- debug: msg="END CLI/RESET.YAML" |