Skip to content

Commit e6b78d2

Browse files
committed
beaker-tests: show progress while waiting for module builds
1 parent 5dbf291 commit e6b78d2

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

beaker-tests/Sanity/copr-cli-basic-operations/helpers

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ setup_checks()
127127
# mismatch, such tests will fail and it is not trivial to find out why.
128128
rlRun "cat /etc/os-release |grep VERSION_ID=${FEDORA_VERSION}"
129129
}
130+
131+
join_lines()
132+
{
133+
tr '\n' ' ' | sed 's/ $//'
134+
}

beaker-tests/Sanity/copr-cli-basic-operations/runtest-modules.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,25 @@ function wait_for_finished_module()
4444
local packages=$2
4545
local tmp=$3
4646
local timeout=1800
47-
local started=$(date +%s)
47+
local started now built_count states states_one_line
48+
49+
started=$(date +%s)
50+
rlLog "Waiting till packages are built: $packages"
4851
while :; do
4952
now=$(date +%s)
50-
copr-cli list-packages $project --with-all-builds > $tmp
51-
if [ `cat $tmp |grep state |grep "succeeded\|failed" |wc -l` -eq $packages ]; then break; fi;
52-
if [ $(($now - $timeout)) -gt $started ]; then break; fi;
53+
copr-cli list-packages "$project" --with-all-builds > "$tmp"
54+
states=$(jq '.[].builds[].state' < "$tmp")
55+
states_one_line=$(echo "$states" | join_lines)
56+
built_count=$(echo "$states" | grep -e succeeded -e failed -e canceled -c)
57+
rlLog "Currently existing packages: $(jq '.[].name' < "$tmp" | join_lines) (states: $states_one_line)"
58+
if test "$built_count" -ge "$packages"; then
59+
rlLogInfo "Successful waiting for $packages builds, states: $states_one_line"
60+
break
61+
fi
62+
if [ $(( now - timeout)) -gt "$started" ]; then
63+
rlLogFatal "This waiting is taking too long... stopping."
64+
break
65+
fi
5366
sleep 10
5467
done
5568
}
@@ -64,7 +77,7 @@ function test_successful_packages()
6477
local tmp=$2
6578
rlAssertEquals "All packages should succeed" `cat $tmp |grep "state" | grep "succeeded" |wc -l` `echo $packages |wc -w`
6679
for pkg in $packages; do
67-
rlAssertEquals "Package $pkg is missing" `cat $tmp |jq '.[] | .name' |grep "$pkg" |wc -l` 1
80+
rlAssertEquals "Package $pkg is present" "$(jq '.[].name' <"$tmp" | grep "$pkg" -c)" 1
6881
done
6982
}
7083

0 commit comments

Comments
 (0)