Ensure all overlay tests use new tmpfs store paths.

This commit is contained in:
Ben Radford 2023-07-20 10:27:11 +01:00
parent 7fda19e2f1
commit 9769a0ae7d
No known key found for this signature in database
GPG Key ID: 9DF5D4640AB888D5
5 changed files with 25 additions and 19 deletions

View File

@ -18,14 +18,14 @@ mountOverlayfs
# Add something to the overlay store
overlayPath=$(addTextToStore "$storeB" "overlay-file" "Add to overlay store")
stat "$TEST_ROOT/merged-store/$overlayPath"
stat "$storeVolume/merged-store/$overlayPath"
# Now add something to the lower store
lowerPath=$(addTextToStore "$storeA" "lower-file" "Add to lower store")
stat "$TEST_ROOT/store-a/$lowerPath"
stat "$storeVolume/store-a/$lowerPath"
# Remount overlayfs to ensure synchronization
mount -o remount "$TEST_ROOT/merged-store/nix/store"
mount -o remount "$storeVolume/merged-store/nix/store"
# Path should be accessible via overlay store
stat "$TEST_ROOT/merged-store/$lowerPath"
stat "$storeVolume/merged-store/$lowerPath"

View File

@ -7,8 +7,8 @@ storeDirs
mkdir -p $TEST_ROOT/bad_test
badTestRoot=$TEST_ROOT/bad_test
storeBadRoot="local-overlay?root=$badTestRoot&lower-store=$storeA&upper-layer=$storeBTop"
storeBadLower="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$badTestRoot&upper-layer=$storeBTop"
storeBadUpper="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$badTestRoot"
storeBadLower="local-overlay?root=$storeVolume/merged-store&lower-store=$badTestRoot&upper-layer=$storeBTop"
storeBadUpper="local-overlay?root=$storeVolume/merged-store&lower-store=$storeA&upper-layer=$badTestRoot"
declare -a storesBad=(
"$storeBadRoot" "$storeBadLower" "$storeBadUpper"

View File

@ -25,7 +25,7 @@ stat $(toRealPath "$storeA/nix/store" "$path")
expect 1 stat $(toRealPath "$storeBTop" "$path")
# Checking for path in overlay store matching lower layer
diff $(toRealPath "$storeA/nix/store" "$path") $(toRealPath "$TEST_ROOT/merged-store/nix/store" "$path")
diff $(toRealPath "$storeA/nix/store" "$path") $(toRealPath "$storeVolume/merged-store/nix/store" "$path")
# Checking requisites query agreement
[[ \

View File

@ -12,30 +12,36 @@ setupConfig () {
echo "build-users-group = " >> "$NIX_CONF_DIR"/nix.conf
}
storeDirs () {
storesRoot="$TEST_ROOT/stores"
mkdir -p "$storesRoot"
mount -t tmpfs tmpfs "$storesRoot"
storeA="$storesRoot/store-a"
storeBTop="$storesRoot/store-b"
storeB="local-overlay?root=$storesRoot/merged-store&lower-store=$storeA&upper-layer=$storeBTop"
# Attempt to create store dirs on tmpfs volume.
# This ensures lowerdir, upperdir and workdir will be on
# a consistent filesystem that fully supports OverlayFS.
storeVolume="$TEST_ROOT/stores"
mkdir -p "$storeVolume"
mount -t tmpfs tmpfs "$storeVolume" || true # But continue anyway if that fails.
storeA="$storeVolume/store-a"
storeBTop="$storeVolume/store-b"
storeB="local-overlay?root=$storeVolume/merged-store&lower-store=$storeA&upper-layer=$storeBTop"
# Creating testing directories
mkdir -p "$storesRoot"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
mkdir -p "$storeVolume"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
}
# Mounting Overlay Store
mountOverlayfs () {
mergedStorePath="$storesRoot/merged-store/nix/store"
mergedStorePath="$storeVolume/merged-store/nix/store"
mount -t overlay overlay \
-o lowerdir="$storeA/nix/store" \
-o upperdir="$storeBTop" \
-o workdir="$storesRoot/workdir" \
-o workdir="$storeVolume/workdir" \
"$mergedStorePath" \
|| skipTest "overlayfs is not supported"
cleanupOverlay () {
umount "$storesRoot/merged-store/nix/store"
rm -r $storesRoot/workdir
umount "$storeVolume/merged-store/nix/store"
rm -r $storeVolume/workdir
}
trap cleanupOverlay EXIT
}

View File

@ -17,7 +17,7 @@ initLowerStore
mountOverlayfs
# Create a file to add to store
dupFilePath="$storesRoot/dup-file"
dupFilePath="$TEST_ROOT/dup-file"
echo Duplicate > "$dupFilePath"
# Add it to the overlay store (it will be written to the upper layer)