Skip to content

Commit e395050

Browse files
committed
[container_benchmark] Deduplicate Ansible tasks for container benchmarks
Signed-off-by: Jan Rodák <[email protected]>
1 parent 4e9654c commit e395050

File tree

22 files changed

+444
-249
lines changed

22 files changed

+444
-249
lines changed

projects/container_bench/toolbox/container_bench_capture_container_engine_info/tasks/main.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
# Define common command template
3-
- name: Set common command
2+
- name: Set info command
43
set_fact:
54
container_info_command: "{{ container_bench_capture_container_engine_info_binary_path }} {{ container_bench_capture_container_engine_info_additional_args }} info --format json"
65

projects/container_bench/toolbox/container_bench_capture_container_engine_info/tasks/unix.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
2-
# Create artifacts directory
3-
- name: Create the artifacts directory
4-
file:
5-
path: "{{ artifact_extra_logs_dir }}/artifacts"
6-
state: directory
7-
mode: '0755'
2+
- name: Include shared artifacts directory creation
3+
include_tasks: "../../shared_tasks/create_artifacts_dir.yml"
84

9-
# Capture container engine information
105
- name: Capture the container engine information
116
become: "{{ container_bench_capture_container_engine_info_rootfull }}"
127
shell: |

projects/container_bench/toolbox/container_bench_capture_container_engine_info/tasks/windows.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
---
2-
# Create artifacts directory
3-
- name: Create the artifacts directory
4-
ansible.windows.win_file:
5-
path: "{{ artifact_extra_logs_dir }}\\artifacts"
6-
state: directory
2+
- name: Include shared artifacts directory creation
3+
include_tasks: "../../shared_tasks/create_artifacts_dir.yml"
74

8-
# Capture container engine information
95
- name: Capture the container engine information
106
ansible.windows.win_shell: |
117
$output = {{ container_info_command }}
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
2-
# Create artifacts directory
3-
- name: Create the artifacts directory
4-
file:
5-
path: "{{ artifact_extra_logs_dir }}/artifacts"
6-
state: directory
7-
mode: '0755'
2+
- name: Include shared artifacts directory creation
3+
include_tasks: "../../shared_tasks/create_artifacts_dir.yml"
84

9-
# Capture system information - macOS/Darwin
105
- name: Capture the system versions (macOS only)
116
shell: system_profiler SPSoftwareDataType SPHardwareDataType > "{{ artifact_extra_logs_dir }}/artifacts/system_info.txt"

projects/container_bench/toolbox/container_bench_capture_system_state/tasks/linux.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
2-
# Create artifacts directory
3-
- name: Create the artifacts directory
4-
file:
5-
path: "{{ artifact_extra_logs_dir }}/artifacts"
6-
state: directory
7-
mode: '0755'
2+
- name: Include shared artifacts directory creation
3+
include_tasks: "../../shared_tasks/create_artifacts_dir.yml"
84

9-
# Capture system information - Linux
105
- name: Capture the system information
116
shell: |
127
set -o pipefail

projects/container_bench/toolbox/container_bench_capture_system_state/tasks/windows.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
---
2-
# Create artifacts directory
3-
- name: Create the artifacts directory
4-
ansible.windows.win_file:
5-
path: "{{ artifact_extra_logs_dir }}\\artifacts"
6-
state: directory
2+
- name: Include shared artifacts directory creation
3+
include_tasks: "../../shared_tasks/create_artifacts_dir.yml"
74

8-
# Capture system information - Windows
95
- name: Capture the system information
106
ansible.windows.win_shell: |
117
# Create output file and add Software section header
Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
---
2-
# Define common command templates (shared across all platforms)
3-
- name: Set common commands
2+
- name: Validate required variables are defined
3+
assert:
4+
that:
5+
- container_bench_exec_benchmark_exec_time_path is defined
6+
- container_bench_exec_benchmark_binary_path is defined
7+
- container_bench_exec_benchmark_rootfull is defined
8+
- container_bench_exec_benchmark_additional_args is defined
9+
when: false # This task never runs but validates variable definitions
10+
11+
- include_tasks: "../../shared_tasks/map_variables.yml"
12+
vars:
13+
role_name: "container_bench_exec_benchmark"
14+
15+
- name: Set common commands (shared across all platforms)
416
set_fact:
17+
image_to_pull: "registry.fedoraproject.org/fedora:latest"
518
prepare_commands: |
6-
{{ container_bench_exec_benchmark_binary_path }} {{ container_bench_exec_benchmark_additional_args }} system prune -a -f
7-
{{ container_bench_exec_benchmark_binary_path }} {{ container_bench_exec_benchmark_additional_args }} pull registry.fedoraproject.org/fedora:latest
8-
{{ container_bench_exec_benchmark_binary_path }} {{ container_bench_exec_benchmark_additional_args }} run --name benchmark_exec -d registry.fedoraproject.org/fedora:latest sleep infinity
19+
{{ binary_path }} {{ additional_args }} run --name benchmark_exec -d registry.fedoraproject.org/fedora:latest sleep infinity
920
cleanup_commands: |
10-
{{ container_bench_exec_benchmark_binary_path }} {{ container_bench_exec_benchmark_additional_args }} stop benchmark_exec
11-
{{ container_bench_exec_benchmark_binary_path }} {{ container_bench_exec_benchmark_additional_args }} rm -f benchmark_exec
12-
{{ container_bench_exec_benchmark_binary_path }} {{ container_bench_exec_benchmark_additional_args }} system prune -a -f
21+
{{ binary_path }} {{ additional_args }} stop benchmark_exec
22+
{{ binary_path }} {{ additional_args }} rm -f benchmark_exec
1323
benchmark_command: |
14-
{{ container_bench_exec_benchmark_binary_path }} {{ container_bench_exec_benchmark_additional_args }} exec benchmark_exec true
24+
{{ binary_path }} {{ additional_args }} exec benchmark_exec true
1525
1626
- name: Include Unix/Linux tasks
17-
include_tasks: unix.yml
27+
include_tasks: "../../shared_tasks/unix_default_benchmark_body.yml"
1828
when: ansible_os_family != 'Windows'
1929

2030
- name: Include Windows tasks
21-
include_tasks: windows.yml
31+
include_tasks: ../../shared_tasks/windows_default_benchmark_body.yml
2232
when: ansible_os_family == 'Windows'

projects/container_bench/toolbox/container_bench_exec_benchmark/tasks/unix.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

projects/container_bench/toolbox/container_bench_exec_benchmark/tasks/windows.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
---
2-
# Define common command templates (shared across all platforms)
3-
- name: Set common commands
2+
- name: Validate required variables are defined
3+
assert:
4+
that:
5+
- container_bench_helloworld_benchmark_exec_time_path is defined
6+
- container_bench_helloworld_benchmark_binary_path is defined
7+
- container_bench_helloworld_benchmark_rootfull is defined
8+
- container_bench_helloworld_benchmark_additional_args is defined
9+
when: false # This task never runs but validates variable definitions
10+
11+
- include_tasks: "../../shared_tasks/map_variables.yml"
12+
vars:
13+
role_name: "container_bench_helloworld_benchmark"
14+
15+
- name: Set common commands (shared across all platforms)
416
set_fact:
5-
prepare_commands: |
6-
{{ container_bench_helloworld_benchmark_binary_path }} {{ container_bench_helloworld_benchmark_additional_args }} system prune -a -f
7-
{{ container_bench_helloworld_benchmark_binary_path }} {{ container_bench_helloworld_benchmark_additional_args }} pull quay.io/podman/hello
8-
cleanup_commands: |
9-
{{ container_bench_helloworld_benchmark_binary_path }} {{ container_bench_helloworld_benchmark_additional_args }} system prune -a -f
17+
image_to_pull: "quay.io/podman/hello"
18+
prepare_commands: "" # Image is pulled using shared pull_image task below
19+
cleanup_commands: "" # Cleanup handled by shared tasks
1020
benchmark_command: |
11-
{{ container_bench_helloworld_benchmark_binary_path }} {{ container_bench_helloworld_benchmark_additional_args }} run --rm quay.io/podman/hello
21+
{{ binary_path }} {{ additional_args }} run --rm quay.io/podman/hello
1222
1323
- name: Include Unix/Linux tasks
14-
include_tasks: unix.yml
24+
include_tasks: "../../shared_tasks/unix_default_benchmark_body.yml"
1525
when: ansible_os_family != 'Windows'
1626

1727
- name: Include Windows tasks
18-
include_tasks: windows.yml
28+
include_tasks: "../../shared_tasks/windows_default_benchmark_body.yml"
1929
when: ansible_os_family == 'Windows'

0 commit comments

Comments
 (0)