at 18.03-beta 1.5 kB view raw
1import ./make-test.nix ({ pkgs, lib, ... } : 2let 3 kafkaPackage = pkgs.apacheKafka_0_10; 4in { 5 name = "kafka_0_10"; 6 meta = with pkgs.stdenv.lib.maintainers; { 7 maintainers = [ nequissimus ]; 8 }; 9 10 nodes = { 11 zookeeper1 = { config, ... }: { 12 services.zookeeper = { 13 enable = true; 14 }; 15 16 networking.firewall.allowedTCPPorts = [ 2181 ]; 17 }; 18 kafka = { config, ... }: { 19 services.apache-kafka = { 20 enable = true; 21 extraProperties = '' 22 offsets.topic.replication.factor = 1 23 ''; 24 package = kafkaPackage; 25 zookeeper = "zookeeper1:2181"; 26 }; 27 28 networking.firewall.allowedTCPPorts = [ 9092 ]; 29 virtualisation.memorySize = 2048; 30 }; 31 }; 32 33 testScript = '' 34 startAll; 35 36 $zookeeper1->waitForUnit("zookeeper"); 37 $zookeeper1->waitForUnit("network.target"); 38 $zookeeper1->waitForOpenPort(2181); 39 40 $kafka->waitForUnit("apache-kafka"); 41 $kafka->waitForUnit("network.target"); 42 $kafka->waitForOpenPort(9092); 43 44 $kafka->waitUntilSucceeds("${kafkaPackage}/bin/kafka-topics.sh --create --zookeeper zookeeper1:2181 --partitions 1 --replication-factor 1 --topic testtopic"); 45 $kafka->mustSucceed("echo 'test 1' | ${kafkaPackage}/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testtopic"); 46 $kafka->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'"); 47 ''; 48})