Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / servers / elasticmq-server-bin / elasticmq-test.nix
blob044b745089825626e5cbdaf64176e9600217fc4f
1 { elasticmq-server, python3Packages, runCommand, writeText}:
3 runCommand "${elasticmq-server.name}-tests" (let
4   commonPy = ''
5     import boto3
6     client = boto3.resource(
7       "sqs",
8       endpoint_url="http://localhost:9324",
9       region_name="elasticmq",
10       aws_secret_access_key="x",
11       aws_access_key_id="x",
12       use_ssl=False,
13     )
14     queue = client.get_queue_by_name(QueueName="foobar")
15   '';
16 in {
17   buildInputs = with python3Packages; [ python boto3 ];
18   emqConfig = writeText "emq-test.conf" ''
19     generate-node-address = true
21     queues {
22       foobar {}
23     }
24   '';
25   putMessagePy = writeText "put_message.py" ''
26     ${commonPy}
27     queue.send_message(MessageBody="bazqux")
28   '';
29   checkMessagePy = writeText "check_message.py" ''
30     ${commonPy}
31     messages = queue.receive_messages()
32     print(f"Received {messages!r}")
33     assert len(messages) == 1
34     assert messages[0].body == "bazqux"
35   '';
36 }) ''
37   JAVA_TOOL_OPTIONS="-Dconfig.file=$emqConfig" ${elasticmq-server}/bin/elasticmq-server &
38   SERVER_PID=$!
39   sleep 10
41   python $putMessagePy
42   python $checkMessagePy
43   touch $out
45   # needed on darwin
46   kill $SERVER_PID