about summary refs log tree commit diff
path: root/nixos/tests/kafka_0_11.nix
diff options
context:
space:
mode:
authorTim Steinbach <tim@nequissimus.com>2017-11-02 15:10:33 -0400
committerTim Steinbach <tim@nequissimus.com>2017-11-02 15:10:33 -0400
commitbeefaff2c19bdf1db24505cf2804487a3ba95b4c (patch)
treecfa8e89ba379d005b12a9a6e7b0e764b932bf21b /nixos/tests/kafka_0_11.nix
parentd27cf320cf23d45261b64326793e8e41bdba5971 (diff)
downloadnixlib-beefaff2c19bdf1db24505cf2804487a3ba95b4c.tar
nixlib-beefaff2c19bdf1db24505cf2804487a3ba95b4c.tar.gz
nixlib-beefaff2c19bdf1db24505cf2804487a3ba95b4c.tar.bz2
nixlib-beefaff2c19bdf1db24505cf2804487a3ba95b4c.tar.lz
nixlib-beefaff2c19bdf1db24505cf2804487a3ba95b4c.tar.xz
nixlib-beefaff2c19bdf1db24505cf2804487a3ba95b4c.tar.zst
nixlib-beefaff2c19bdf1db24505cf2804487a3ba95b4c.zip
kafka: Add tests
Diffstat (limited to 'nixos/tests/kafka_0_11.nix')
-rw-r--r--nixos/tests/kafka_0_11.nix48
1 files changed, 48 insertions, 0 deletions
diff --git a/nixos/tests/kafka_0_11.nix b/nixos/tests/kafka_0_11.nix
new file mode 100644
index 000000000000..39f9c36bb229
--- /dev/null
+++ b/nixos/tests/kafka_0_11.nix
@@ -0,0 +1,48 @@
+import ./make-test.nix ({ pkgs, lib, ... } :
+let
+  kafkaPackage = pkgs.apacheKafka_0_11;
+in {
+  name = "kafka_0_11";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ nequissimus ];
+  };
+
+  nodes = {
+    zookeeper1 = { config, ... }: {
+      services.zookeeper = {
+        enable = true;
+      };
+
+      networking.firewall.allowedTCPPorts = [ 2181 ];
+    };
+    kafka = { config, ... }: {
+      services.apache-kafka = {
+        enable = true;
+        extraProperties = ''
+          offsets.topic.replication.factor = 1
+        '';
+        package = kafkaPackage;
+        zookeeper = "zookeeper1:2181";
+      };
+
+      networking.firewall.allowedTCPPorts = [ 9092 ];
+      virtualisation.memorySize = 2048;
+    };
+  };
+
+  testScript = ''
+    startAll;
+
+    $zookeeper1->waitForUnit("zookeeper");
+    $zookeeper1->waitForUnit("network.target");
+    $zookeeper1->waitForOpenPort(2181);
+
+    $kafka->waitForUnit("apache-kafka");
+    $kafka->waitForUnit("network.target");
+    $kafka->waitForOpenPort(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->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'");
+  '';
+})