ci-automation: Change the way we prepare torcx manifest for testing

Now URLs for torcx packages are always present in the torcx manifest,
but for releases they may be pointing to the origin server where the
packages will be eventually uploaded. At the time of running the
tests, those packages are still only in the build cache, so change the
URLs to point to the build cache, so the test can pass.
This commit is contained in:
Krzesimir Nowak 2022-09-06 13:23:05 +02:00
parent b2d6f7fc6e
commit 1ecea3544f

View File

@ -74,8 +74,11 @@
# script would need to make anyway. For more information, please refer
# to the vendor_test.sh file.
# Download torcx package and manifest, add build cache URL to manifest
# so the docker.torcx-manifest-pkgs test can use it.
# Download torcx manifest and modify URLs pointing to the origin
# server to point to the build cache. This is because the tests for
# releases are run before artifacts are uploaded to the origin
# server. This would make kola's docker.torcx-manifest-pkgs test to
# fail.
function __prepare_torcx() {
local arch="$1"
local vernum="$2"
@ -83,14 +86,26 @@ function __prepare_torcx() {
copy_from_buildcache "images/${arch}/${vernum}/torcx/torcx_manifest.json" "${workdir}"
local docker_pkg
docker_pkg="$(basename \
"$(jq -r ".value.packages[0].versions[0].locations[0].path" \
${workdir}/torcx_manifest.json)")"
# Add docker package URL on build cache to manifest
local docker_url="http://${BUILDCACHE_SERVER}/images/${arch}/${vernum}/torcx/${docker_pkg}"
jq ".value.packages[0].versions[0].locations += [{\"url\" : \"${docker_url}\"}]" \
# Change URLs from:
#
# https://${channel}.release.flatcar-linux.net/${arch}-usr/${vernum}/torcx/…
#
# to:
#
# https://bincache.flatcar-linux.net/images/${arch}/${vernum}/torcx/…
#
# This is done in two parts - replacing host part and arch part.
#
# Replace 'https://${channel}.release.flatcar-linux.net/' with
# 'https://bincache.flatcar-linux.net/' matching the initial "url"
# JSON key too.
local host_match='\("url":\s*"https://\)[a-z]\+\.release\([^/]\+/\)'
local host_replace='\1bincache\2'
# Replace '${arch}-usr/` part with 'images/${arch}/'.
local arch_match='\([a-z0-9]\+\)-usr/'
local arch_replace='images/\3/'
sed \
-e "s#${host_match}${arch_match}#${host_replace}${arch_replace}#g" \
"${workdir}/torcx_manifest.json" \
>"${workdir}/torcx_manifest_new.json"