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

feat: test directory removals #601

Closed
wants to merge 1 commit into from
Closed
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
56 changes: 56 additions & 0 deletions test/basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,59 @@ busybox:
EOF
stacker build --substitute "a=b,c" --substitute BUSYBOX_OCI=${BUSYBOX_OCI}
}

@test "Test whiteouts across layers" {
# /aaa is created in l1, removed in l2, re-created in l3
# /bbb is created in l2, removed in l3
# /ccc is created in l2, removed and recreated in l3
# /ddd is created in l1, removed and recreated in l2, and extended in l3
cat > stacker.yaml <<"EOF"
l1:
from:
type: tar
url: .stacker/layer-bases/busybox.tar
run: |
mkdir -p /aaa/111/ab
mkdir -p /ddd/111/ab
l2:
from:
type: built
tag: l1
run: |
rm -rf /aaa
mkdir -p /bbb/111/ab
mkdir -p /ccc/111/ab
rm -rf /ddd
mkdir -p /ddd/222/ab
l3:
from:
type: built
tag: l2
run: |
rm -rf /bbb
rm -rf /ccc
mkdir -p /aaa/222/ab
mkdir -p /ccc/222/ab
mkdir -p /ddd/333/ab
EOF
stacker build
umoci unpack --image oci:l3 l3

# aaa/111 should be deleted, aaa/222 should exist
[ ! -d l3/rootfs/aaa/111 ]
[ -d l3/rootfs/aaa/222/ab ]

# bbb should be deleted entirely
[ ! -d l3/rootfs/bbb ]

# ccc should be like aaa - but doesn't have an intermediate layer
[ -d l3/rootfs/ccc/222 ]
[ ! -d l3/rootfs/ccc/111 ]

# ddd should have both 222 and 333 but not 111
# This is to test specifically that the opaque xattr is not copied
# up, causing 222 to be missed.
[ -d l3/rootfs/ddd/333 ]
[ -d l3/rootfs/ddd/222 ]
[ ! -d l3/rootfs/ddd/111 ]
}
Loading