Skip to content

Commit

Permalink
Merge pull request #19979 from edsantiago/ci_trace_setup
Browse files Browse the repository at this point in the history
CI: trace setup and runner scripts
  • Loading branch information
openshift-merge-robot authored Sep 15, 2023
2 parents c361d07 + ade0c49 commit 3f8f494
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 73 deletions.
26 changes: 15 additions & 11 deletions contrib/cirrus/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ CIRRUS_REPO_NAME=${CIRRUS_REPO_NAME:-podman}
# shellcheck disable=SC2154
if [[ -z "$CIRRUS_BASE_SHA" ]] && [[ -z "$CIRRUS_TAG" ]]
then # Operating on a branch, or under `get_ci_vm.sh`
showrun echo "branch or get_ci_vm (CIRRUS_BASE_SHA and CIRRUS_TAG are unset)"
CIRRUS_BASE_SHA=$(git rev-parse ${UPSTREAM_REMOTE:-origin}/$DEST_BRANCH)
elif [[ -z "$CIRRUS_BASE_SHA" ]]
then # Operating on a tag
showrun echo "operating on tag"
CIRRUS_BASE_SHA=$(git rev-parse HEAD)
fi
# The starting place for linting and code validation
Expand Down Expand Up @@ -164,8 +166,8 @@ setup_rootless() {
ROOTLESS_UID=$rootless_uid
rootless_gid=$((1500 + RANDOM % 5000))
msg "creating $rootless_uid:$rootless_gid $ROOTLESS_USER user"
groupadd -g $rootless_gid $ROOTLESS_USER
useradd -g $rootless_gid -u $rootless_uid --no-user-group --create-home $ROOTLESS_USER
showrun groupadd -g $rootless_gid $ROOTLESS_USER
showrun useradd -g $rootless_gid -u $rootless_uid --no-user-group --create-home $ROOTLESS_USER

echo "$ROOTLESS_USER ALL=(root) NOPASSWD: ALL" > /etc/sudoers.d/ci-rootless

Expand All @@ -174,8 +176,8 @@ setup_rootless() {
msg "Creating ssh key pairs"
[[ -r "$HOME/.ssh/id_rsa" ]] || \
ssh-keygen -t rsa -P "" -f "$HOME/.ssh/id_rsa"
ssh-keygen -t ed25519 -P "" -f "/home/$ROOTLESS_USER/.ssh/id_ed25519"
ssh-keygen -t rsa -P "" -f "/home/$ROOTLESS_USER/.ssh/id_rsa"
showrun ssh-keygen -t ed25519 -P "" -f "/home/$ROOTLESS_USER/.ssh/id_ed25519"
showrun ssh-keygen -t rsa -P "" -f "/home/$ROOTLESS_USER/.ssh/id_rsa"

msg "Set up authorized_keys"
cat $HOME/.ssh/*.pub /home/$ROOTLESS_USER/.ssh/*.pub >> $HOME/.ssh/authorized_keys
Expand Down Expand Up @@ -231,17 +233,17 @@ use_cni() {
[ -z "$(rpm -qa | grep $pkg)" ] && echo "$pkg not installed" || rpm -e --nodeps $pkg
done
msg "Installing default CNI configuration"
dnf install -y $PACKAGE_DOWNLOAD_DIR/podman-plugins*
showrun dnf install -y $PACKAGE_DOWNLOAD_DIR/podman-plugins*
cd $GOSRC || exit 1
rm -rvf /etc/cni/net.d
mkdir -p /etc/cni/net.d
install -v -D -m 644 ./cni/87-podman-bridge.conflist \
showrun install -v -D -m 644 ./cni/87-podman-bridge.conflist \
/etc/cni/net.d/
# This config must always sort last in the list of networks (podman picks
# first one as the default). This config prevents allocation of network
# address space used by default in google cloud.
# https://cloud.google.com/vpc/docs/vpc#ip-ranges
install -v -D -m 644 $SCRIPT_BASE/99-do-not-use-google-subnets.conflist \
showrun install -v -D -m 644 $SCRIPT_BASE/99-do-not-use-google-subnets.conflist \
/etc/cni/net.d/
}

Expand All @@ -252,7 +254,7 @@ use_netavark() {
echo "NETWORK_BACKEND=netavark" >> /etc/ci_environment
export NETWORK_BACKEND=netavark # needed for install_test_configs()
msg "Removing any/all CNI configuration"
rm -rvf /etc/cni/net.d/*
showrun rm -rvf /etc/cni/net.d/*
# N/B: The CNI packages are still installed and available. This is
# on purpose, since CI needs to verify the selection mechanisms are
# functional when both are available.
Expand All @@ -276,8 +278,8 @@ remove_packaged_podman_files() {
if systemctl --quiet is-$state $unit
then
echo "Warning: $unit found $state prior to packaged-file removal"
systemctl --quiet disable $unit || true
systemctl --quiet stop $unit || true
showrun systemctl --quiet disable $unit || true
showrun systemctl --quiet stop $unit || true
fi
done
done
Expand All @@ -299,9 +301,11 @@ remove_packaged_podman_files() {
do
# Sub-directories may contain unrelated/valuable stuff
if [[ -d "$fullpath" ]]; then continue; fi
ooe.sh rm -vf "$fullpath"
showrun ooe.sh rm -vf "$fullpath"
done

# Be super extra sure and careful vs performant and completely safe
sync && echo 3 > /proc/sys/vm/drop_caches || true
}

showrun echo "finished"
68 changes: 36 additions & 32 deletions contrib/cirrus/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ set -eo pipefail
# shellcheck source=contrib/cirrus/lib.sh
source $(dirname $0)/lib.sh

showrun echo "starting"

function _run_validate() {
# TODO: aarch64 images need python3-devel installed
# https://github.com/containers/automation_images/issues/159
bigto ooe.sh dnf install -y python3-devel
showrun bigto ooe.sh dnf install -y python3-devel

# git-validation tool fails if $EPOCH_TEST_COMMIT is empty
# shellcheck disable=SC2154
if [[ -n "$EPOCH_TEST_COMMIT" ]]; then
make validate
showrun make validate
else
warn "Skipping git-validation since \$EPOCH_TEST_COMMIT is empty"
fi
Expand All @@ -42,29 +44,29 @@ function _run_unit() {
# shellcheck disable=SC2154
die "$TEST_FLAVOR: Unsupported PODBIN_NAME='$PODBIN_NAME'"
fi
make localunit
showrun make localunit
}

function _run_apiv2() {
_bail_if_test_can_be_skipped test/apiv2

(
make localapiv2-bash
showrun make localapiv2-bash
source .venv/requests/bin/activate
make localapiv2-python
showrun make localapiv2-python
) |& logformatter
}

function _run_compose() {
_bail_if_test_can_be_skipped test/compose

./test/compose/test-compose |& logformatter
showrun ./test/compose/test-compose |& logformatter
}

function _run_compose_v2() {
_bail_if_test_can_be_skipped test/compose

./test/compose/test-compose |& logformatter
showrun ./test/compose/test-compose |& logformatter
}

function _run_int() {
Expand All @@ -82,18 +84,18 @@ function _run_sys() {
function _run_upgrade_test() {
_bail_if_test_can_be_skipped test/system test/upgrade

bats test/upgrade |& logformatter
showrun bats test/upgrade |& logformatter
}

function _run_bud() {
_bail_if_test_can_be_skipped test/buildah-bud

./test/buildah-bud/run-buildah-bud-tests |& logformatter
showrun ./test/buildah-bud/run-buildah-bud-tests |& logformatter
}

function _run_bindings() {
# install ginkgo
make .install.ginkgo
showrun make .install.ginkgo

# shellcheck disable=SC2155
export PATH=$PATH:$GOSRC/hack:$GOSRC/test/tools/build
Expand All @@ -105,23 +107,23 @@ function _run_bindings() {
fi

(echo "$gitcommit_magic" && \
make testbindings) |& logformatter
showrun make testbindings) |& logformatter
}

function _run_docker-py() {
source .venv/docker-py/bin/activate
make run-docker-py-tests
showrun make run-docker-py-tests
}

function _run_endpoint() {
make test-binaries
make endpoint
showrun make test-binaries
showrun make endpoint
}

function _run_minikube() {
_bail_if_test_can_be_skipped test/minikube
msg "Testing minikube."
bats test/minikube |& logformatter
showrun bats test/minikube |& logformatter
}

exec_container() {
Expand Down Expand Up @@ -187,10 +189,10 @@ function _run_swagger() {

# Swagger validation takes a significant amount of time
msg "Pulling \$CTR_FQIN '$CTR_FQIN' (background process)"
bin/podman pull --quiet $CTR_FQIN &
showrun bin/podman pull --quiet $CTR_FQIN &

cd $GOSRC
make swagger
showrun make swagger

# Cirrus-CI Artifact instruction expects file here
cp -v $GOSRC/pkg/api/swagger.yaml ./
Expand All @@ -209,7 +211,7 @@ eof

msg "Waiting for backgrounded podman pull to complete..."
wait %%
bin/podman run -it --rm --security-opt label=disable \
showrun bin/podman run -it --rm --security-opt label=disable \
--env-file=$envvarsfile \
-v $GOSRC:$GOSRC:ro \
--workdir $GOSRC \
Expand All @@ -219,9 +221,9 @@ eof

function _run_build() {
# Ensure always start from clean-slate with all vendor modules downloaded
make clean
make vendor
make podman-release # includes podman, podman-remote, and docs
showrun make clean
showrun make vendor
showrun make podman-release # includes podman, podman-remote, and docs

# Last-minute confirmation that we're testing the desired runtime.
# This Can't Possibly Fail™ in regular CI; only when updating VMs.
Expand Down Expand Up @@ -252,7 +254,7 @@ function _run_altbuild() {
cd $GOSRC
case "$ALT_NAME" in
*Each*)
git fetch origin
showrun git fetch origin
# The make-and-check-size script, introduced 2022-03-22 in #13518,
# runs 'make' (the original purpose of this check) against
# each commit, then checks image sizes to make sure that
Expand All @@ -264,19 +266,19 @@ function _run_altbuild() {
savedhead=$(git rev-parse HEAD)
# Push to PR base. First run of the script will write size files
pr_base=$(git merge-base origin/$DEST_BRANCH HEAD)
git checkout $pr_base
hack/make-and-check-size $context_dir
showrun git checkout $pr_base
showrun hack/make-and-check-size $context_dir
# pop back to PR, and run incremental makes. Subsequent script
# invocations will compare against original size.
git checkout $savedhead
git rebase $pr_base -x "hack/make-and-check-size $context_dir"
showrun git checkout $savedhead
showrun git rebase $pr_base -x "hack/make-and-check-size $context_dir"
rm -rf $context_dir
;;
*Windows*)
make podman-remote-release-windows_amd64.zip
showrun make podman-remote-release-windows_amd64.zip
;;
*RPM*)
make package
showrun make package
;;
Alt*x86*Cross)
arches=(\
Expand Down Expand Up @@ -316,7 +318,7 @@ function _run_altbuild() {
function _build_altbuild_archs() {
for arch in "$@"; do
msg "Building release archive for $arch"
make podman-release-${arch}.tar.gz GOARCH=$arch
showrun make podman-release-${arch}.tar.gz GOARCH=$arch
done
}

Expand Down Expand Up @@ -418,13 +420,13 @@ dotest() {
die "Found fallback podman '$fallback_podman' in \$PATH; tests require none, as a guarantee that we're testing the right binary."
fi

make ${localremote}${testsuite} PODMAN_SERVER_LOG=$PODMAN_SERVER_LOG \
showrun make ${localremote}${testsuite} PODMAN_SERVER_LOG=$PODMAN_SERVER_LOG \
|& logformatter
}

_run_machine() {
# N/B: Can't use _bail_if_test_can_be_skipped here b/c content isn't under test/
make localmachine |& logformatter
showrun make localmachine |& logformatter
}

# Optimization: will exit if the only PR diffs are under docs/ or tests/
Expand Down Expand Up @@ -543,4 +545,6 @@ if [ "$(type -t $handler)" != "function" ]; then
die "Unknown/Unsupported \$TEST_FLAVOR=$TEST_FLAVOR"
fi

$handler
showrun $handler

showrun echo "finished"
Loading

0 comments on commit 3f8f494

Please sign in to comment.