2020-06-25 21:38:33 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
# This script runs in the Cirrus CI environment, invoked from .cirrus.yml .
|
|
|
|
# It can also be invoked manually in a `hack/get_ci_cm.sh` environment,
|
|
|
|
# documentation of said usage is TBI.
|
|
|
|
#
|
|
|
|
# The principal deciding factor is the $TEST_FLAVOR envariable: for any
|
|
|
|
# given value 'xyz' there must be a function '_run_xyz' to handle that
|
|
|
|
# test. Several other envariables are used to differentiate further,
|
|
|
|
# most notably:
|
|
|
|
#
|
|
|
|
# PODBIN_NAME : "podman" (i.e. local) or "remote"
|
|
|
|
# TEST_ENVIRON : 'host' or 'container'; desired environment in which to run
|
|
|
|
# CONTAINER : 1 if *currently* running inside a container, 0 if host
|
|
|
|
#
|
2020-06-25 21:38:33 +00:00
|
|
|
|
|
|
|
# shellcheck source=contrib/cirrus/lib.sh
|
|
|
|
source $(dirname $0)/lib.sh
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
function _run_ext_svc() {
|
|
|
|
$SCRIPT_BASE/ext_svc_check.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
function _run_automation() {
|
|
|
|
$SCRIPT_BASE/cirrus_yaml_test.py
|
|
|
|
|
|
|
|
req_env_vars CI DEST_BRANCH IMAGE_SUFFIX TEST_FLAVOR TEST_ENVIRON \
|
|
|
|
PODBIN_NAME PRIV_NAME DISTRO_NV CONTAINER USER HOME \
|
2020-10-16 13:12:03 +00:00
|
|
|
UID AUTOMATION_LIB_PATH SCRIPT_BASE OS_RELEASE_ID \
|
2020-11-12 14:10:18 +00:00
|
|
|
CG_FS_TYPE
|
2020-10-06 13:35:00 +00:00
|
|
|
bigto ooe.sh dnf install -y ShellCheck # small/quick addition
|
|
|
|
$SCRIPT_BASE/shellcheck.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
function _run_validate() {
|
2021-01-21 19:56:34 +00:00
|
|
|
# git-validation tool fails if $EPOCH_TEST_COMMIT is empty
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
if [[ -n "$EPOCH_TEST_COMMIT" ]]; then
|
|
|
|
make validate
|
|
|
|
else
|
|
|
|
warn "Skipping git-validation since \$EPOCH_TEST_COMMIT is empty"
|
|
|
|
fi
|
2020-11-10 19:57:53 +00:00
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _run_unit() {
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
if [[ "$PODBIN_NAME" != "podman" ]]; then
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
die "$TEST_FLAVOR: Unsupported PODBIN_NAME='$PODBIN_NAME'"
|
|
|
|
fi
|
|
|
|
make localunit
|
|
|
|
}
|
|
|
|
|
2020-10-08 15:47:27 +00:00
|
|
|
function _run_apiv2() {
|
|
|
|
make localapiv2 |& logformatter
|
|
|
|
}
|
|
|
|
|
2020-12-02 14:45:08 +00:00
|
|
|
function _run_compose() {
|
|
|
|
./test/compose/test-compose |& logformatter
|
|
|
|
}
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
function _run_int() {
|
|
|
|
dotest integration
|
|
|
|
}
|
|
|
|
|
|
|
|
function _run_sys() {
|
|
|
|
dotest system
|
|
|
|
}
|
|
|
|
|
2020-12-15 21:40:16 +00:00
|
|
|
function _run_upgrade_test() {
|
|
|
|
bats test/upgrade |& logformatter
|
|
|
|
}
|
|
|
|
|
2021-02-09 21:33:19 +00:00
|
|
|
function _run_bud() {
|
|
|
|
./test/buildah-bud/run-buildah-bud-tests |& logformatter
|
|
|
|
}
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
function _run_bindings() {
|
|
|
|
# shellcheck disable=SC2155
|
|
|
|
export PATH=$PATH:$GOSRC/hack
|
|
|
|
|
|
|
|
# Subshell needed so logformatter will write output in cwd; if it runs in
|
|
|
|
# the subdir, .cirrus.yml will not find the html'ized log
|
|
|
|
(cd pkg/bindings/test && ginkgo -trace -noColor -debug -r) |& logformatter
|
|
|
|
}
|
|
|
|
|
|
|
|
function _run_docker-py() {
|
2021-08-09 19:04:31 +00:00
|
|
|
source venv/bin/activate
|
|
|
|
make run-docker-py-tests
|
2020-10-06 13:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _run_endpoint() {
|
|
|
|
make test-binaries
|
|
|
|
make endpoint
|
|
|
|
}
|
|
|
|
|
2020-06-25 21:38:33 +00:00
|
|
|
exec_container() {
|
|
|
|
local var_val
|
|
|
|
local cmd
|
|
|
|
# Required to be defined by caller
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
msg "Re-executing runner inside container: $CTR_FQIN"
|
|
|
|
msg "************************************************************"
|
|
|
|
|
|
|
|
req_env_vars CTR_FQIN TEST_ENVIRON CONTAINER SECRET_ENV_RE
|
|
|
|
|
|
|
|
# Line-separated arguments which include shell-escaped special characters
|
|
|
|
declare -a envargs
|
|
|
|
while read -r var_val; do
|
|
|
|
envargs+=("-e $var_val")
|
|
|
|
done <<<"$(passthrough_envars)"
|
|
|
|
|
|
|
|
# VM Images and Container images are built using (nearly) identical operations.
|
|
|
|
set -x
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
exec podman run --rm --privileged --net=host --cgroupns=host \
|
|
|
|
-v /dev/fuse:/dev/fuse \
|
|
|
|
-v "$GOPATH:$GOPATH:Z" \
|
|
|
|
--workdir "$GOSRC" \
|
|
|
|
-e "CONTAINER=1" \
|
|
|
|
"${envargs[@]}" \
|
|
|
|
$CTR_FQIN bash -c "$SCRIPT_BASE/setup_environment.sh && $SCRIPT_BASE/runner.sh"
|
|
|
|
}
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
function _run_swagger() {
|
2021-01-19 15:42:25 +00:00
|
|
|
local upload_filename
|
|
|
|
local upload_bucket
|
2020-06-25 21:38:33 +00:00
|
|
|
local download_url
|
2021-01-19 15:42:25 +00:00
|
|
|
local envvarsfile
|
|
|
|
req_env_vars GCPJSON GCPNAME GCPPROJECT CTR_FQIN
|
|
|
|
|
2020-06-25 21:38:33 +00:00
|
|
|
# Building this is a PITA, just grab binary for use in automation
|
|
|
|
# Ref: https://goswagger.io/install.html#static-binary
|
|
|
|
download_url=$(\
|
|
|
|
curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
|
|
|
|
jq -r '.assets[] | select(.name | contains("linux_amd64")) | .browser_download_url')
|
2021-01-19 15:42:25 +00:00
|
|
|
|
|
|
|
# The filename and bucket depend on the automation context
|
|
|
|
#shellcheck disable=SC2154,SC2153
|
|
|
|
if [[ -n "$CIRRUS_PR" ]]; then
|
|
|
|
upload_bucket="libpod-pr-releases"
|
|
|
|
upload_filename="swagger-pr$CIRRUS_PR.yaml"
|
|
|
|
elif [[ -n "$CIRRUS_TAG" ]]; then
|
|
|
|
upload_bucket="libpod-master-releases"
|
|
|
|
upload_filename="swagger-$CIRRUS_TAG.yaml"
|
2021-06-30 15:39:19 +00:00
|
|
|
elif [[ "$CIRRUS_BRANCH" == "main" ]]; then
|
2021-01-19 15:42:25 +00:00
|
|
|
upload_bucket="libpod-master-releases"
|
2021-06-30 15:39:19 +00:00
|
|
|
# readthedocs versioning uses "latest" for "main" (default) branch
|
2021-01-19 15:42:25 +00:00
|
|
|
upload_filename="swagger-latest.yaml"
|
|
|
|
elif [[ -n "$CIRRUS_BRANCH" ]]; then
|
|
|
|
upload_bucket="libpod-master-releases"
|
|
|
|
upload_filename="swagger-$CIRRUS_BRANCH.yaml"
|
|
|
|
else
|
|
|
|
die "Unknown execution context, expected a non-empty value for \$CIRRUS_TAG, \$CIRRUS_BRANCH, or \$CIRRUS_PR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
curl -s -o /usr/local/bin/swagger -L'#' "$download_url"
|
2020-06-25 21:38:33 +00:00
|
|
|
chmod +x /usr/local/bin/swagger
|
|
|
|
|
2021-01-19 15:42:25 +00:00
|
|
|
# Swagger validation takes a significant amount of time
|
|
|
|
msg "Pulling \$CTR_FQIN '$CTR_FQIN' (background process)"
|
|
|
|
podman pull --quiet $CTR_FQIN &
|
|
|
|
|
2020-06-25 21:38:33 +00:00
|
|
|
cd $GOSRC
|
|
|
|
make swagger
|
2020-10-06 13:35:00 +00:00
|
|
|
|
|
|
|
# Cirrus-CI Artifact instruction expects file here
|
2021-01-19 15:42:25 +00:00
|
|
|
cp -v $GOSRC/pkg/api/swagger.yaml ./
|
|
|
|
|
|
|
|
envvarsfile=$(mktemp -p '' .tmp_$(basename $0)_XXXXXXXX)
|
|
|
|
trap "rm -f $envvarsfile" EXIT # contains secrets
|
|
|
|
# Warning: These values must _not_ be quoted, podman will not remove them.
|
|
|
|
#shellcheck disable=SC2154
|
2021-07-06 11:47:28 +00:00
|
|
|
cat <<eof >>$envvarsfile
|
2021-01-19 15:42:25 +00:00
|
|
|
GCPJSON=$GCPJSON
|
|
|
|
GCPNAME=$GCPNAME
|
|
|
|
GCPPROJECT=$GCPPROJECT
|
|
|
|
FROM_FILEPATH=$GOSRC/swagger.yaml
|
|
|
|
TO_GCSURI=gs://$upload_bucket/$upload_filename
|
|
|
|
eof
|
|
|
|
|
|
|
|
msg "Waiting for backgrounded podman pull to complete..."
|
|
|
|
wait %%
|
|
|
|
podman run -it --rm --security-opt label=disable \
|
|
|
|
--env-file=$envvarsfile \
|
|
|
|
-v $GOSRC:$GOSRC:ro \
|
|
|
|
--workdir $GOSRC \
|
|
|
|
$CTR_FQIN
|
|
|
|
rm -f $envvarsfile
|
2020-06-25 21:38:33 +00:00
|
|
|
}
|
|
|
|
|
2021-01-19 16:19:46 +00:00
|
|
|
function _run_consistency() {
|
2020-10-06 13:35:00 +00:00
|
|
|
make vendor
|
2021-01-19 16:19:46 +00:00
|
|
|
SUGGESTION="run 'make vendor' and commit all changes" ./hack/tree_status.sh
|
|
|
|
make generate-bindings
|
|
|
|
SUGGESTION="run 'make generate-bindings' and commit all changes" ./hack/tree_status.sh
|
2021-07-01 18:01:44 +00:00
|
|
|
make completions
|
|
|
|
SUGGESTION="run 'make completions' and commit all changes" ./hack/tree_status.sh
|
2020-10-06 13:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _run_build() {
|
2020-10-06 18:12:49 +00:00
|
|
|
# Ensure always start from clean-slate with all vendor modules downloaded
|
|
|
|
make clean
|
|
|
|
make vendor
|
2021-04-08 18:30:40 +00:00
|
|
|
make podman-release.tar.gz # includes podman, podman-remote, and docs
|
2020-10-06 13:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _run_altbuild() {
|
2020-06-25 21:38:33 +00:00
|
|
|
req_env_vars ALT_NAME
|
|
|
|
# Defined in .cirrus.yml
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
msg "Performing alternate build: $ALT_NAME"
|
|
|
|
msg "************************************************************"
|
|
|
|
cd $GOSRC
|
|
|
|
case "$ALT_NAME" in
|
|
|
|
*Each*)
|
|
|
|
git fetch origin
|
|
|
|
make build-all-new-commits GIT_BASE_BRANCH=origin/$DEST_BRANCH
|
|
|
|
;;
|
|
|
|
*Windows*)
|
2021-04-08 18:30:40 +00:00
|
|
|
make podman-remote-release-windows.zip
|
2020-06-25 21:38:33 +00:00
|
|
|
make podman.msi
|
|
|
|
;;
|
|
|
|
*Without*)
|
|
|
|
make build-no-cgo
|
|
|
|
;;
|
|
|
|
*RPM*)
|
|
|
|
make -f ./.copr/Makefile
|
|
|
|
rpmbuild --rebuild ./podman-*.src.rpm
|
|
|
|
;;
|
2021-01-11 16:17:42 +00:00
|
|
|
Alt*Cross)
|
|
|
|
make local-cross
|
|
|
|
;;
|
2020-06-25 21:38:33 +00:00
|
|
|
*Static*)
|
|
|
|
req_env_vars CTR_FQIN
|
|
|
|
[[ "$UID" -eq 0 ]] || \
|
|
|
|
die "Static build must execute nixos container as root on host"
|
2021-01-25 11:02:22 +00:00
|
|
|
podman run -i --rm \
|
|
|
|
-e CACHIX_AUTH_TOKEN \
|
|
|
|
-v $PWD:$PWD:Z -w $PWD $CTR_FQIN sh -c \
|
|
|
|
"nix-env -iA cachix -f https://cachix.org/api/v1/install && \
|
|
|
|
cachix use podman && \
|
|
|
|
nix-build nix && \
|
|
|
|
nix-store -qR --include-outputs \$(nix-instantiate nix/default.nix) | grep -v podman | cachix push podman && \
|
|
|
|
cp -R result/bin ."
|
2020-06-25 21:38:33 +00:00
|
|
|
rm result # makes cirrus puke
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
die "Unknown/Unsupported \$$ALT_NAME '$ALT_NAME'"
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
function _run_release() {
|
2021-01-06 15:41:29 +00:00
|
|
|
# TODO: These tests should come from code external to the podman repo.
|
2021-01-12 18:46:23 +00:00
|
|
|
# to allow test-changes (and re-runs) in the case of a correctable test
|
2021-01-06 15:41:29 +00:00
|
|
|
# flaw or flake at release tag-push time. For now, the test is here
|
2021-01-12 18:46:23 +00:00
|
|
|
# given its simplicity.
|
|
|
|
msg "podman info:"
|
|
|
|
bin/podman info
|
2021-01-06 15:41:29 +00:00
|
|
|
|
|
|
|
msg "Checking podman release (or potential release) criteria."
|
2021-01-18 18:23:04 +00:00
|
|
|
# We're running under 'set -eo pipefail'; make sure this statement passes
|
|
|
|
dev=$(bin/podman info |& grep -- -dev || echo -n '')
|
2021-01-12 18:46:23 +00:00
|
|
|
if [[ -n "$dev" ]]; then
|
|
|
|
die "Releases must never contain '-dev' in output of 'podman info' ($dev)"
|
2020-10-06 13:35:00 +00:00
|
|
|
fi
|
2021-01-12 18:46:23 +00:00
|
|
|
msg "All OK"
|
2020-10-06 13:35:00 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 14:25:19 +00:00
|
|
|
logformatter() {
|
2021-03-18 13:36:20 +00:00
|
|
|
if [[ "$CI" == "true" ]]; then
|
|
|
|
# Use similar format as human-friendly task name from .cirrus.yml
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
output_name="$TEST_FLAVOR-$PODBIN_NAME-$DISTRO_NV-$PRIV_NAME-$TEST_ENVIRON"
|
|
|
|
# Requires stdin and stderr combined!
|
|
|
|
cat - \
|
|
|
|
|& awk --file "${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/timestamp.awk" \
|
|
|
|
|& "${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/logformatter" "$output_name"
|
|
|
|
else
|
2021-04-21 09:38:34 +00:00
|
|
|
# Assume script is run by a human, they want output immediately
|
2021-03-18 13:36:20 +00:00
|
|
|
cat -
|
|
|
|
fi
|
2020-06-25 21:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Handle local|remote integration|system testing in a uniform way
|
|
|
|
dotest() {
|
|
|
|
local testsuite="$1"
|
|
|
|
req_env_vars testsuite CONTAINER TEST_ENVIRON PRIV_NAME
|
|
|
|
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
if ((CONTAINER==0)) && [[ "$TEST_ENVIRON" == "container" ]]; then
|
|
|
|
exec_container # does not return
|
|
|
|
fi;
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
# containers/automation sets this to 0 for its dbg() function
|
2020-06-25 21:38:33 +00:00
|
|
|
# but the e2e integration tests are also sensitive to it.
|
|
|
|
unset DEBUG
|
|
|
|
|
|
|
|
# shellcheck disable=SC2154
|
2020-10-06 13:35:00 +00:00
|
|
|
local localremote="$PODBIN_NAME"
|
2020-06-25 21:38:33 +00:00
|
|
|
case "$PODBIN_NAME" in
|
2020-10-06 13:35:00 +00:00
|
|
|
podman) localremote="local" ;;
|
2020-06-25 21:38:33 +00:00
|
|
|
esac
|
2020-10-06 13:35:00 +00:00
|
|
|
|
|
|
|
make ${localremote}${testsuite} PODMAN_SERVER_LOG=$PODMAN_SERVER_LOG \
|
|
|
|
|& logformatter
|
2020-06-25 21:38:33 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 12:19:31 +00:00
|
|
|
# Nearly every task in .cirrus.yml makes use of this shell script
|
|
|
|
# wrapped by /usr/bin/time to collect runtime statistics. Because the
|
|
|
|
# --output option is used to log stats to a file, every child-process
|
|
|
|
# inherits an open FD3 pointing at the log. However, some testing
|
|
|
|
# operations depend on making use of FD3, and so it must be explicitly
|
|
|
|
# closed here (and for all further child-processes).
|
|
|
|
# STATS_LOGFILE assumed empty/undefined outside of Cirrus-CI (.cirrus.yml)
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
exec 3<&-
|
|
|
|
|
2020-06-25 21:38:33 +00:00
|
|
|
msg "************************************************************"
|
|
|
|
# Required to be defined by caller
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
msg "Runner executing $TEST_FLAVOR $PODBIN_NAME-tests as $PRIV_NAME on $DISTRO_NV($OS_REL_VER)"
|
|
|
|
if ((CONTAINER)); then
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
msg "Current environment container image: $CTR_FQIN"
|
|
|
|
else
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
msg "Current environment VM image: $VM_IMAGE_NAME"
|
|
|
|
fi
|
|
|
|
msg "************************************************************"
|
|
|
|
|
|
|
|
((${SETUP_ENVIRONMENT:-0})) || \
|
|
|
|
die "Expecting setup_environment.sh to have completed successfully"
|
|
|
|
|
2021-03-31 22:32:56 +00:00
|
|
|
# shellcheck disable=SC2154
|
|
|
|
if [[ "$PRIV_NAME" == "rootless" ]] && [[ "$UID" -eq 0 ]]; then
|
2021-07-06 11:47:28 +00:00
|
|
|
# Remove /var/lib/cni, it is not required for rootless cni.
|
|
|
|
# We have to test that it works without this directory.
|
|
|
|
# https://github.com/containers/podman/issues/10857
|
|
|
|
rm -rf /var/lib/cni
|
|
|
|
|
2021-03-31 22:32:56 +00:00
|
|
|
req_env_vars ROOTLESS_USER
|
|
|
|
msg "Re-executing runner through ssh as user '$ROOTLESS_USER'"
|
|
|
|
msg "************************************************************"
|
|
|
|
set -x
|
|
|
|
exec ssh $ROOTLESS_USER@localhost \
|
|
|
|
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
|
|
|
|
-o CheckHostIP=no $GOSRC/$SCRIPT_BASE/runner.sh
|
|
|
|
# Does not return!
|
|
|
|
fi
|
|
|
|
# else: not running rootless, do nothing special
|
|
|
|
|
2020-06-25 21:38:33 +00:00
|
|
|
cd "${GOSRC}/"
|
|
|
|
|
2020-10-06 13:35:00 +00:00
|
|
|
handler="_run_${TEST_FLAVOR}"
|
|
|
|
|
|
|
|
if [ "$(type -t $handler)" != "function" ]; then
|
|
|
|
die "Unknown/Unsupported \$TEST_FLAVOR=$TEST_FLAVOR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
$handler
|