Skip to content

Commit

Permalink
tests: Calculate boot duration
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Gladkov <[email protected]>
  • Loading branch information
legionus committed Apr 17, 2023
1 parent 0b4c000 commit fe4d559
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ jobs:
QEMU_DISK_FORMAT: qcow2
run: testing/testing-${{ matrix.name }}-${{ matrix.test }} test-root-${{ matrix.testcase }} run-boot

- name: "Archive Metrics"
uses: actions/upload-artifact@v3
with:
name: "metrics-${{ matrix.name }}-${{ matrix.test }}-${{ matrix.testcase }}"
path: testing/status/artifact-*.txt
if-no-files-found: ignore
retention-days: 1


e2e-network:
name: "${{ matrix.name }} ${{ matrix.test }} ${{ matrix.testcase }}"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -163,3 +172,35 @@ jobs:
QEMU_MEMORY: 1G
QEMU_DISK_FORMAT: qcow2
run: testing/testing-${{ matrix.name }}-${{ matrix.test }} test-root-${{ matrix.testcase }} run-boot

- name: "Archive Metrics"
uses: actions/upload-artifact@v3
with:
name: "metrics-${{ matrix.name }}-${{ matrix.test }}-${{ matrix.testcase }}"
path: testing/status/artifact-*.txt
if-no-files-found: ignore
retention-days: 1


boot-duration:
name: "Metrics"
needs: [ e2e-local, e2e-network ]
runs-on: ubuntu-latest
if: always()
steps:
- name: "Checkout Repository"
uses: actions/checkout@v3

- name: "Download Metrics"
uses: actions/download-artifact@v3
with:
path: artifacts

- name: "Summarize"
run: testing/generate-metrics artifacts > "$GITHUB_STEP_SUMMARY"

- name: "Remove Artifacts"
uses: geekyeggo/delete-artifact@v2
with:
name: metrics-*
failOnError: false
66 changes: 66 additions & 0 deletions testing/generate-metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash -efu

artifacts="$1"
shift

maxlen="####################################################################################################################"

find "$artifacts" -name 'artifact-*.txt' -printf '%f\t%p\n' |
sort -k1,1 |
cut -f2- > "/tmp/artifacts.list"

max_testname_len=0
max_duration_len=0
max_duration=0

while read -r f; do
. "$f"
testname="${testname#test-root-}"
[ "$max_testname_len" -gt "${#testname}" ] || max_testname_len="${#testname}"
[ "$max_duration_len" -gt "${#duration}" ] || max_duration_len="${#duration}"
[ "$max_duration" -gt "${duration}" ] || max_duration="${duration}"
done < "/tmp/artifacts.list"

prev_vendor=""
while read -r f; do
. "$f"

testname="${testname#test-root-}"

if [ "$prev_vendor" != "$vendor" ]; then
[ -z "$prev_vendor" ] ||
printf '```\n'
printf '### Vendor: %s\n' "$vendor"
printf '```\n'
fi

state="x"
[ "${status:-0}" -eq 0 ] || state="!"

prefix=""
printf -v prefix "[%s] %-${max_testname_len}s | %${max_duration_len}d s |" \
"$state" "$testname" "$duration"

rest=$(( ${#maxlen} - ${#prefix} ))
max=$(( $max_duration ))
len=$(( $duration ))

if [ $max_duration -gt $rest ]; then
over=$(( $max_duration - $rest ))
max=$(( $max - $over ))
len=$(( $len - $over ))
fi

printf '%s' "$prefix"
for (( i=0; i < max; i++)) {
[ $i -lt $len ] && printf '#' || printf '-'
}
printf '\n'

prev_vendor="$vendor"
done < "/tmp/artifacts.list"

if [ -n "$prev_vendor" ]; then
printf '```\n'
fi

36 changes: 35 additions & 1 deletion testing/sh-functions
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pack_sysimage()
--mount="type=bind,src=$topdir/guess,dst=/image$builddir/guess" \
--mount="type=bind,src=$topdir/tools,dst=/image$builddir/tools" \
--volume="$topdir:/host" \
"localhost/mi-$VENDOR:sysimage" "/host/$workdir/run.sh"
"localhost/mi-$VENDOR:sys" "/host/$workdir/run.sh"
}

prepare_testsuite()
Expand Down Expand Up @@ -279,6 +279,29 @@ qemu_setup_kickstart_disks()
qemu_activate_disks
}

qemu_calc_boot_duration()
{
local start=''
local stop=''

sed -r -n -e '/^Booting from Hard Disk\.\.\./,${ s/^\[([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})\] .*/\1/p }' |
sort -u |
sed -r -n -e '1p' -e '$p' |
while read -r s; do
t="$(date --date="$s +0000" '+%s')"

if [ -z "$start" ]; then
start="$t"
continue
elif [ -z "$stop" ]; then
stop="$t"
fi

echo "$(( $stop - $start ))"
break
done
}

qemu_exec()
{
create_qemu_wrapper "$top_workdir/qemu-bin"
Expand All @@ -292,6 +315,17 @@ qemu_exec()
valid_log 'check' "$top_logdir/qemu.log" ||
rc=$?

local duration=0

[ "$rc" -ne 0 ] ||
duration="$(qemu_calc_boot_duration < "$top_logdir/qemu.log" ||:)"
{
printf 'vendor="%q"\n' "$VENDOR"
printf 'testname="%q"\n' "$TESTNAME"
printf 'duration=%d\n' "${duration:-0}"
printf 'status=%d\n' "$rc"
} > "$statusdir/artifact-$VENDOR-$TESTNAME.txt"

set -- ${BOOT_LOGS-}

while [ "$#" -gt 0 ]; do
Expand Down
4 changes: 4 additions & 0 deletions testing/testing-altlinux-local
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ for step in "$@"; do
find /var/lib/apt/lists/ /var/cache/apt/ -type f -delete;
EOF

run podman image tag \
"localhost/mi-$VENDOR:sysimage" \
"localhost/mi-$VENDOR:sys"

gh_group_end
fi

Expand Down
2 changes: 2 additions & 0 deletions testing/testing-altlinux-sshfs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ for step in "$@"; do
BOOT_LOGS="$top_logdir/sshd.log"

gh_group_start "checking the ability to boot"

qemu_setup_cpu
qemu_exec

gh_group_end
;;
*)
Expand Down
4 changes: 4 additions & 0 deletions testing/testing-fedora-local
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ for step in "$@"; do
; do [ ! -d "\$d" ] || find "\$d" -mindepth 1 -delete ||:; done
EOF

run podman image tag \
"localhost/mi-$VENDOR:sysimage" \
"localhost/mi-$VENDOR:sys"

gh_group_end
fi

Expand Down
4 changes: 4 additions & 0 deletions testing/testing-ubuntu-local
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ for step in "$@"; do
find /var/lib/apt/lists/ /var/cache/apt/ -type f -delete;
EOF

run podman image tag \
"localhost/mi-$VENDOR:sysimage" \
"localhost/mi-$VENDOR:sys"

gh_group_end
fi

Expand Down

0 comments on commit fe4d559

Please sign in to comment.