mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #6304/08f14f3e backport][stable-5] pids tests: 'some-' is not that a unique pattern. (#6305)
pids tests: 'some-' is not that a unique pattern. (#6304)
* 'some-' is not that a unique pattern.
* Add debugging help.
* Avoid passing the name as a parameter to obtainpid.sh.
(cherry picked from commit 08f14f3eb0
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
e113c8cf11
commit
c44f07a405
2 changed files with 18 additions and 10 deletions
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
- name: "Picking a random process name"
|
- name: "Picking a random process name"
|
||||||
set_fact:
|
set_fact:
|
||||||
random_name: some-random-long-name-{{ 99999999 | random }}
|
random_name: some-random-long-name-{{ 10000000000 + (9999999999 | random) }}
|
||||||
|
|
||||||
- name: Copy the fake 'sleep' source code
|
- name: Copy the fake 'sleep' source code
|
||||||
copy:
|
copy:
|
||||||
|
@ -43,15 +43,14 @@
|
||||||
- name: Compile fake 'sleep' binary
|
- name: Compile fake 'sleep' binary
|
||||||
command: cc {{ remote_tmp_dir }}/sleeper.c -o {{ remote_tmp_dir }}/{{ random_name }}
|
command: cc {{ remote_tmp_dir }}/sleeper.c -o {{ remote_tmp_dir }}/{{ random_name }}
|
||||||
|
|
||||||
- name: Copy helper script
|
- name: Copy templated helper script
|
||||||
copy:
|
template:
|
||||||
src: obtainpid.sh
|
src: obtainpid.sh
|
||||||
dest: "{{ remote_tmp_dir }}/obtainpid.sh"
|
dest: "{{ remote_tmp_dir }}/obtainpid.sh"
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: "Run the fake 'sleep' binary"
|
- name: "Run the fake 'sleep' binary"
|
||||||
command: "sh {{ remote_tmp_dir }}/obtainpid.sh '{{ remote_tmp_dir }}/{{ random_name }}' '{{ remote_tmp_dir }}/obtainpid.txt'"
|
command: sh {{ remote_tmp_dir }}/obtainpid.sh
|
||||||
|
|
||||||
async: 100
|
async: 100
|
||||||
poll: 0
|
poll: 0
|
||||||
|
|
||||||
|
@ -66,17 +65,17 @@
|
||||||
|
|
||||||
- name: "Checking that exact non-substring matches are required"
|
- name: "Checking that exact non-substring matches are required"
|
||||||
pids:
|
pids:
|
||||||
name: "{{ random_name[0:5] }}"
|
name: "{{ random_name[0:25] }}"
|
||||||
register: exactpidmatch
|
register: exactpidmatch
|
||||||
|
|
||||||
- name: "Checking that patterns can be used with the pattern option"
|
- name: "Checking that patterns can be used with the pattern option"
|
||||||
pids:
|
pids:
|
||||||
pattern: "{{ random_name[0:5] }}"
|
pattern: "{{ random_name[0:25] }}"
|
||||||
register: pattern_pid_match
|
register: pattern_pid_match
|
||||||
|
|
||||||
- name: "Checking that case-insensitive patterns can be used with the pattern option"
|
- name: "Checking that case-insensitive patterns can be used with the pattern option"
|
||||||
pids:
|
pids:
|
||||||
pattern: "{{ random_name[0:5] | upper }}"
|
pattern: "{{ random_name[0:25] | upper }}"
|
||||||
ignore_case: true
|
ignore_case: true
|
||||||
register: caseinsensitive_pattern_pid_match
|
register: caseinsensitive_pattern_pid_match
|
||||||
|
|
||||||
|
@ -90,6 +89,15 @@
|
||||||
src: "{{ remote_tmp_dir }}/obtainpid.txt"
|
src: "{{ remote_tmp_dir }}/obtainpid.txt"
|
||||||
register: newpid
|
register: newpid
|
||||||
|
|
||||||
|
- name: Gather all processes to make debugging easier
|
||||||
|
command: ps aux
|
||||||
|
register: result
|
||||||
|
no_log: true
|
||||||
|
|
||||||
|
- name: List all processes to make debugging easier
|
||||||
|
debug:
|
||||||
|
var: result.stdout_lines
|
||||||
|
|
||||||
- name: "Verify that the Process IDs (PIDs) returned is not empty and also equal to the PIDs obtained in console"
|
- name: "Verify that the Process IDs (PIDs) returned is not empty and also equal to the PIDs obtained in console"
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
"$1" 100 &
|
"{{ remote_tmp_dir }}/{{ random_name }}" 100 &
|
||||||
echo "$!" > "$2"
|
echo "$!" > "{{ remote_tmp_dir }}/obtainpid.txt"
|
Loading…
Reference in a new issue