Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/supervisorctl/tasks/test_start.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: start py1 service (without auth)
7 supervisorctl:
8 name: 'pys:py1'
9 state: started
10 config: '{{ remote_dir }}/supervisord.conf'
11 register: result
12 when: credentials.username == ''
13
14 - name: start py1 service (with auth)
15 supervisorctl:
16 name: 'pys:py1'
17 state: started
18 server_url: http://127.0.0.1:9001
19 username: '{{ credentials.username }}'
20 password: '{{ credentials.password }}'
21 register: result_with_auth
22 when: credentials.username != ''
23
24 - command: "supervisorctl -c {{ remote_dir }}/supervisord.conf {% if credentials.username %}-u {{ credentials.username }} -p {{ credentials.password }}{% endif %} status"
25 register: result_cmd
26 failed_when: result_cmd.rc not in [0, 3]
27
28 - name: check that service is started
29 assert:
30 that:
31 - (result is success and result_with_auth is skip) or (result is skip and result_with_auth is changed)
32 - (result is changed and result_with_auth is skip) or (result is skip and result_with_auth is changed)
33
34 - name: check that service is running (part1) # py1.log content is checked below
35 script:
36 cmd: "files/sendProcessStdin.py 'pys:py1' 2 '{{ credentials.username }}' '{{ credentials.password }}'"
37 executable: "{{ ansible_facts.python.executable }}"
38
39 - name: try again to start py1 service (without auth)
40 supervisorctl:
41 name: pys:py1
42 state: started
43 config: '{{ remote_dir }}/supervisord.conf'
44 register: result
45 when: credentials.username == ''
46
47 - name: try again to start py1 service (with auth)
48 supervisorctl:
49 name: pys:py1
50 state: started
51 server_url: http://127.0.0.1:9001
52 username: '{{ credentials.username }}'
53 password: '{{ credentials.password }}'
54 register: result_with_auth
55 when: credentials.username != ''
56
57 - name: check that service is already running
58 assert:
59 that:
60 - (result is success and result_with_auth is skip) or (result is skip and result_with_auth is success)
61 - (result is not changed and result_with_auth is skip) or (result is skip and result_with_auth is not changed)
62
63 - import_tasks: stop_supervisord.yml
64
65 # supervisord has been stopped, check logfile
66 - name: check that service has done what it was expected (part 2)
67 shell: 'test "$(tail -2 {{ remote_dir }}/py1.log | head -1)" = ">>> 2"'
68
69 # restart supervisord and py1 service for next tasks
70 - import_tasks: start_supervisord.yml
71
72 - name: start py1 service (without auth)
73 supervisorctl:
74 name: 'pys:py1'
75 state: started
76 config: '{{ remote_dir }}/supervisord.conf'
77 register: result
78 when: credentials.username == ''
79
80 - name: start py1 service (with auth)
81 supervisorctl:
82 name: 'pys:py1'
83 state: started
84 server_url: http://127.0.0.1:9001
85 username: '{{ credentials.username }}'
86 password: '{{ credentials.password }}'
87 register: result_with_auth
88 when: credentials.username != ''
89
90 - name: check that service is started
91 assert:
92 that:
93 - (result is success and result_with_auth is skip) or (result is skip and result_with_auth is changed)
94 - (result is changed and result_with_auth is skip) or (result is skip and result_with_auth is changed)
95
96 #############################################################
97
98 - name: Check an error occurs when wrong credentials are used
99 supervisorctl:
100 name: pys:py1
101 state: started
102 server_url: http://127.0.0.1:9001
103 username: '{{ credentials.username }}wrong_creds'
104 password: '{{ credentials.password }}same_here'
105 register: result
106 failed_when: result is not skip and (result is success or result is not failed)
107 when: credentials.username != ''
108
109 - name: Check an error occurs when wrong URL is used
110 supervisorctl:
111 name: pys:py1
112 state: started
113 server_url: http://127.0.0.1:9002
114 register: result
115 failed_when: result is success or result is not failed
116
117 - name: Check an error occurs when wrong config path is used
118 supervisorctl:
119 name: 'pys:py1'
120 state: started
121 config: '{{ remote_dir }}/supervisord_not_here.conf'
122 register: result
123 failed_when: result is success or result is not failed
124
125 - name: Check an error occurs wrong name is used (without auth)
126 supervisorctl:
127 name: 'invalid'
128 state: started
129 config: '{{ remote_dir }}/supervisord.conf'
130 register: result
131 failed_when: result is skip or (result is success or result is not failed)
132 when: credentials.username == ''
133
134 - name: Check an error occurs wrong name is used (with auth)
135 supervisorctl:
136 name: 'invalid'
137 state: started
138 config: '{{ remote_dir }}/supervisord.conf'
139 username: '{{ credentials.username }}wrong_creds'
140 password: '{{ credentials.password }}same_here'
141 register: result
142 failed_when: result is skip or (result is success or result is not failed)
143 when: credentials.username != ''