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,12 +1,13 @@
|
|||
{ lib, stdenv, fetchurl, jdk, jre, makeWrapper }:
|
||||
{ lib, stdenv, fetchurl, jdk, jre, makeWrapper, runCommand, python3Packages, writeText }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
let
|
||||
elasticmq-server = stdenv.mkDerivation rec {
|
||||
pname = "elasticmq-server";
|
||||
version = "0.14.6";
|
||||
version = "1.2.0";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://s3-eu-west-1.amazonaws.com/softwaremill-public/${pname}-${version}.jar";
|
||||
sha256 = "1cp2pmkc6gx7gr6109jlcphlky5rr6s1wj528r6hyhzdc01sjhhz";
|
||||
sha256 = "06bn5ixz0pvvhfvavr6njv8c2i9pgd6gj32wnp2f0fn0z1kypn1f";
|
||||
};
|
||||
|
||||
# don't do anything?
|
||||
|
@ -31,4 +32,9 @@ stdenv.mkDerivation rec {
|
|||
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