apache-jena-fuseki: 4.8.0 -> 4.9.0, add a test

Adding a minimal test showing the Fuseki starts and handles a small
insert and a request. As the test is run in the minimal environment, add
the missing utilities to PATH in the wrapper.
This commit is contained in:
Michael Raskin 2023-07-16 15:46:15 +02:00
parent 4eb7071907
commit 24b7921044
2 changed files with 36 additions and 4 deletions

View File

@ -1,11 +1,20 @@
{ lib, stdenv, fetchurl, java, makeWrapper }:
{ lib
, stdenv
, fetchurl
, java
, coreutils
, which
, makeWrapper
# For the test
, pkgs
}:
stdenv.mkDerivation rec {
pname = "apache-jena-fuseki";
version = "4.8.0";
version = "4.9.0";
src = fetchurl {
url = "mirror://apache/jena/binaries/apache-jena-fuseki-${version}.tar.gz";
hash = "sha256-rJCY8vG1vfEGGA0gsIqNFXKl75O2Zp4zUIWSDfplpVE=";
hash = "sha256-t25Q0lb+ecR12cDD1p6eZnzLxW0kZpPOFGvo5YK7AlI=";
};
nativeBuildInputs = [
makeWrapper
@ -16,11 +25,16 @@ stdenv.mkDerivation rec {
ln -s "$out"/{fuseki-backup,fuseki-server,fuseki} "$out/bin"
for i in "$out"/bin/*; do
wrapProgram "$i" \
--prefix "PATH" : "${java}/bin/" \
--prefix "PATH" : "${java}/bin/:${coreutils}/bin:${which}/bin" \
--set-default "FUSEKI_HOME" "$out" \
;
done
'';
passthru = {
tests = {
basic-test = pkgs.callPackage ./fuseki-test.nix { };
};
};
meta = with lib; {
description = "SPARQL server";
license = licenses.asl20;

View File

@ -0,0 +1,18 @@
{ lib, runCommandNoCC, apache-jena-fuseki, curl }:
runCommandNoCC "fuseki-test-${apache-jena-fuseki.name}"
{ nativeBuildInputs = [ curl apache-jena-fuseki ]; } ''
export FUSEKI_BASE="$PWD/fuseki-base"
mkdir -p "$FUSEKI_BASE/db"
FUSEKI_ARGS="--update --loc=$FUSEKI_BASE/db /dataset" fuseki start
fuseki status
for i in $(seq 120); do
if curl http://127.0.0.1:3030/dataset/data; then
break;
fi
sleep 1
done
curl -d 'update=insert+data+{+<test://subject>+<test://predicate>+<test://object>+}' http://127.0.0.1:3030/dataset/update > /dev/null
curl http://127.0.0.1:3030/dataset/data | grep -C999 'test://predicate'
curl -d 'query=select+?s+?p+?o+where+{+?s+?p+?o+.+}' http://127.0.0.1:3030/dataset/query | grep -C999 'test://predicate'
touch $out
''