Define storeBRoot variable distinct from storeB URI.

This commit is contained in:
Ben Radford 2023-07-20 11:03:14 +01:00
parent 878c84d5ee
commit 2c66a093e0
No known key found for this signature in database
GPG Key ID: 9DF5D4640AB888D5
5 changed files with 13 additions and 14 deletions

View File

@ -18,14 +18,14 @@ mountOverlayfs
# Add something to the overlay store
overlayPath=$(addTextToStore "$storeB" "overlay-file" "Add to overlay store")
stat "$storeVolume/merged-store/$overlayPath"
stat "$storeBRoot/$overlayPath"
# Now add something to the lower store
lowerPath=$(addTextToStore "$storeA" "lower-file" "Add to lower store")
stat "$storeVolume/store-a/$lowerPath"
# Remount overlayfs to ensure synchronization
mount -o remount "$storeVolume/merged-store/nix/store"
remountOverlayfs
# Path should be accessible via overlay store
stat "$storeVolume/merged-store/$lowerPath"
stat "$storeBRoot/$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=$storeVolume/merged-store&lower-store=$badTestRoot&upper-layer=$storeBTop"
storeBadUpper="local-overlay?root=$storeVolume/merged-store&lower-store=$storeA&upper-layer=$badTestRoot"
storeBadLower="local-overlay?root=$storeBRoot&lower-store=$badTestRoot&upper-layer=$storeBTop"
storeBadUpper="local-overlay?root=$storeBRoot&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 "$storeVolume/merged-store/nix/store" "$path")
diff $(toRealPath "$storeA/nix/store" "$path") $(toRealPath "$storeBRoot/nix/store" "$path")
# Checking requisites query agreement
[[ \

View File

@ -24,30 +24,30 @@ storeDirs () {
storeA="$storeVolume/store-a"
storeBTop="$storeVolume/store-b"
storeB="local-overlay?root=$storeVolume/merged-store&lower-store=$storeA&upper-layer=$storeBTop"
storeBRoot="$storeVolume/merged-store"
storeB="local-overlay?root=$storeBRoot&lower-store=$storeA&upper-layer=$storeBTop"
# Creating testing directories
mkdir -p "$storeVolume"/{store-a/nix/store,store-b,merged-store/nix/store,workdir}
}
# Mounting Overlay Store
mountOverlayfs () {
mergedStorePath="$storeVolume/merged-store/nix/store"
mount -t overlay overlay \
-o lowerdir="$storeA/nix/store" \
-o upperdir="$storeBTop" \
-o workdir="$storeVolume/workdir" \
"$mergedStorePath" \
"$storeBRoot/nix/store" \
|| skipTest "overlayfs is not supported"
cleanupOverlay () {
umount "$storeVolume/merged-store/nix/store"
umount "$storeBRoot/nix/store"
rm -r $storeVolume/workdir
}
trap cleanupOverlay EXIT
}
remountOverlayfs () {
mount -o remount "$mergedStorePath"
mount -o remount "$storeBRoot/nix/store"
}
toRealPath () {

View File

@ -7,7 +7,7 @@ set -x
source common.sh
# Avoid store dir being inside sandbox build-dir
unset NIX_STORE_DIR # TODO: This causes toRealPath to fail (it expects this var to be set)
unset NIX_STORE_DIR
unset NIX_STATE_DIR
storeDirs
@ -27,5 +27,4 @@ path=$(nix-store --store "$storeB" --add ../dummy)
stat $(toRealPath "$storeA/nix/store" "$path")
# upper layer should still not have it (no redundant copy)
expect 1 stat $(toRealPath "$storeB/nix/store" "$path") # TODO: Check this is failing for the right reason.
# $storeB is a store URI not a directory path
expect 1 stat $(toRealPath "$storeBTop" "$path")