diff options
author | Jacek Galowicz <jacek.galowicz@cyberus-technology.de> | 2020-01-08 10:39:29 +0100 |
---|---|---|
committer | Jacek Galowicz <jacek.galowicz@cyberus-technology.de> | 2020-01-08 10:51:57 +0100 |
commit | f7b274d9571dfa81f2cf6589488c43d6e77e0d71 (patch) | |
tree | d936c6ecd6e6fe180693deac4a6f80f9a1625ddf /nixos/tests/kafka.nix | |
parent | 8ecd07f9e3b0ad23a4f8430945e4cb9db4dfa485 (diff) | |
download | nixpkgs-f7b274d9571dfa81f2cf6589488c43d6e77e0d71.tar nixpkgs-f7b274d9571dfa81f2cf6589488c43d6e77e0d71.tar.gz nixpkgs-f7b274d9571dfa81f2cf6589488c43d6e77e0d71.tar.bz2 nixpkgs-f7b274d9571dfa81f2cf6589488c43d6e77e0d71.tar.lz nixpkgs-f7b274d9571dfa81f2cf6589488c43d6e77e0d71.tar.xz nixpkgs-f7b274d9571dfa81f2cf6589488c43d6e77e0d71.tar.zst nixpkgs-f7b274d9571dfa81f2cf6589488c43d6e77e0d71.zip |
nixosTests.kafka: port to python
Diffstat (limited to 'nixos/tests/kafka.nix')
-rw-r--r-- | nixos/tests/kafka.nix | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/nixos/tests/kafka.nix b/nixos/tests/kafka.nix index 48ca98da8fa..30e5cc0417c 100644 --- a/nixos/tests/kafka.nix +++ b/nixos/tests/kafka.nix @@ -3,11 +3,10 @@ pkgs ? import ../.. { inherit system config; } }: -with import ../lib/testing.nix { inherit system pkgs; }; with pkgs.lib; let - makeKafkaTest = name: kafkaPackage: (makeTest { + makeKafkaTest = name: kafkaPackage: (import ./make-test-python.nix ({ inherit name; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; @@ -45,24 +44,40 @@ let }; testScript = '' - startAll; + start_all() - $zookeeper1->waitForUnit("default.target"); - $zookeeper1->waitForUnit("zookeeper.service"); - $zookeeper1->waitForOpenPort(2181); + zookeeper1.wait_for_unit("default.target") + zookeeper1.wait_for_unit("zookeeper.service") + zookeeper1.wait_for_open_port(2181) - $kafka->waitForUnit("default.target"); - $kafka->waitForUnit("apache-kafka.service"); - $kafka->waitForOpenPort(9092); + kafka.wait_for_unit("default.target") + kafka.wait_for_unit("apache-kafka.service") + kafka.wait_for_open_port(9092) - $kafka->waitUntilSucceeds("${kafkaPackage}/bin/kafka-topics.sh --create --zookeeper zookeeper1:2181 --partitions 1 --replication-factor 1 --topic testtopic"); - $kafka->mustSucceed("echo 'test 1' | ${kafkaPackage}/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testtopic"); + kafka.wait_until_succeeds( + "${kafkaPackage}/bin/kafka-topics.sh --create " + + "--zookeeper zookeeper1:2181 --partitions 1 " + + "--replication-factor 1 --topic testtopic" + ) + kafka.succeed( + "echo 'test 1' | " + + "${kafkaPackage}/bin/kafka-console-producer.sh " + + "--broker-list localhost:9092 --topic testtopic" + ) '' + (if name == "kafka_0_9" then '' - $kafka->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --zookeeper zookeeper1:2181 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'"); + assert "test 1" in kafka.succeed( + "${kafkaPackage}/bin/kafka-console-consumer.sh " + + "--zookeeper zookeeper1:2181 --topic testtopic " + + "--from-beginning --max-messages 1" + ) '' else '' - $kafka->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'"); + assert "test 1" in kafka.succeed( + "${kafkaPackage}/bin/kafka-console-consumer.sh " + + "--bootstrap-server localhost:9092 --topic testtopic " + + "--from-beginning --max-messages 1" + ) ''); - }); + }) {}); in with pkgs; { kafka_0_9 = makeKafkaTest "kafka_0_9" apacheKafka_0_9; |