rewrite schedule cancelling test
This commit is contained in:
parent
f48fa02916
commit
631055d190
2 changed files with 74 additions and 6 deletions
|
@ -1,18 +1,86 @@
|
|||
repo=root/example-$example
|
||||
#
|
||||
# delete the repository
|
||||
#
|
||||
api=$url/api/v1
|
||||
forgejo-curl.sh api_json -X DELETE $api/repos/root/example-$example
|
||||
|
||||
#
|
||||
# push the repository
|
||||
#
|
||||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
sha=$(forgejo-test-helper.sh branch_tip $url $repo main)
|
||||
|
||||
# Prevent test failure because the db is occupied
|
||||
sqlite3 $DIR/forgejo-work-path/forgejo.db "pragma busy_timeout=20000"
|
||||
|
||||
#
|
||||
# wait for the workflow (sleep infinity) to start running
|
||||
# get the run id of the workflow that just started
|
||||
#
|
||||
forgejo-test-helper.sh wait_running $url $repo $sha
|
||||
getScheduleRun() {
|
||||
sqlite3 $DIR/forgejo-work-path/forgejo.db \
|
||||
"select action_run.id \
|
||||
from action_run \
|
||||
inner join action_schedule on action_run.schedule_id = action_schedule.id \
|
||||
inner join repository on action_schedule.repo_id = repository.id \
|
||||
where repository.name = 'example-schedule-noncancel' \
|
||||
order by action_run.created desc limit 1"
|
||||
}
|
||||
|
||||
run_id=$(getScheduleRun)
|
||||
while [ -z $run_id ]; do
|
||||
echo waiting 5...
|
||||
sleep 5
|
||||
run_id=$(getScheduleRun)
|
||||
done
|
||||
|
||||
echo Schedule run id: $run_id
|
||||
|
||||
#
|
||||
# push to the same branch
|
||||
# Wait for it to be started
|
||||
#
|
||||
checkStarted() {
|
||||
sqlite3 $DIR/forgejo-work-path/forgejo.db \
|
||||
"select id \
|
||||
from action_run \
|
||||
where id = $run_id \
|
||||
and started is not null"
|
||||
}
|
||||
|
||||
started_check=$(checkStarted)
|
||||
while [ -z $started_check ]; do
|
||||
echo waiting 2...
|
||||
sleep 2
|
||||
started_check=$(checkStarted)
|
||||
done
|
||||
|
||||
echo Run has started
|
||||
echo Push to repo again
|
||||
|
||||
#
|
||||
# Push to the repo again
|
||||
#
|
||||
forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token
|
||||
|
||||
#
|
||||
# wait for the workflow to be canceled as a result of the previous push
|
||||
# Wait for the workflow to finish anyway
|
||||
#
|
||||
forgejo-test-helper.sh wait_success $url $repo $sha
|
||||
echo Wait for workflow to finish
|
||||
|
||||
checkFinished() {
|
||||
sqlite3 $DIR/forgejo-work-path/forgejo.db \
|
||||
"select status \
|
||||
from action_run \
|
||||
where id = $run_id \
|
||||
and status != 6"
|
||||
}
|
||||
|
||||
finished_status=$(checkFinished)
|
||||
while [ -z $finished_status ]; do
|
||||
echo waiting 5...
|
||||
sleep 5
|
||||
finished_status=$(checkFinished)
|
||||
done
|
||||
|
||||
echo Workflow finished.
|
||||
|
||||
test $finished_status = 1
|
||||
|
|
Loading…
Add table
Reference in a new issue