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 <rchincha@cisco.com>
  • Loading branch information
rchincha committed Jun 26, 2024
1 parent 3188360 commit 5cf9fe0
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ require (
)

replace (
github.com/opencontainers/umoci => github.com/rchincha/umoci v0.0.0-20240624222738-f537fd2733f9
github.com/opencontainers/umoci => github.com/rchincha/umoci v0.0.0-20240626041051-8a70aa6ab09f
stackerbuild.io/stacker-bom => github.com/project-stacker/stacker-bom v0.0.0-20240509203427-4d685e046780
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/rchincha/umoci v0.0.0-20240624222738-f537fd2733f9 h1:zVLb+d07fy3soRSqjhreRNkfQjYqoEF4bNnoVLMC9DE=
github.com/rchincha/umoci v0.0.0-20240624222738-f537fd2733f9/go.mod h1:XUXUpCpA/Y8aJWezK1i8o4WDR0Y/vhMcWg+FUNQkKMQ=
github.com/rchincha/umoci v0.0.0-20240626041051-8a70aa6ab09f h1:kb6KNqJtAu7bF//luRE42U3ySX79bn0iO+5FVXuEnLo=
github.com/rchincha/umoci v0.0.0-20240626041051-8a70aa6ab09f/go.mod h1:XUXUpCpA/Y8aJWezK1i8o4WDR0Y/vhMcWg+FUNQkKMQ=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
Expand Down
73 changes: 73 additions & 0 deletions test/whiteout.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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://ubuntu:latest
run: |
apt-get update
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
}
bsdtar -tvf 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 5cf9fe0

Please sign in to comment.