Skip to content

Commit

Permalink
test: try parameterizing the tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha committed Nov 3, 2023
1 parent 7645c84 commit 11524a2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/gzip.bats
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,10 @@ EOF
echo "$l2"
[ "$l1" = "$l2" ]
}

@test "import various sizes" {
test_copy_buffer_size 512k tar
test_copy_buffer_size 2m tar
test_copy_buffer_size 512k tar.gz
test_copy_buffer_size 2m tar.gz
}
38 changes: 38 additions & 0 deletions test/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,41 @@ function zot_teardown {
killall zot
rm -f $TEST_TMPDIR/zot-config.json
}

function test_copy_buffer_size() {
local buffer_size=$1
local file_type=$2
rm -rf folder1
mkdir folder1
truncate -s $buffer_size folder1/file1
if [ $file_type = "tar" ]; then
tar cvf test.$file_type folder1
else
tar cvzf test.$file_type folder1
fi
cat > stacker.yaml <<EOF
tar:
from:
type: tar
url: test.$file_type
EOF
stacker build
cat oci/index.json | jq .
m1=$(cat oci/index.json | jq .manifests[0].digest | sed 's/sha256://' | tr -d \")
cat oci/blobs/sha256/"$m1" | jq .
l1=$(cat oci/blobs/sha256/"$m1" | jq .layers[0].digest | sed 's/sha256://' | tr -d \")
$SKOPEO --version
[[ "$($SKOPEO --version)" =~ "skopeo version ${SKOPEO_VERSION}" ]] || {
echo "$SKOPEO --version should be ${SKOPEO_VERSION}"
exit 1
}
$SKOPEO copy --format=oci oci:oci:tar containers-storage:test:tar
$SKOPEO copy --format=oci containers-storage:test:tar oci:oci:test
cat oci/index.json | jq .
m2=$(cat oci/index.json | jq .manifests[1].digest | sed 's/sha256://' | tr -d \")
cat oci/blobs/sha256/"$m2" | jq .
l2=$(cat oci/blobs/sha256/"$m2" | jq .layers[0].digest | sed 's/sha256://' | tr -d \")
echo "$l1"
echo "$l2"
[ "$l1" = "$l2" ]
}

0 comments on commit 11524a2

Please sign in to comment.