2018-11-11 09:41:11 +01:00
|
|
|
{ system ? builtins.currentSystem,
|
|
|
|
config ? {},
|
|
|
|
pkgs ? import ../.. { inherit system config; }
|
|
|
|
}:
|
|
|
|
|
2018-05-12 02:16:25 +02:00
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
2020-01-08 10:39:29 +01:00
|
|
|
makeKafkaTest = name: kafkaPackage: (import ./make-test-python.nix ({
|
2018-05-12 02:16:25 +02:00
|
|
|
inherit name;
|
2021-01-10 20:08:30 +01:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2018-05-12 02:16:25 +02:00
|
|
|
maintainers = [ nequissimus ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
2018-07-20 22:56:59 +02:00
|
|
|
zookeeper1 = { ... }: {
|
2018-05-12 02:16:25 +02:00
|
|
|
services.zookeeper = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 2181 ];
|
|
|
|
virtualisation.memorySize = 1024;
|
|
|
|
};
|
2018-07-20 22:56:59 +02:00
|
|
|
kafka = { ... }: {
|
2018-05-12 02:16:25 +02:00
|
|
|
services.apache-kafka = {
|
|
|
|
enable = true;
|
|
|
|
extraProperties = ''
|
|
|
|
offsets.topic.replication.factor = 1
|
|
|
|
zookeeper.session.timeout.ms = 600000
|
|
|
|
'';
|
|
|
|
package = kafkaPackage;
|
|
|
|
zookeeper = "zookeeper1:2181";
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 9092 ];
|
|
|
|
# i686 tests: qemu-system-i386 can simulate max 2047MB RAM (not 2048)
|
2018-12-03 17:43:34 +01:00
|
|
|
virtualisation.memorySize = 2047;
|
2018-05-12 02:16:25 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2020-01-08 10:39:29 +01:00
|
|
|
start_all()
|
2018-05-12 02:16:25 +02:00
|
|
|
|
2020-01-08 10:39:29 +01:00
|
|
|
zookeeper1.wait_for_unit("default.target")
|
|
|
|
zookeeper1.wait_for_unit("zookeeper.service")
|
|
|
|
zookeeper1.wait_for_open_port(2181)
|
2018-05-12 02:16:25 +02:00
|
|
|
|
2020-01-08 10:39:29 +01:00
|
|
|
kafka.wait_for_unit("default.target")
|
|
|
|
kafka.wait_for_unit("apache-kafka.service")
|
|
|
|
kafka.wait_for_open_port(9092)
|
2018-05-12 02:16:25 +02:00
|
|
|
|
2020-01-08 10:39:29 +01:00
|
|
|
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"
|
|
|
|
)
|
2018-05-12 02:16:25 +02:00
|
|
|
'' + (if name == "kafka_0_9" then ''
|
2020-01-08 10:39:29 +01:00
|
|
|
assert "test 1" in kafka.succeed(
|
|
|
|
"${kafkaPackage}/bin/kafka-console-consumer.sh "
|
|
|
|
+ "--zookeeper zookeeper1:2181 --topic testtopic "
|
|
|
|
+ "--from-beginning --max-messages 1"
|
|
|
|
)
|
2018-05-12 02:16:25 +02:00
|
|
|
'' else ''
|
2020-01-08 10:39:29 +01:00
|
|
|
assert "test 1" in kafka.succeed(
|
|
|
|
"${kafkaPackage}/bin/kafka-console-consumer.sh "
|
|
|
|
+ "--bootstrap-server localhost:9092 --topic testtopic "
|
|
|
|
+ "--from-beginning --max-messages 1"
|
|
|
|
)
|
2018-05-12 02:16:25 +02:00
|
|
|
'');
|
2020-04-07 17:50:58 +02:00
|
|
|
}) { inherit system; });
|
2018-05-12 02:16:25 +02:00
|
|
|
|
|
|
|
in with pkgs; {
|
2021-08-05 13:01:59 +02:00
|
|
|
kafka_2_7 = makeKafkaTest "kafka_2_7" apacheKafka_2_7;
|
|
|
|
kafka_2_8 = makeKafkaTest "kafka_2_8" apacheKafka_2_8;
|
2018-05-12 02:16:25 +02:00
|
|
|
}
|