Merge pull request #97299 from risicle/ris-elasticmq-server-0.15.7-tests
elasticmq-server: 0.14.6 -> 1.2.0, add passthru.tests
This commit is contained in:
commit
6aef13b5ed
2 changed files with 83 additions and 30 deletions
|
@ -1,34 +1,40 @@
|
|||
{ lib, stdenv, fetchurl, jdk, jre, makeWrapper }:
|
||||
{ lib, stdenv, fetchurl, jdk, jre, makeWrapper, runCommand, python3Packages, writeText }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "elasticmq-server";
|
||||
version = "0.14.6";
|
||||
let
|
||||
elasticmq-server = stdenv.mkDerivation rec {
|
||||
pname = "elasticmq-server";
|
||||
version = "1.2.0";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://s3-eu-west-1.amazonaws.com/softwaremill-public/${pname}-${version}.jar";
|
||||
sha256 = "1cp2pmkc6gx7gr6109jlcphlky5rr6s1wj528r6hyhzdc01sjhhz";
|
||||
src = fetchurl {
|
||||
url = "https://s3-eu-west-1.amazonaws.com/softwaremill-public/${pname}-${version}.jar";
|
||||
sha256 = "06bn5ixz0pvvhfvavr6njv8c2i9pgd6gj32wnp2f0fn0z1kypn1f";
|
||||
};
|
||||
|
||||
# don't do anything?
|
||||
unpackPhase = "${jdk}/bin/jar xf $src favicon.png";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/share/elasticmq-server
|
||||
|
||||
cp $src $out/share/elasticmq-server/elasticmq-server.jar
|
||||
|
||||
# TODO: how to add extraArgs? current workaround is to use JAVA_TOOL_OPTIONS environment to specify properties
|
||||
makeWrapper ${jre}/bin/java $out/bin/elasticmq-server \
|
||||
--add-flags "-jar $out/share/elasticmq-server/elasticmq-server.jar"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/softwaremill/elasticmq";
|
||||
description = "Message queueing system with Java, Scala and Amazon SQS-compatible interfaces";
|
||||
license = licenses.asl20;
|
||||
platforms = platforms.unix;
|
||||
maintainers = with maintainers; [ peterromfeldhk ];
|
||||
};
|
||||
};
|
||||
|
||||
# don't do anything?
|
||||
unpackPhase = "${jdk}/bin/jar xf $src favicon.png";
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/share/elasticmq-server
|
||||
|
||||
cp $src $out/share/elasticmq-server/elasticmq-server.jar
|
||||
|
||||
# TODO: how to add extraArgs? current workaround is to use JAVA_TOOL_OPTIONS environment to specify properties
|
||||
makeWrapper ${jre}/bin/java $out/bin/elasticmq-server \
|
||||
--add-flags "-jar $out/share/elasticmq-server/elasticmq-server.jar"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/softwaremill/elasticmq";
|
||||
description = "Message queueing system with Java, Scala and Amazon SQS-compatible interfaces";
|
||||
license = licenses.asl20;
|
||||
platforms = platforms.unix;
|
||||
maintainers = with maintainers; [ peterromfeldhk ];
|
||||
in elasticmq-server.overrideAttrs (_: {
|
||||
passthru.tests.elasticmqTest = import ./elasticmq-test.nix {
|
||||
inherit elasticmq-server runCommand python3Packages writeText;
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
47
pkgs/servers/elasticmq-server-bin/elasticmq-test.nix
Normal file
47
pkgs/servers/elasticmq-server-bin/elasticmq-test.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{ elasticmq-server, python3Packages, runCommand, writeText}:
|
||||
|
||||
runCommand "${elasticmq-server.name}-tests" (let
|
||||
commonPy = ''
|
||||
import boto3
|
||||
client = boto3.resource(
|
||||
"sqs",
|
||||
endpoint_url="http://localhost:9324",
|
||||
region_name="elasticmq",
|
||||
aws_secret_access_key="x",
|
||||
aws_access_key_id="x",
|
||||
use_ssl=False,
|
||||
)
|
||||
queue = client.get_queue_by_name(QueueName="foobar")
|
||||
'';
|
||||
in {
|
||||
buildInputs = with python3Packages; [ python boto3 ];
|
||||
emqConfig = writeText "emq-test.conf" ''
|
||||
generate-node-address = true
|
||||
|
||||
queues {
|
||||
foobar {}
|
||||
}
|
||||
'';
|
||||
putMessagePy = writeText "put_message.py" ''
|
||||
${commonPy}
|
||||
queue.send_message(MessageBody="bazqux")
|
||||
'';
|
||||
checkMessagePy = writeText "check_message.py" ''
|
||||
${commonPy}
|
||||
messages = queue.receive_messages()
|
||||
print(f"Received {messages!r}")
|
||||
assert len(messages) == 1
|
||||
assert messages[0].body == "bazqux"
|
||||
'';
|
||||
}) ''
|
||||
JAVA_TOOL_OPTIONS="-Dconfig.file=$emqConfig" ${elasticmq-server}/bin/elasticmq-server &
|
||||
SERVER_PID=$!
|
||||
sleep 10
|
||||
|
||||
python $putMessagePy
|
||||
python $checkMessagePy
|
||||
touch $out
|
||||
|
||||
# needed on darwin
|
||||
kill $SERVER_PID
|
||||
''
|
Loading…
Reference in a new issue