at 23.05-pre 2.3 kB view raw
1{ system ? builtins.currentSystem, 2 config ? {}, 3 pkgs ? import ../.. { inherit system config; } 4}: 5 6with pkgs.lib; 7 8let 9 makeKafkaTest = name: kafkaPackage: (import ./make-test-python.nix ({ 10 inherit name; 11 meta = with pkgs.lib.maintainers; { 12 maintainers = [ nequissimus ]; 13 }; 14 15 nodes = { 16 zookeeper1 = { ... }: { 17 services.zookeeper = { 18 enable = true; 19 }; 20 21 networking.firewall.allowedTCPPorts = [ 2181 ]; 22 }; 23 kafka = { ... }: { 24 services.apache-kafka = { 25 enable = true; 26 extraProperties = '' 27 offsets.topic.replication.factor = 1 28 zookeeper.session.timeout.ms = 600000 29 ''; 30 package = kafkaPackage; 31 zookeeper = "zookeeper1:2181"; 32 }; 33 34 networking.firewall.allowedTCPPorts = [ 9092 ]; 35 # i686 tests: qemu-system-i386 can simulate max 2047MB RAM (not 2048) 36 virtualisation.memorySize = 2047; 37 }; 38 }; 39 40 testScript = '' 41 start_all() 42 43 zookeeper1.wait_for_unit("default.target") 44 zookeeper1.wait_for_unit("zookeeper.service") 45 zookeeper1.wait_for_open_port(2181) 46 47 kafka.wait_for_unit("default.target") 48 kafka.wait_for_unit("apache-kafka.service") 49 kafka.wait_for_open_port(9092) 50 51 kafka.wait_until_succeeds( 52 "${kafkaPackage}/bin/kafka-topics.sh --create " 53 + "--bootstrap-server localhost:9092 --partitions 1 " 54 + "--replication-factor 1 --topic testtopic" 55 ) 56 kafka.succeed( 57 "echo 'test 1' | " 58 + "${kafkaPackage}/bin/kafka-console-producer.sh " 59 + "--broker-list localhost:9092 --topic testtopic" 60 ) 61 assert "test 1" in kafka.succeed( 62 "${kafkaPackage}/bin/kafka-console-consumer.sh " 63 + "--bootstrap-server localhost:9092 --topic testtopic " 64 + "--from-beginning --max-messages 1" 65 ) 66 ''; 67 }) { inherit system; }); 68 69in with pkgs; { 70 kafka_2_8 = makeKafkaTest "kafka_2_8" apacheKafka_2_8; 71 kafka_3_0 = makeKafkaTest "kafka_3_0" apacheKafka_3_0; 72 kafka_3_1 = makeKafkaTest "kafka_3_1" apacheKafka_3_1; 73 kafka_3_2 = makeKafkaTest "kafka_3_2" apacheKafka_3_2; 74 kafka_3_3 = makeKafkaTest "kafka_3_3" apacheKafka_3_3; 75 kafka = makeKafkaTest "kafka" apacheKafka; 76}