-
Notifications
You must be signed in to change notification settings - Fork 22
/
trigger-openqa_in_openqa
executable file
·101 lines (88 loc) · 3.79 KB
/
trigger-openqa_in_openqa
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash -ex
# Trigger tests on an openQA instance testing openQA itself.
#
# Can be configured by variables.
set -euo pipefail
# shellcheck source=/dev/null
. "$(dirname "$0")"/_common
# configuration variables with defaults.
target_host="${target_host:-"openqa.opensuse.org"}"
target_host_proto="${target_host_proto:-"https"}"
dry_run="${dry_run:-"0"}"
tw_openqa_host="${tw_openqa_host:-"https://openqa.opensuse.org"}"
tw_group_id="${tw_group_id:-"1"}"
openqa_cli="${openqa_cli:-"openqa-cli"}"
arch="${arch:-"x86_64"}"
machine="${machine:-"64bit"}"
build_tag=${BUILD_TAG:-}
client_prefix=${client_prefix:-}
full_run=${FULL:-}
group_id="${group_id:-"openQA"}"
osc=${osc:-osc}
src_project=${src_project:-devel:openQA}
staging_project=${staging_project:-${src_project}:testing}
dst_project=${dst_project:-${src_project}:tested}
# shellcheck source=/dev/null
. "$(dirname "$0")"/_common
main() {
[[ $dry_run == 1 ]] && client_prefix="echo" osc="echo $osc"
local qcow build
download_scenario
download_latest_published_tumbleweed_image
create_devel_openqa_snapshot
trigger
}
download_latest_published_tumbleweed_image() {
qcow=$(find_latest_published_tumbleweed_image "$tw_group_id" "$arch" "$machine" qcow)
if [ "$target_host_proto://$target_host" != "$tw_openqa_host" ]; then
url="${tw_openqa_host}/assets/hdd/${qcow}"
# instead of manual wget it should also work to provide a whitelisted url to openqa as HDD_1_URL which should then download it itself but a first experiment didn't work
${client_prefix} wget -c "$url" -O /var/lib/openqa/factory/hdd/"$qcow"
fi
# ensure the build tag conforms to coolo's unwritten rules for the openQA dashboard
build=$(echo "$build_tag" | sed -e "s/jenkins-trigger-openQA_in_openQA-/:/" -e "s/-/./g")
}
download_scenario() {
rm -f /var/tmp/sd.yaml
curl https://raw.githubusercontent.com/os-autoinst/os-autoinst-distri-openQA/master/scenario-definitions.yaml -o /var/tmp/sd.yaml
}
create_devel_openqa_snapshot() {
local auto_submit_packages staged_packages
auto_submit_packages=$(list_packages "$dst_project")
staged_packages=$(list_packages "$staging_project") || true # osc ls returns non-zero return code for empty projects
if [[ $staged_packages ]]; then
echo "Only triggering tests from $src_project (not overriding $staging_project and doing a submission) because openQA-in-openQA tests or a submission is still pending (as $staging_project still contains packages)" \
| tee job_post_skip_submission
staging_project=$src_project
return
elif [[ -e job_post_skip_submission ]]; then
rm job_post_skip_submission
fi
echo "Creating snapshots under $staging_project"
for package in $auto_submit_packages; do
echo "Creating snapshots of $package"
$osc release --no-delay --target-project "$staging_project" --target-repository=openSUSE_Tumbleweed -r openSUSE_Tumbleweed -a x86_64 "$src_project" "$package"
done
}
trigger() {
# prevent host access problem when running within o3 infrastructure
# where o3 is not reachable over https
declare -a ARGS
if [ "$target_host" = "openqa.opensuse.org" ]; then
ARGS=("OPENQA_HOST=http://openqa.opensuse.org")
fi
# in full run use only openqa_install+publish test
if [ "$full_run" ]; then
ARGS+=('TEST=openqa_install+publish' "FULL_OPENSUSE_TEST=1")
fi
${client_prefix} "${openqa_cli}" \
schedule --host "${target_host_proto}://${target_host}" \
--param-file SCENARIO_DEFINITIONS_YAML=/var/tmp/sd.yaml \
VERSION=Tumbleweed \
DISTRI=openqa FLAVOR=dev ARCH="${arch}" \
HDD_1="$qcow" BUILD="${build}" _GROUP="${group_id}" \
OPENQA_OBS_PROJECT="$staging_project" \
"${ARGS[@]}" \
| tee job_post_response
}
main