git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #31146 from NeQuissimus/kafka_updates

Kafka: Update + Tests

commit97f172a1d5e122ecd3ce2f8ce0af109f3e41d561 authorTim Steinbach <NeQuissimus@users.noreply.github.com> dateSat 4 Nov 2017, 11:06 (9 years ago) parenta789f5b30d4dec
8 files changed+249−16
nixos/release.nix+5−1 nixos/tests/kafka_0_10.nix+48 nixos/tests/kafka_0_11.nix+48 nixos/tests/kafka_0_9.nix+48 nixos/tests/kafka_1_0.nix+48 nixos/tests/zookeeper.nix+28 pkgs/servers/apache-kafka/default.nix+21−13 pkgs/top-level/all-packages.nix+3−2
nixos/release.nix+5−1
@@ -270,6 +270,10 @@ in rec {
270270 tests.plasma5 = callTest tests/plasma5.nix {};
271271 tests.keymap = callSubTests tests/keymap.nix {};
272272 tests.initrdNetwork = callTest tests/initrd-network.nix {};
273+ tests.kafka_0_9 = callTest tests/kafka_0_9.nix {};
274+ tests.kafka_0_10 = callTest tests/kafka_0_10.nix {};
275+ tests.kafka_0_11 = callTest tests/kafka_0_11.nix {};
276+ tests.kafka_1_0 = callTest tests/kafka_1_0.nix {};
273277 tests.kernel-copperhead = callTest tests/kernel-copperhead.nix {};
274278 tests.kernel-latest = callTest tests/kernel-latest.nix {};
275279 tests.kernel-lts = callTest tests/kernel-lts.nix {};
@@ -330,7 +334,7 @@ in rec {
330334 tests.wordpress = callTest tests/wordpress.nix {};
331335 tests.xfce = callTest tests/xfce.nix {};
332336 tests.xmonad = callTest tests/xmonad.nix {};
333−
337+ tests.zookeeper = callTest tests/zookeeper.nix {};
334338
335339 /* Build a bunch of typical closures so that Hydra can keep track of
336340 the evolution of closure sizes. */
nixos/tests/kafka_0_10.nixnew file+48
@@ -0,0 +1,48 @@
1+import ./make-test.nix ({ pkgs, lib, ... } :
2+let
3+ kafkaPackage = pkgs.apacheKafka_0_10;
4+in {
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+})
nixos/tests/kafka_0_11.nixnew file+48
@@ -0,0 +1,48 @@
1+import ./make-test.nix ({ pkgs, lib, ... } :
2+let
3+ kafkaPackage = pkgs.apacheKafka_0_11;
4+in {
5+ name = "kafka_0_11";
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+})
nixos/tests/kafka_0_9.nixnew file+48
@@ -0,0 +1,48 @@
1+import ./make-test.nix ({ pkgs, lib, ... } :
2+let
3+ kafkaPackage = pkgs.apacheKafka_0_9;
4+in {
5+ name = "kafka_0_9";
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 --zookeeper zookeeper1:2181 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'");
47+ '';
48+})
nixos/tests/kafka_1_0.nixnew file+48
@@ -0,0 +1,48 @@
1+import ./make-test.nix ({ pkgs, lib, ... } :
2+let
3+ kafkaPackage = pkgs.apacheKafka_1_0;
4+in {
5+ name = "kafka_1_0";
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+})
nixos/tests/zookeeper.nixnew file+28
@@ -0,0 +1,28 @@
1+import ./make-test.nix ({ pkgs, ...} : {
2+ name = "zookeeper";
3+ meta = with pkgs.stdenv.lib.maintainers; {
4+ maintainers = [ nequissimus ];
5+ };
6+
7+ nodes = {
8+ server = { pkgs, config, ... }: {
9+ services.zookeeper = {
10+ enable = true;
11+ };
12+
13+ networking.firewall.allowedTCPPorts = [ 2181 ];
14+ };
15+ };
16+
17+ testScript = ''
18+ startAll;
19+
20+ $server->waitForUnit("zookeeper");
21+ $server->waitForUnit("network.target");
22+ $server->waitForOpenPort(2181);
23+
24+ $server->waitUntilSucceeds("${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar");
25+ $server->waitUntilSucceeds("${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello");
26+ $server->waitUntilSucceeds("${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello");
27+ '';
28+})
pkgs/servers/apache-kafka/default.nix+21−13
@@ -1,20 +1,28 @@
11{ stdenv, fetchurl, jre, makeWrapper, bash,
2− majorVersion ? "0.9" }:
2+ majorVersion ? "1.0" }:
33
44let
55 versionMap = {
6− "0.8" = { kafkaVersion = "0.8.2.2";
7− scalaVersion = "2.10";
8− sha256 = "1azccf1k0nr8y1sfpjgqf9swyp87ypvgva68ci4kczwcx1z9d89v";
9− };
10− "0.9" = { kafkaVersion = "0.9.0.1";
11− scalaVersion = "2.11";
12− sha256 = "0ykcjv5dz9i5bws9my2d60pww1g9v2p2nqr67h0i2xrjm7az8a6v";
13− };
14− "0.10" = { kafkaVersion = "0.10.2.0";
15− scalaVersion = "2.12";
16− sha256 = "0py43s6zv8z7wr2lk8403k07xxckl11gla3vs4gr99lixc4whis1";
17− };
6+ "0.9" = {
7+ kafkaVersion = "0.9.0.1";
8+ scalaVersion = "2.11";
9+ sha256 = "0ykcjv5dz9i5bws9my2d60pww1g9v2p2nqr67h0i2xrjm7az8a6v";
10+ };
11+ "0.10" = {
12+ kafkaVersion = "0.10.2.1";
13+ scalaVersion = "2.12";
14+ sha256 = "0iszr6r0n9yjgq7kcp1hf00fg754m86gs4jzqc18542an94b88z5";
15+ };
16+ "0.11" = {
17+ kafkaVersion = "0.11.0.1";
18+ scalaVersion = "2.12";
19+ sha256 = "1wj639h95aq5n132fq1rbyzqh5rsa4mlhbg3c5mszqglnzdz4xn7";
20+ };
21+ "1.0" = {
22+ kafkaVersion = "1.0.0";
23+ scalaVersion = "2.12";
24+ sha256 = "1cs4nmp39m99gqjpy5klsffqksc0h9pz514jkq99qb95a83x1cfm";
25+ };
1826 };
1927in
2028
pkgs/top-level/all-packages.nix+3−2
@@ -6871,10 +6871,11 @@ with pkgs;
68716871
68726872 apacheAnt = callPackage ../development/tools/build-managers/apache-ant { };
68736873
6874− apacheKafka = apacheKafka_0_10;
6875− apacheKafka_0_8 = callPackage ../servers/apache-kafka { majorVersion = "0.8"; };
6874+ apacheKafka = apacheKafka_1_0;
68766875 apacheKafka_0_9 = callPackage ../servers/apache-kafka { majorVersion = "0.9"; };
68776876 apacheKafka_0_10 = callPackage ../servers/apache-kafka { majorVersion = "0.10"; };
6877+ apacheKafka_0_11 = callPackage ../servers/apache-kafka { majorVersion = "0.11"; };
6878+ apacheKafka_1_0 = callPackage ../servers/apache-kafka { majorVersion = "1.0"; };
68786879
68796880 kt = callPackage ../tools/misc/kt {};
68806881