Debian Codegraph @

test/integration/targets/ansiballz_python/tasks/main.yml

raw
1 - include_tasks: embed.yml
2
3 - name: get the ansible-test imposed file descriptor limit
4 check_rlimit_and_maxfd:
5 register: rlimit_limited_return
6
7 - name: get existing file descriptor limit
8 check_rlimit_and_maxfd:
9 register: rlimit_original_return
10 vars:
11 ansible_python_module_rlimit_nofile: 0 # ignore limit set by ansible-test
12
13 - name: attempt to set a value lower than existing soft limit
14 check_rlimit_and_maxfd:
15 vars:
16 ansible_python_module_rlimit_nofile: '{{ rlimit_original_return.rlimit_nofile[0] - 1 }}'
17 register: rlimit_below_soft_return
18
19 - name: attempt to set a value higher than existing soft limit
20 check_rlimit_and_maxfd:
21 vars:
22 ansible_python_module_rlimit_nofile: '{{ rlimit_original_return.rlimit_nofile[0] + 1 }}'
23 register: rlimit_above_soft_return
24
25 - name: attempt to set a value lower than existing hard limit
26 check_rlimit_and_maxfd:
27 vars:
28 ansible_python_module_rlimit_nofile: '{{ rlimit_original_return.rlimit_nofile[1] - 1 }}'
29 register: rlimit_below_hard_return
30
31 - name: attempt to set a value higher than existing hard limit
32 check_rlimit_and_maxfd:
33 vars:
34 ansible_python_module_rlimit_nofile: '{{ rlimit_original_return.rlimit_nofile[1] + 1 }}'
35 register: rlimit_above_hard_return
36
37 - name: run a role module which uses a role module_util using relative imports
38 custom_module:
39 register: custom_module_return
40
41 - assert:
42 that:
43 # make sure ansible-test was able to set the limit unless it exceeds the hard limit or the value is lower on macOS
44 - rlimit_limited_return.rlimit_nofile[0] == 1024 or rlimit_original_return.rlimit_nofile[1] < 1024 or (rlimit_limited_return.rlimit_nofile[0] < 1024 and ansible_distribution == 'MacOSX')
45 # make sure that maxfd matches the soft limit on Python 2.x (-1 on Python 3.x)
46 - rlimit_limited_return.maxfd == rlimit_limited_return.rlimit_nofile[0] or rlimit_limited_return.maxfd == -1
47
48 # we should always be able to set the limit lower than the existing soft limit
49 - rlimit_below_soft_return.rlimit_nofile[0] == rlimit_original_return.rlimit_nofile[0] - 1
50 # the hard limit should not have changed
51 - rlimit_below_soft_return.rlimit_nofile[1] == rlimit_original_return.rlimit_nofile[1]
52 # lowering the limit should also lower the max file descriptors reported by Python 2.x (-1 on Python 3.x)
53 - rlimit_below_soft_return.maxfd == rlimit_original_return.rlimit_nofile[0] - 1 or rlimit_below_soft_return.maxfd == -1
54
55 # we should be able to set the limit higher than the existing soft limit if it does not exceed the hard limit (except on macOS)
56 - rlimit_above_soft_return.rlimit_nofile[0] == rlimit_original_return.rlimit_nofile[0] + 1 or rlimit_original_return.rlimit_nofile[0] == rlimit_original_return.rlimit_nofile[1] or ansible_distribution == 'MacOSX'
57
58 # we should be able to set the limit lower than the existing hard limit (except on macOS)
59 - rlimit_below_hard_return.rlimit_nofile[0] == rlimit_original_return.rlimit_nofile[1] - 1 or ansible_distribution == 'MacOSX'
60
61 # setting the limit higher than the existing hard limit should use the hard limit (except on macOS)
62 - rlimit_above_hard_return.rlimit_nofile[0] == rlimit_original_return.rlimit_nofile[1] or ansible_distribution == 'MacOSX'
63
64 # custom module returned the correct answer
65 - custom_module_return.answer == 42
66
67 # https://github.com/ansible/ansible/issues/64664
68 # https://github.com/ansible/ansible/issues/64479
69 - name: Run module that tries to access itself via sys.modules
70 sys_check: