test: remove herb from test suite

This commit is contained in:
Joe Bryan 2022-04-04 11:43:12 -04:00
parent 216d63a910
commit 98d202d44b
3 changed files with 79 additions and 52 deletions

View File

@ -109,7 +109,6 @@ let
urbit-debug = urbit.override { enableDebug = true; }; urbit-debug = urbit.override { enableDebug = true; };
urbit-tests = libLocal.testFakeShip { urbit-tests = libLocal.testFakeShip {
inherit herb;
inherit arvo; inherit arvo;
urbit = urbit-debug; urbit = urbit-debug;

View File

@ -1,6 +1,6 @@
{ lib, stdenvNoCC, cacert }: { lib, stdenvNoCC, curl }:
{ urbit, herb, arvo ? null, pill, ship, arguments ? [ "-l" ] }: { urbit, arvo ? null, pill, ship, arguments ? [ "-l" ] }:
let let
@ -10,16 +10,11 @@ let
in stdenvNoCC.mkDerivation { in stdenvNoCC.mkDerivation {
name = "fake-${ship}"; name = "fake-${ship}";
buildInputs = [ cacert urbit herb ]; buildInputs = [ curl urbit ];
phases = [ "buildPhase" "installPhase " ]; phases = [ "buildPhase" "installPhase " ];
buildPhase = '' buildPhase = ''
if ! [ -f "$SSL_CERT_FILE" ]; then
header "$SSL_CERT_FILE doesn't exist"
exit 1
fi
set -xeuo pipefail set -xeuo pipefail
urbit ${lib.concatStringsSep " " args} ./pier urbit ${lib.concatStringsSep " " args} ./pier
@ -34,13 +29,27 @@ in stdenvNoCC.mkDerivation {
trap cleanup EXIT trap cleanup EXIT
port=$(cat ./pier/.http.ports | grep loopback | tr -s ' ' '\n' | head -n 1)
lensd() {
curl -f -s \
--data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
lensa() {
curl -f -s \
--data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
check () { check () {
[ 3 -eq "$(herb ./pier -d 3)" ] [ 3 -eq "$(lensd 3)" ]
} }
if check && sleep 10 && check; then if check && sleep 10 && check; then
header "boot success" header "boot success"
herb ./pier -p hood -d '+hood/exit' lensa hood '+hood/exit'
while [ -f ./pier/.vere.lock ]; do while [ -f ./pier/.vere.lock ]; do
echo "waiting for pier to shut down" echo "waiting for pier to shut down"
sleep 5 sleep 5
@ -48,8 +57,11 @@ in stdenvNoCC.mkDerivation {
else else
header "boot failure" header "boot failure"
kill $(< ./pier/.vere.lock) || true kill $(< ./pier/.vere.lock) || true
set +x
exit 1 exit 1
fi fi
set +x
''; '';
installPhase = '' installPhase = ''

View File

@ -1,16 +1,16 @@
{ lib, stdenvNoCC, cacert, python3, bootFakeShip }: { lib, stdenvNoCC, curl, python3, bootFakeShip }:
{ urbit, herb, arvo ? null, pill, ship ? "bus", arguments ? urbit.meta.arguments { urbit, arvo ? null, pill, ship ? "bus", arguments ? urbit.meta.arguments
, doCheck ? true }: , doCheck ? true }:
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
name = "test-${ship}"; name = "test-${ship}";
src = bootFakeShip { inherit urbit herb arvo pill ship; }; src = bootFakeShip { inherit urbit arvo pill ship; };
phases = [ "unpackPhase" "buildPhase" "checkPhase" ]; phases = [ "unpackPhase" "buildPhase" "checkPhase" ];
buildInputs = [ cacert urbit herb python3 ]; buildInputs = [ curl python3 urbit ];
unpackPhase = '' unpackPhase = ''
cp -R $src ./pier cp -R $src ./pier
@ -26,6 +26,22 @@ stdenvNoCC.mkDerivation {
# See: https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 # See: https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959
python3 -c $'import os\n[os.set_blocking(i, True) for i in range(3)]\n' python3 -c $'import os\n[os.set_blocking(i, True) for i in range(3)]\n'
port=$(cat ./pier/.http.ports | grep loopback | tr -s ' ' '\n' | head -n 1)
lensd() {
# -f elided, this can hit server-side timeouts
curl -s \
--data "{\"source\":{\"dojo\":\"$1\"},\"sink\":{\"stdout\":null}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
lensa() {
# -f elided, this can hit server-side timeouts
curl -s \
--data "{\"source\":{\"dojo\":\"$2\"},\"sink\":{\"app\":\"$1\"}}" \
"http://localhost:$port" | xargs printf %s | sed 's/\\n/\n/g'
}
tail -F urbit-output >&2 & tail -F urbit-output >&2 &
tailproc=$! tailproc=$!
@ -41,69 +57,69 @@ stdenvNoCC.mkDerivation {
# measure initial memory usage # measure initial memory usage
# #
herb ./pier -d '~& ~ ~& %init-mass-start ~' lensd '~& ~ ~& %init-mass-start ~'
herb ./pier -p hood -d '+hood/mass' lensa hood '+hood/mass'
herb ./pier -d '~& ~ ~& %init-mass-end ~' lensd '~& ~ ~& %init-mass-end ~'
# run the unit tests # run the unit tests
# #
herb ./pier -d '~& ~ ~& %test-unit-start ~' lensd '~& ~ ~& %test-unit-start ~'
herb ./pier -d '####-test %/tests ~' lensd '-test %/tests ~'
herb ./pier -d '~& ~ ~& %test-unit-end ~' lensd '~& ~ ~& %test-unit-end ~'
# use the :test app to build all agents, generators, and marks # use the :test app to build all agents, generators, and marks
# #
herb ./pier -p hood -d '+hood/start %test' lensa hood '+hood/start %test'
herb ./pier -d '~& ~ ~& %test-agents-start ~' lensd '~& ~ ~& %test-agents-start ~'
herb ./pier -p test -d '%agents' lensa test '%agents'
herb ./pier -d '~& ~ ~& %test-agents-end ~' lensd '~& ~ ~& %test-agents-end ~'
herb ./pier -d '~& ~ ~& %test-generators-start ~' lensd '~& ~ ~& %test-generators-start ~'
herb ./pier -p test -d '%generators' lensa test '%generators'
herb ./pier -d '~& ~ ~& %test-generators-end ~' lensd '~& ~ ~& %test-generators-end ~'
herb ./pier -d '~& ~ ~& %test-marks-start ~' lensd '~& ~ ~& %test-marks-start ~'
herb ./pier -p test -d '%marks' lensa test '%marks'
herb ./pier -d '~& ~ ~& %test-marks-end ~' lensd '~& ~ ~& %test-marks-end ~'
# measure memory usage post tests # measure memory usage post tests
# #
herb ./pier -d '~& ~ ~& %test-mass-start ~' lensd '~& ~ ~& %test-mass-start ~'
herb ./pier -p hood -d '+hood/mass' lensa hood '+hood/mass'
herb ./pier -d '~& ~ ~& %test-mass-end ~' lensd '~& ~ ~& %test-mass-end ~'
# defragment the loom # defragment the loom
# #
herb ./pier -d '~& ~ ~& %pack-start ~' lensd '~& ~ ~& %pack-start ~'
herb ./pier -p hood -d '+hood/pack' lensa hood '+hood/pack'
herb ./pier -d '~& ~ ~& %pack-end ~' lensd '~& ~ ~& %pack-end ~'
# reclaim space within arvo # reclaim space within arvo
# #
herb ./pier -d '~& ~ ~& %trim-start ~' lensd '~& ~ ~& %trim-start ~'
herb ./pier -p hood -d '+hood/trim' lensa hood '+hood/trim'
herb ./pier -d '~& ~ ~& %trim-end ~' lensd '~& ~ ~& %trim-end ~'
# measure memory usage pre |meld # measure memory usage pre |meld
# #
herb ./pier -d '~& ~ ~& %trim-mass-start ~' lensd '~& ~ ~& %trim-mass-start ~'
herb ./pier -p hood -d '+hood/mass' lensa hood '+hood/mass'
herb ./pier -d '~& ~ ~& %trim-mass-end ~' lensd '~& ~ ~& %trim-mass-end ~'
# globally deduplicate # globally deduplicate
# #
herb ./pier -d '~& ~ ~& %meld-start ~' lensd '~& ~ ~& %meld-start ~'
herb ./pier -p hood -d '+hood/meld' lensa hood '+hood/meld'
herb ./pier -d '~& ~ ~& %meld-end ~' lensd '~& ~ ~& %meld-end ~'
# measure memory usage post |meld # measure memory usage post |meld
# #
herb ./pier -d '~& ~ ~& %meld-mass-start ~' lensd '~& ~ ~& %meld-mass-start ~'
herb ./pier -p hood -d '+hood/mass' lensa hood '+hood/mass'
herb ./pier -d '~& ~ ~& %meld-mass-end ~' lensd '~& ~ ~& %meld-mass-end ~'
herb ./pier -p hood -d '+hood/exit' lensa hood '+hood/exit'
cleanup cleanup
@ -128,6 +144,8 @@ stdenvNoCC.mkDerivation {
mkdir -p $out mkdir -p $out
cp test-output-* $out/ cp test-output-* $out/
set +x
''; '';
checkPhase = '' checkPhase = ''
@ -168,6 +186,4 @@ stdenvNoCC.mkDerivation {
# Fix 'bind: operation not permitted' when nix.useSandbox = true on darwin. # Fix 'bind: operation not permitted' when nix.useSandbox = true on darwin.
# See https://github.com/NixOS/nix/blob/5f6840fbb49ae5b534423bd8a4360646ee93dbaf/src/libstore/build.cc#L2961 # See https://github.com/NixOS/nix/blob/5f6840fbb49ae5b534423bd8a4360646ee93dbaf/src/libstore/build.cc#L2961
__darwinAllowLocalNetworking = true; __darwinAllowLocalNetworking = true;
meta = { platforms = [ "x86_64-linux" ]; };
} }