forked from dsariel/swiftacular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_workload_test.yml
75 lines (60 loc) · 2.44 KB
/
setup_workload_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Apply patch to sharder.py to ensure sharding is always set to true.
# Then run workloader and verification.
- name: Sharder patch
hosts: storage
become: yes
tasks:
- name: Copy the sharder patch file to the target host
copy:
src: sharder.patch
dest: /tmp/sharder.patch
- name: Install patch package
command: dnf install -y patch
- name: Apply sharder patch
shell: patch -p0 < /tmp/sharder.patch # Shell because '<' doesn't work otherwise
args:
chdir: /usr/lib/python3.9/site-packages/swift/container
- name: Stop sharders
command: swift-init container-sharder stop
ignore_errors: yes
- name: Start sharders
command: sudo swift-init container-sharder start
- name: Workload tests
hosts: package_cache
tasks:
- name: Copy tests directory to package_cache host
copy:
src: workload_tests
dest: /home/vagrant/
- name: Ensure pytest is installed
command: pip install pytest
# We're currently only running the tiny test. It would be good to run everything!
- name: Run workload tests
command: /usr/bin/python -m pytest test_workload.py::test_tiny_workload -svx
args:
chdir: /home/vagrant/workload_tests
register: pytest_result
- name: Verify sharding
hosts: storage
tasks:
# It's entirely possible that for bigger tests, it would take much longer than 10 minutes for sharding to complete.
- name: Wait for sharding
command: sleep 600
# The container name in the command is hard-coded to match the workloader test. It would be good to make it variable!
- name: Get container sharding results
shell: | # Big ugly command to check whether container is sharded.
for FILE in /srv/node/td*/containers/*/*/*/*.db; do swift-manage-shard-ranges $FILE info; done 2>&1 | grep '^Loaded.*the-test-container$' -A 20 | grep -m 1 "db_state" | sed -e "s/^db_state = //"
register: command_output
- name: Show output
debug:
var: command_output.stdout
- name: Check the output
fail:
msg: "The container is unsharded"
when: command_output.stdout == "unsharded"
- name: Check if sharded # Also succeeds if output is empty result, meaning no replica on host
command: sleep 0
retries: 1
delay: 0
until: command_output.stdout == "sharded" or command_output.stdout == ""
when: command_output.stdout != "sharded"