forked from lix-project/lix
* Test case to show that parallel builds of different fixed-output
derivations that produce the same output path don't work properly wrt locking. This happens a lot in the build farm when fetchurl derivations downloading the same file on different platforms are executed in parallel and then copied back to the main machine.
This commit is contained in:
parent
7d5836b34d
commit
455a7b9577
|
@ -1,3 +1,5 @@
|
||||||
|
echo dummy: $dummy
|
||||||
|
if test -n "$dummy"; then sleep 2; fi
|
||||||
mkdir $out
|
mkdir $out
|
||||||
mkdir $out/bla
|
mkdir $out/bla
|
||||||
echo "Hello World!" > $out/foo
|
echo "Hello World!" > $out/foo
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
f = builder: mode: algo: hash: derivation {
|
f2 = dummy: builder: mode: algo: hash: derivation {
|
||||||
name = "fixed";
|
name = "fixed";
|
||||||
system = "@system@";
|
system = "@system@";
|
||||||
builder = "@shell@";
|
builder = "@shell@";
|
||||||
|
@ -9,8 +9,11 @@ rec {
|
||||||
outputHashAlgo = algo;
|
outputHashAlgo = algo;
|
||||||
outputHash = hash;
|
outputHash = hash;
|
||||||
PATH = "@testPath@";
|
PATH = "@testPath@";
|
||||||
|
inherit dummy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
f = f2 "";
|
||||||
|
|
||||||
good = [
|
good = [
|
||||||
(f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
(f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
||||||
(f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
|
(f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
|
||||||
|
@ -35,4 +38,11 @@ rec {
|
||||||
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
|
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Test for building two derivations in parallel that produce the
|
||||||
|
# same output path because they're fixed-output derivations.
|
||||||
|
parallelSame = [
|
||||||
|
(f2 "foo" ./fixed.builder2.sh "flat" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||||
|
(f2 "bar" ./fixed.builder2.sh "flat" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,18 +1,33 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
|
echo 'testing good...'
|
||||||
drvs=$($nixinstantiate fixed.nix -A good)
|
drvs=$($nixinstantiate fixed.nix -A good)
|
||||||
echo $drvs
|
echo $drvs
|
||||||
$nixstore -r $drvs
|
$nixstore -r $drvs
|
||||||
|
|
||||||
|
echo 'testing good2...'
|
||||||
drvs=$($nixinstantiate fixed.nix -A good2)
|
drvs=$($nixinstantiate fixed.nix -A good2)
|
||||||
echo $drvs
|
echo $drvs
|
||||||
$nixstore -r $drvs
|
$nixstore -r $drvs
|
||||||
|
|
||||||
|
echo 'testing bad...'
|
||||||
drvs=$($nixinstantiate fixed.nix -A bad)
|
drvs=$($nixinstantiate fixed.nix -A bad)
|
||||||
echo $drvs
|
echo $drvs
|
||||||
if $nixstore -r $drvs; then false; fi
|
if $nixstore -r $drvs; then false; fi
|
||||||
|
|
||||||
|
echo 'testing reallyBad...'
|
||||||
if $nixinstantiate fixed.nix -A reallyBad; then false; fi
|
if $nixinstantiate fixed.nix -A reallyBad; then false; fi
|
||||||
|
|
||||||
# While we're at it, check attribute selection a bit more.
|
# While we're at it, check attribute selection a bit more.
|
||||||
|
echo 'testing attribute selection...'
|
||||||
test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1
|
test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1
|
||||||
|
|
||||||
|
# Test parallel builds of derivations that produce the same output.
|
||||||
|
# Only one should run at the same time.
|
||||||
|
echo 'testing parallelSame...'
|
||||||
|
clearStore
|
||||||
|
drvs=$($nixinstantiate fixed.nix -A parallelSame)
|
||||||
|
echo $drvs
|
||||||
|
$nixstore -r $drvs -j2
|
||||||
|
|
Loading…
Reference in a new issue