Skip to content

Commit 572636a

Browse files
authored
Merge pull request #964 from moreati/test-tweaks
Test tweaks
2 parents 4a5d529 + a3a10cb commit 572636a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+289
-298
lines changed

.ci/ansible_tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ def pause_if_interactive():
6666
for container in containers
6767
)
6868

69-
for distro, hostnames in distros.items():
69+
for distro, hostnames in sorted(distros.items(), key=lambda t: t[0]):
7070
fp.write('\n[%s]\n' % distro)
7171
fp.writelines('%s\n' % name for name in hostnames)
7272

73-
for family, hostnames in families.items():
73+
for family, hostnames in sorted(families.items(), key=lambda t: t[0]):
7474
fp.write('\n[%s]\n' % family)
7575
fp.writelines('%s\n' % name for name in hostnames)
7676

77+
fp.write('\n[linux:children]\ntest-targets\n')
78+
7779
ci_lib.dump_file(inventory_path)
7880

7981
if not ci_lib.exists_in_path('sshpass'):

tests/ansible/ansible.cfg

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
[defaults]
22
any_errors_fatal = true
3+
# callback_whitelist naming will be deprecated in ansible-core >= 2.15.
4+
# callbacks_enabled naming was added in ansible-core 2.11
5+
# profile_tasks: Displays timing for each task and summary table of top N tasks
6+
# timer: Displays "Playbook run took 0 days, 0 hours, ..."
7+
callback_whitelist =
8+
profile_tasks,
9+
timer
310
inventory = hosts
411
gathering = explicit
512
strategy_plugins = ../../ansible_mitogen/plugins/strategy
613
inventory_plugins = lib/inventory
714
action_plugins = lib/action
815
callback_plugins = lib/callback
916
stdout_callback = yaml
10-
stdout_whitelist =
11-
profile_roles,
12-
timer,
13-
yaml
1417
vars_plugins = lib/vars
1518
library = lib/modules
1619
filter_plugins = lib/filters
1720
module_utils = lib/module_utils
1821
retry_files_enabled = False
22+
show_task_path_on_failure = true # Added in ansible-core 2.11
1923
display_args_to_stdout = True
2024
forks = 100
2125

@@ -31,7 +35,7 @@ transport = ssh
3135
no_target_syslog = True
3236

3337
# Required by integration/ssh/timeouts.yml
34-
timeout = 10
38+
timeout = 30
3539

3640
# On Travis, paramiko check fails due to host key checking enabled.
3741
host_key_checking = False

tests/ansible/bench/loop-20-templates.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
- name: bench/loop-20-templates.yml
22
hosts: all
33
tasks:
4-
- file:
4+
- name: Create loop templates dir
5+
file:
56
dest: /tmp/templates
67
state: "{{item}}"
78
with_items: ["absent", "directory"]
89

9-
- copy:
10+
- name: Copy loop files
11+
copy:
1012
dest: /tmp/templates/{{item}}
1113
mode: 0755
1214
content:

tests/ansible/integration/action/copy.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33
- name: integration/action/copy.yml
44
hosts: test-targets
55
tasks:
6-
- copy:
6+
- name: Create tiny file
7+
copy:
78
dest: /tmp/copy-tiny-file
89
content:
910
this is a tiny file.
1011
delegate_to: localhost
1112

12-
- copy:
13+
- name: Create large file
14+
copy:
1315
dest: /tmp/copy-large-file
1416
# Must be larger than Connection.SMALL_SIZE_LIMIT.
1517
content: "{% for x in range(200000) %}x{% endfor %}"
1618
delegate_to: localhost
1719

18-
# end of making files
19-
20-
- file:
20+
- name: Cleanup copied files
21+
file:
2122
state: absent
2223
path: "{{item}}"
2324
with_items:
@@ -26,28 +27,31 @@
2627
- /tmp/copy-tiny-inline-file.out
2728
- /tmp/copy-large-inline-file.out
2829

29-
# end of cleaning out files
30-
31-
- copy:
30+
- name: Copy large file
31+
copy:
3232
dest: /tmp/copy-large-file.out
3333
src: /tmp/copy-large-file
3434

35-
- copy:
35+
- name: Copy tiny file
36+
copy:
3637
dest: /tmp/copy-tiny-file.out
3738
src: /tmp/copy-tiny-file
3839

39-
- copy:
40+
- name: Copy tiny inline file
41+
copy:
4042
dest: /tmp/copy-tiny-inline-file.out
4143
content: "tiny inline content"
4244

43-
- copy:
45+
- name: Copy large inline file
46+
copy:
4447
dest: /tmp/copy-large-inline-file.out
4548
content: |
4649
{% for x in range(200000) %}y{% endfor %}
4750
4851
# stat results
4952

50-
- stat:
53+
- name: Stat copied files
54+
stat:
5155
path: "{{item}}"
5256
with_items:
5357
- /tmp/copy-tiny-file.out
@@ -64,7 +68,8 @@
6468
- stat.results[3].stat.checksum == "d675f47e467eae19e49032a2cc39118e12a6ee72"
6569
fail_msg: stat={{stat}}
6670

67-
- file:
71+
- name: Cleanup files
72+
file:
6873
state: absent
6974
path: "{{item}}"
7075
with_items:

tests/ansible/integration/action/fixup_perms2__copy.yml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
- name: integration/action/fixup_perms2__copy.yml
77
hosts: test-targets
88
tasks:
9-
#
10-
# copy module (no mode).
11-
#
12-
139
- name: "Copy files (no mode)"
1410
copy:
1511
content: ""
@@ -22,10 +18,6 @@
2218
- out.stat.mode in ("0644", "0664")
2319
fail_msg: out={{out}}
2420

25-
#
26-
# copy module (explicit mode).
27-
#
28-
2921
- name: "Copy files from content: arg"
3022
copy:
3123
content: ""
@@ -39,22 +31,20 @@
3931
- out.stat.mode == "0400"
4032
fail_msg: out={{out}}
4133

42-
#
43-
# copy module (existing disk files, no mode).
44-
#
45-
46-
- file:
34+
- name: Cleanup local weird mode file
35+
file:
4736
path: /tmp/weird-mode.out
4837
state: absent
4938

50-
- name: Create local test file.
39+
- name: Create local weird mode file
5140
delegate_to: localhost
5241
copy:
5342
content: "weird mode"
5443
dest: "/tmp/weird-mode"
5544
mode: "1462"
5645

57-
- copy:
46+
- name: Copy file with weird mode
47+
copy:
5848
src: "/tmp/weird-mode"
5949
dest: "/tmp/weird-mode.out"
6050

@@ -66,11 +56,8 @@
6656
- out.stat.mode in ("0644", "0664")
6757
fail_msg: out={{out}}
6858

69-
#
70-
# copy module (existing disk files, preserve mode).
71-
#
72-
73-
- copy:
59+
- name: Copy file with weird mode, preserving mode
60+
copy:
7461
src: "/tmp/weird-mode"
7562
dest: "/tmp/weird-mode"
7663
mode: preserve
@@ -83,11 +70,8 @@
8370
- out.stat.mode == "1462"
8471
fail_msg: out={{out}}
8572

86-
#
87-
# copy module (existing disk files, explicit mode).
88-
#
89-
90-
- copy:
73+
- name: Copy file with weird mode, explicit mode
74+
copy:
9175
src: "/tmp/weird-mode"
9276
dest: "/tmp/weird-mode"
9377
mode: "1461"
@@ -101,7 +85,8 @@
10185
- out.stat.mode == "1461"
10286
fail_msg: out={{out}}
10387

104-
- file:
88+
- name: Cleanup
89+
file:
10590
state: absent
10691
path: "{{item}}"
10792
with_items:

tests/ansible/integration/action/remote_file_exists.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,32 @@
22
- name: integration/action/remote_file_exists.yml
33
hosts: test-targets
44
tasks:
5-
6-
- file:
5+
- name: Ensure does-not-exist doesnt
6+
file:
77
path: /tmp/does-not-exist
88
state: absent
9-
109
- action_passthrough:
1110
method: _remote_file_exists
1211
args: ['/tmp/does-not-exist']
1312
register: out
14-
1513
- assert:
1614
that: out.result == False
1715
fail_msg: out={{out}}
1816

19-
# ---
20-
21-
- copy:
17+
- name: Ensure does-exist does
18+
copy:
2219
dest: /tmp/does-exist
2320
content: "I think, therefore I am"
24-
2521
- action_passthrough:
2622
method: _remote_file_exists
2723
args: ['/tmp/does-exist']
2824
register: out
29-
3025
- assert:
3126
that: out.result == True
3227
fail_msg: out={{out}}
3328

34-
- file:
29+
- name: Cleanup
30+
file:
3531
path: /tmp/does-exist
3632
state: absent
3733
tags:

tests/ansible/integration/action/remove_tmp_path.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
# return a result with a 'src' attribute pointing into that directory.
1111
#
1212

13-
- copy:
13+
- name: Ensure remove_tmp_path_test
14+
copy:
1415
dest: /tmp/remove_tmp_path_test
1516
content: "{{ 123123 | random }}"
1617
register: out

tests/ansible/integration/action/synchronize.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,27 @@
1212
ansible_password: ''
1313
tasks:
1414
# must copy git file to set proper file mode.
15-
- copy:
15+
- name: Copy synchronize-action-key
16+
copy:
1617
dest: /tmp/synchronize-action-key
1718
src: ../../../data/docker/mitogen__has_sudo_pubkey.key
1819
mode: u=rw,go=
1920
delegate_to: localhost
2021

21-
- file:
22+
- name: Cleanup sync-test
23+
file:
2224
path: /tmp/sync-test
2325
state: absent
2426
delegate_to: localhost
2527

26-
- file:
28+
- name: Create sync-test
29+
file:
2730
path: /tmp/sync-test
2831
state: directory
2932
delegate_to: localhost
3033

31-
- copy:
34+
- name: Create syn-test item
35+
copy:
3236
dest: /tmp/sync-test/item
3337
content: "item!"
3438
delegate_to: localhost

tests/ansible/integration/action/transfer_data.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,45 @@
22
- name: integration/action/transfer_data.yml
33
hosts: test-targets
44
tasks:
5-
6-
- file:
5+
- name: Cleanup transfer data
6+
file:
77
path: /tmp/transfer-data
88
state: absent
99

10-
# Ensure it JSON-encodes dicts.
11-
- action_passthrough:
10+
- name: Create JSON transfer data
11+
action_passthrough:
1212
method: _transfer_data
1313
kwargs:
1414
remote_path: /tmp/transfer-data
1515
data: {
1616
"I am JSON": true
1717
}
18-
19-
- slurp:
18+
- name: Slurp JSON transfer data
19+
slurp:
2020
src: /tmp/transfer-data
2121
register: out
22-
2322
- assert:
2423
that: |
2524
out.content|b64decode == '{"I am JSON": true}'
2625
fail_msg: out={{out}}
2726

28-
29-
# Ensure it handles strings.
30-
- action_passthrough:
27+
- name: Create text transfer data
28+
action_passthrough:
3129
method: _transfer_data
3230
kwargs:
3331
remote_path: /tmp/transfer-data
3432
data: "I am text."
35-
36-
- slurp:
33+
- name: Slurp text transfer data
34+
slurp:
3735
src: /tmp/transfer-data
3836
register: out
39-
4037
- assert:
4138
that:
4239
out.content|b64decode == 'I am text.'
4340
fail_msg: out={{out}}
4441

45-
- file:
42+
- name: Cleanup transfer data
43+
file:
4644
path: /tmp/transfer-data
4745
state: absent
4846
tags:

tests/ansible/integration/async/result_binary_producing_json.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
retries: 100000
3838
delay: 0
3939

40-
- slurp:
40+
- name: Slurp async busy-poll
41+
slurp:
4142
src: "{{ansible_user_dir}}/.ansible_async/{{job.ansible_job_id}}"
4243
register: result
4344

0 commit comments

Comments
 (0)