Skip to content

Commit

Permalink
test: add unit tests for whiteouts
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha committed Jun 21, 2024
1 parent a11880c commit 10e0e23
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions test/whiteout.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
load helpers

function setup() {
stacker_setup
}

function teardown() {
cleanup
}

@test "test not adding extraneous whiteouts" {
cat > stacker.yaml <<EOF
image:
from:
type: docker
url: docker://aci-zot.cisco.com:5000/c3/minbase:3.0.2
run: |
apt-get -y install libsensors-config
EOF

stacker build
echo "checking"
for f in $(ls oci/blobs/sha256/); do
file oci/blobs/sha256/$f | grep "gzip" || {
echo "skipping $f"
continue
}
tar -tvzf oci/blobs/sha256/$f | grep ".wh.sensors.d" && {
echo "should not have a sensors.d whiteout!"
exit 1
}
done
}

@test "dont emit whiteout for new dir creates" {
cat > stacker.yaml <<EOF
# a1.tar has /a1/file
bb:
from:
type: docker
url: docker://busybox
run: |
mkdir /a1
touch /a1/file
nodir:
from:
type: built
tag: bb
run: |
rm -rf /a1
emptydir:
from:
type: built
tag: bb
run: |
rm -rf /a1
mkdir /a1
fulldir:
from:
type: built
tag: bb
run: |
rm -rf /a1
mkdir /a1
touch /a1/newfile
EOF

stacker build
}

0 comments on commit 10e0e23

Please sign in to comment.