Add a test for auto-GC
This currently fails because we're using POSIX file locks. So when the garbage collector opens and closes its own temproots file, it causes the lock to be released and then deleted by another GC instance.
This commit is contained in:
parent
320126aeeb
commit
ec415d7166
4 changed files with 72 additions and 3 deletions
59
tests/gc-auto.sh
Normal file
59
tests/gc-auto.sh
Normal file
|
@ -0,0 +1,59 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
garbage1=$(nix add-to-store --name garbage1 ./tarball.sh)
|
||||
garbage2=$(nix add-to-store --name garbage2 ./tarball.sh)
|
||||
garbage3=$(nix add-to-store --name garbage3 ./tarball.sh)
|
||||
|
||||
fake_free=$TEST_ROOT/fake-free
|
||||
export _NIX_TEST_FREE_SPACE_FILE=$fake_free
|
||||
echo 1100 > $fake_free
|
||||
|
||||
expr=$(cat <<EOF
|
||||
with import ./config.nix; mkDerivation {
|
||||
name = "gc-A";
|
||||
buildCommand = ''
|
||||
[[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 3 ]]
|
||||
mkdir \$out
|
||||
echo foo > \$out/bar
|
||||
echo 1...
|
||||
sleep 2
|
||||
echo 100 > $fake_free
|
||||
echo 2...
|
||||
sleep 2
|
||||
echo 3...
|
||||
[[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 1 ]]
|
||||
'';
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
nix build -o $TEST_ROOT/result-A -L "($expr)" \
|
||||
--min-free 1000 --max-free 2000 --min-free-check-interval 1 &
|
||||
pid=$!
|
||||
|
||||
expr2=$(cat <<EOF
|
||||
with import ./config.nix; mkDerivation {
|
||||
name = "gc-B";
|
||||
buildCommand = ''
|
||||
mkdir \$out
|
||||
echo foo > \$out/bar
|
||||
echo 1...
|
||||
sleep 2
|
||||
echo 100 > $fake_free
|
||||
echo 2...
|
||||
sleep 2
|
||||
echo 3...
|
||||
'';
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
nix build -o $TEST_ROOT/result-B -L "($expr2)" \
|
||||
--min-free 1000 --max-free 2000 --min-free-check-interval 1
|
||||
|
||||
wait "$pid"
|
||||
|
||||
[[ foo = $(cat $TEST_ROOT/result-A/bar) ]]
|
||||
[[ foo = $(cat $TEST_ROOT/result-B/bar) ]]
|
|
@ -3,7 +3,9 @@ check:
|
|||
|
||||
nix_tests = \
|
||||
init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
|
||||
gc.sh gc-concurrent.sh \
|
||||
gc.sh \
|
||||
gc-concurrent.sh \
|
||||
gc-auto.sh \
|
||||
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
||||
gc-runtime.sh check-refs.sh filter-source.sh \
|
||||
remote-store.sh export.sh export-graph.sh \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue