mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
pids: re-enabled tests on Alpine Linux (#4405)
* [WIP] pids: re-enabled tests on Alpine Linux * trying to compile a simple-faked sleep command * make FreeBSD happy * remove the block testing for Alpine Linux * simpler version of sleeper.c * simpler version of sleeper.c, part II * Update tests/integration/targets/pids/tasks/main.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update tests/integration/targets/pids/tasks/main.yml Co-authored-by: Felix Fontein <felix@fontein.de> * added license to sleeper.c file Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
24ca69aa05
commit
21ee4c84b7
3 changed files with 96 additions and 91 deletions
12
tests/integration/targets/pids/files/sleeper.c
Normal file
12
tests/integration/targets/pids/files/sleeper.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* (c) 2022, Alexei Znamensky <russoz@gmail.com>
|
||||||
|
* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int delay = atoi(argv[1]);
|
||||||
|
sleep(delay);
|
||||||
|
}
|
|
@ -7,10 +7,6 @@
|
||||||
# Copyright: (c) 2019, Saranya Sridharan
|
# Copyright: (c) 2019, Saranya Sridharan
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- when:
|
|
||||||
- not (ansible_os_family == 'Alpine') # TODO
|
|
||||||
block:
|
|
||||||
|
|
||||||
- name: Attempt installation of latest 'psutil' version
|
- name: Attempt installation of latest 'psutil' version
|
||||||
pip:
|
pip:
|
||||||
name: psutil
|
name: psutil
|
||||||
|
@ -37,35 +33,32 @@
|
||||||
set_fact:
|
set_fact:
|
||||||
random_name: some-random-long-name-{{ 99999999 | random }}
|
random_name: some-random-long-name-{{ 99999999 | random }}
|
||||||
|
|
||||||
- name: "finding the 'sleep' binary"
|
- name: Copy the fake 'sleep' source code
|
||||||
command: which sleep
|
copy:
|
||||||
register: find_sleep
|
src: sleeper.c
|
||||||
|
dest: "{{ remote_tmp_dir }}/sleeper.c"
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: "Copying 'sleep' binary"
|
- name: Compile fake 'sleep' binary
|
||||||
command: cp {{ find_sleep.stdout }} {{ remote_tmp_dir }}/{{ random_name }}
|
command: cc {{ remote_tmp_dir }}/sleeper.c -o {{ remote_tmp_dir }}/{{ random_name }}
|
||||||
# The following does not work on macOS 11.1 (it uses shutil.copystat, and that will die with a PermissionError):
|
|
||||||
# copy:
|
|
||||||
# src: "{{ find_sleep.stdout }}"
|
|
||||||
# dest: "{{ remote_tmp_dir }}/{{ random_name }}"
|
|
||||||
# mode: "0777"
|
|
||||||
# remote_src: true
|
|
||||||
|
|
||||||
- name: Copy helper script
|
- name: Copy helper script
|
||||||
copy:
|
copy:
|
||||||
src: obtainpid.sh
|
src: obtainpid.sh
|
||||||
dest: "{{ remote_tmp_dir }}/obtainpid.sh"
|
dest: "{{ remote_tmp_dir }}/obtainpid.sh"
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
- name: "Running the copy of '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 '{{ remote_tmp_dir }}/{{ random_name }}' '{{ remote_tmp_dir }}/obtainpid.txt'"
|
||||||
|
|
||||||
async: 100
|
async: 100
|
||||||
poll: 0
|
poll: 0
|
||||||
|
|
||||||
- name: "Wait for one second to make sure that the sleep copy has actually been started"
|
- name: "Wait for one second to make sure that the fake 'sleep' binary has actually been started"
|
||||||
pause:
|
pause:
|
||||||
seconds: 1
|
seconds: 1
|
||||||
|
|
||||||
- name: "Checking the process IDs (PIDs) of sleep binary"
|
- name: "Checking the process IDs (PIDs) of fake 'sleep' binary"
|
||||||
pids:
|
pids:
|
||||||
name: "{{ random_name }}"
|
name: "{{ random_name }}"
|
||||||
register: pids
|
register: pids
|
||||||
|
|
Loading…
Reference in a new issue