From a5d1241fa13b308813173e7686277e15c09c0bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Subileau?= Date: Sun, 26 Aug 2018 17:15:01 +0200 Subject: [PATCH] win_nssm: add failing tests for issue #44079 --- test/integration/targets/win_nssm/aliases | 1 + .../targets/win_nssm/defaults/main.yml | 1 + .../targets/win_nssm/tasks/main.yml | 21 +++++++++++++++++++ .../targets/win_nssm/tasks/tests.yml | 21 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 test/integration/targets/win_nssm/aliases create mode 100644 test/integration/targets/win_nssm/defaults/main.yml create mode 100644 test/integration/targets/win_nssm/tasks/main.yml create mode 100644 test/integration/targets/win_nssm/tasks/tests.yml diff --git a/test/integration/targets/win_nssm/aliases b/test/integration/targets/win_nssm/aliases new file mode 100644 index 00000000000..215e0b06920 --- /dev/null +++ b/test/integration/targets/win_nssm/aliases @@ -0,0 +1 @@ +shippable/windows/group4 diff --git a/test/integration/targets/win_nssm/defaults/main.yml b/test/integration/targets/win_nssm/defaults/main.yml new file mode 100644 index 00000000000..1c7900f727d --- /dev/null +++ b/test/integration/targets/win_nssm/defaults/main.yml @@ -0,0 +1 @@ +test_service_name: ansible_nssm_test \ No newline at end of file diff --git a/test/integration/targets/win_nssm/tasks/main.yml b/test/integration/targets/win_nssm/tasks/main.yml new file mode 100644 index 00000000000..9b3769e645e --- /dev/null +++ b/test/integration/targets/win_nssm/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- name: install NSSM + win_chocolatey: + name: NSSM + state: present + +# Run actual tests +- block: + - include_tasks: tests.yml + + always: + - name: ensure test service is absent + win_service: + name: '{{ test_service_name }}' + state: absent + + - name: uninstall NSSM + win_chocolatey: + name: NSSM + state: absent + failed_when: false diff --git a/test/integration/targets/win_nssm/tasks/tests.yml b/test/integration/targets/win_nssm/tasks/tests.yml new file mode 100644 index 00000000000..d70e83320c1 --- /dev/null +++ b/test/integration/targets/win_nssm/tasks/tests.yml @@ -0,0 +1,21 @@ +--- +- name: install service + win_nssm: + name: '{{ test_service_name }}' + application: 'C:\Windows\System32\cmd.exe' + app_parameters_free_form: '-Dcom.test.string=value' + state: present + register: install_service + +- name: get result of install service + win_shell: | + Write-Host ([bool](Get-Service "{{ test_service_name }}" -ErrorAction SilentlyContinue)) + nssm get "{{ test_service_name }}" AppParameters + register: install_service_actual + +- name: assert results of install service + assert: + that: + - install_service.changed == true + - install_service_actual.stdout_lines[0] == "True" + - install_service_actual.stdout_lines[1] == "-Dcom.test.string=value" \ No newline at end of file