Skip to content

Commit

Permalink
test: test create layer from staging directory
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Oct 3, 2023
1 parent c40dde3 commit 42fa4a9
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/apply-diff.bats
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,60 @@ load helpers
checkchanges
checkdiffs
}

@test "apply-diff-from-staging-directory" {
case "$STORAGE_DRIVER" in
overlay*)
;;
*)
skip "driver $STORAGE_DRIVER does not support diff-from-staging-directory"
;;
esac

SRC=$TESTDIR/source
mkdir -p $SRC
createrandom $SRC/file1
createrandom $SRC/file2
createrandom $SRC/file3

local sconf=$TESTDIR/storage.conf

local root=`storage status 2>&1 | awk '/^Root:/{print $2}'`
local runroot=`storage status 2>&1 | awk '/^Run Root:/{print $3}'`

cat >$sconf <<EOF
[storage]
driver="overlay"
graphroot="$root"
runroot="$runroot"
[storage.options]
pull_options = {enable_partial_images = "true" }
EOF

# Create a layer.
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false create-layer
[ "$status" -eq 0 ]
[ "$output" != "" ]
layer="$output"

CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false applydiff-using-staging-dir $layer $SRC
[ "$status" -eq 0 ]

name=safe-image
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false create-image --name $name $layer
[ "$status" -eq 0 ]

ctrname=foo
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false create-container --name $ctrname $name
[ "$status" -eq 0 ]

CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false mount $ctrname
[ "$status" -eq 0 ]
mount="$output"

for i in file1 file2 file3 ; do
run cmp $SRC/$i $mount/$i
[ "$status" -eq 0 ]
done
}

0 comments on commit 42fa4a9

Please sign in to comment.