Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bats tests - parallelize #5552

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ integration_task:

gce_instance:
image_name: "$IMAGE_NAME"
cpu: 4

# Separate scripts for separate outputs, makes debugging easier.
setup_script: '${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}'
Expand Down Expand Up @@ -281,6 +282,7 @@ integration_rootless_task:

gce_instance:
image_name: "$IMAGE_NAME"
cpu: 4

# Separate scripts for separate outputs, makes debugging easier.
setup_script: '${SCRIPT_BASE}/setup.sh |& ${_TIMESTAMP}'
Expand Down
17 changes: 12 additions & 5 deletions tests/blobcache.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

load helpers

# The 'rm cachefile' in the "blobs must be reused" test
# causes flakes when parallelizing
function setup_file() {
export BATS_NO_PARALLELIZE_WITHIN_FILE=true
}

@test "blobcache-pull" {
blobcachedir=${TEST_SCRATCH_DIR}/cache
mkdir -p ${blobcachedir}
Expand Down Expand Up @@ -57,6 +63,8 @@ function _check_matches() {

# Integration test for https://github.com/containers/image/pull/1645
@test "blobcache: blobs must be reused when pushing across registry" {
blobcachedir=${TEST_SCRATCH_DIR}/cachereuse
mkdir -p ${blobcachedir}
start_registry

imgname=blobimg-$(random_string | tr A-Z a-z)
Expand All @@ -65,10 +73,10 @@ function _check_matches() {
mkdir -p ${outputdir}
podman run --rm --mount type=bind,src=${TEST_SCRATCH_DIR}/test.auth,target=/test.auth,Z --mount type=bind,src=${outputdir},target=/output,Z --net host quay.io/skopeo/stable copy --preserve-digests --authfile=/test.auth --tls-verify=false docker://registry.fedoraproject.org/fedora-minimal dir:/output
run_buildah rmi --all -f
run_buildah pull dir:${outputdir}
run_buildah pull --blob-cache=${blobcachedir} dir:${outputdir}
run_buildah images -a --format '{{.ID}}'
cid=$output
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth $cid docker://localhost:${REGISTRY_PORT}/$imgname
run_buildah --log-level debug push --blob-cache=${blobcachedir} --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth $cid docker://localhost:${REGISTRY_PORT}/$imgname
# must not contain "Skipping blob" since push must happen
assert "$output" !~ "Skipping blob"

Expand All @@ -79,15 +87,14 @@ function _check_matches() {
then
cachedir=$HOME/.local/share
fi
cachefile=$cachedir/containers/cache/blob-info-cache-v1.sqlite
run rm $cachefile
run rm -rf $blobcachedir/*
assert "$status" -eq 0 "status of `run rm $cachefile` must be 0"

# In first push blob must be skipped after vendoring https://github.com/containers/image/pull/1645
run_buildah pull dir:${outputdir}
run_buildah images -a --format '{{.ID}}'
cid=$output
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth $cid docker://localhost:${REGISTRY_PORT}/$imgname
run_buildah --log-level debug push --blob-cache=${blobcachedir} --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth $cid docker://localhost:${REGISTRY_PORT}/$imgname
expect_output --substring "Skipping blob"
}

Expand Down
3 changes: 3 additions & 0 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ _EOF

@test "bud: build push with --force-compression" {
skip_if_no_podman
blobcachedir=${TEST_SCRATCH_DIR}/blobcachelocal
mkdir -p ${blobcachedir}
local contextdir=${TEST_SCRATCH_DIR}/bud/platform
mkdir -p $contextdir

Expand All @@ -165,6 +167,7 @@ _EOF
# Helper function. push our image with the given options, and run skopeo inspect
function _test_buildah_push() {
run_buildah push \
--blob-cache=${blobcachedir} \
$WITH_POLICY_JSON \
--authfile ${TEST_SCRATCH_DIR}/test.auth \
--tls-verify=false \
Expand Down
2 changes: 0 additions & 2 deletions tests/source.bats
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,4 @@ load helpers
run diff -r $srcdir $pulldir
# FIXME: if there's a nonzero chance of this failing, include actual diffs
assert "$status" -eq 0 "status from diff of srcdir vs pulldir"

stop_registry
}
2 changes: 1 addition & 1 deletion tests/test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ function execute() {
}

# Run the tests.
execute time bats --tap "${@:-.}"
execute time bats -j $(nproc) --tap "${@:-.}"