Mount tmpfs first to ensure overlayfs works consistently.

This commit is contained in:
Ben Radford 2023-07-19 16:46:51 +01:00
parent 44f855d14e
commit 7fda19e2f1
No known key found for this signature in database
GPG key ID: 9DF5D4640AB888D5
2 changed files with 12 additions and 9 deletions

View file

@ -13,26 +13,29 @@ setupConfig () {
} }
storeDirs () { storeDirs () {
storeA="$TEST_ROOT/store-a" storesRoot="$TEST_ROOT/stores"
storeBTop="$TEST_ROOT/store-b" mkdir -p "$storesRoot"
storeB="local-overlay?root=$TEST_ROOT/merged-store&lower-store=$storeA&upper-layer=$storeBTop" 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"
# Creating testing directories # Creating testing directories
mkdir -p "$TEST_ROOT"/{store-a/nix/store,store-b,merged-store/nix/store,workdir} mkdir -p "$storesRoot"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
} }
# Mounting Overlay Store # Mounting Overlay Store
mountOverlayfs () { mountOverlayfs () {
mergedStorePath="$TEST_ROOT/merged-store/nix/store" mergedStorePath="$storesRoot/merged-store/nix/store"
mount -t overlay overlay \ mount -t overlay overlay \
-o lowerdir="$storeA/nix/store" \ -o lowerdir="$storeA/nix/store" \
-o upperdir="$storeBTop" \ -o upperdir="$storeBTop" \
-o workdir="$TEST_ROOT/workdir" \ -o workdir="$storesRoot/workdir" \
"$mergedStorePath" \ "$mergedStorePath" \
|| skipTest "overlayfs is not supported" || skipTest "overlayfs is not supported"
cleanupOverlay () { cleanupOverlay () {
umount "$TEST_ROOT/merged-store/nix/store" umount "$storesRoot/merged-store/nix/store"
rm -r $TEST_ROOT/workdir rm -r $storesRoot/workdir
} }
trap cleanupOverlay EXIT trap cleanupOverlay EXIT
} }

View file

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