tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
kafka: Add tests
Tim Steinbach
8 years ago
beefaff2
d27cf320
+196
5 changed files
expand all
collapse all
unified
split
nixos
release.nix
tests
kafka_0_10.nix
kafka_0_11.nix
kafka_0_9.nix
kafka_1_0.nix
+4
nixos/release.nix
···
270
270
tests.plasma5 = callTest tests/plasma5.nix {};
271
271
tests.keymap = callSubTests tests/keymap.nix {};
272
272
tests.initrdNetwork = callTest tests/initrd-network.nix {};
273
273
+
tests.kafka_0_9 = callTest tests/kafka_0_9.nix {};
274
274
+
tests.kafka_0_10 = callTest tests/kafka_0_10.nix {};
275
275
+
tests.kafka_0_11 = callTest tests/kafka_0_11.nix {};
276
276
+
tests.kafka_1_0 = callTest tests/kafka_1_0.nix {};
273
277
tests.kernel-copperhead = callTest tests/kernel-copperhead.nix {};
274
278
tests.kernel-latest = callTest tests/kernel-latest.nix {};
275
279
tests.kernel-lts = callTest tests/kernel-lts.nix {};
+48
nixos/tests/kafka_0_10.nix
···
1
1
+
import ./make-test.nix ({ pkgs, lib, ... } :
2
2
+
let
3
3
+
kafkaPackage = pkgs.apacheKafka_0_10;
4
4
+
in {
5
5
+
name = "kafka_0_10";
6
6
+
meta = with pkgs.stdenv.lib.maintainers; {
7
7
+
maintainers = [ nequissimus ];
8
8
+
};
9
9
+
10
10
+
nodes = {
11
11
+
zookeeper1 = { config, ... }: {
12
12
+
services.zookeeper = {
13
13
+
enable = true;
14
14
+
};
15
15
+
16
16
+
networking.firewall.allowedTCPPorts = [ 2181 ];
17
17
+
};
18
18
+
kafka = { config, ... }: {
19
19
+
services.apache-kafka = {
20
20
+
enable = true;
21
21
+
extraProperties = ''
22
22
+
offsets.topic.replication.factor = 1
23
23
+
'';
24
24
+
package = kafkaPackage;
25
25
+
zookeeper = "zookeeper1:2181";
26
26
+
};
27
27
+
28
28
+
networking.firewall.allowedTCPPorts = [ 9092 ];
29
29
+
virtualisation.memorySize = 2048;
30
30
+
};
31
31
+
};
32
32
+
33
33
+
testScript = ''
34
34
+
startAll;
35
35
+
36
36
+
$zookeeper1->waitForUnit("zookeeper");
37
37
+
$zookeeper1->waitForUnit("network.target");
38
38
+
$zookeeper1->waitForOpenPort(2181);
39
39
+
40
40
+
$kafka->waitForUnit("apache-kafka");
41
41
+
$kafka->waitForUnit("network.target");
42
42
+
$kafka->waitForOpenPort(9092);
43
43
+
44
44
+
$kafka->waitUntilSucceeds("${kafkaPackage}/bin/kafka-topics.sh --create --zookeeper zookeeper1:2181 --partitions 1 --replication-factor 1 --topic testtopic");
45
45
+
$kafka->mustSucceed("echo 'test 1' | ${kafkaPackage}/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testtopic");
46
46
+
$kafka->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'");
47
47
+
'';
48
48
+
})
+48
nixos/tests/kafka_0_11.nix
···
1
1
+
import ./make-test.nix ({ pkgs, lib, ... } :
2
2
+
let
3
3
+
kafkaPackage = pkgs.apacheKafka_0_11;
4
4
+
in {
5
5
+
name = "kafka_0_11";
6
6
+
meta = with pkgs.stdenv.lib.maintainers; {
7
7
+
maintainers = [ nequissimus ];
8
8
+
};
9
9
+
10
10
+
nodes = {
11
11
+
zookeeper1 = { config, ... }: {
12
12
+
services.zookeeper = {
13
13
+
enable = true;
14
14
+
};
15
15
+
16
16
+
networking.firewall.allowedTCPPorts = [ 2181 ];
17
17
+
};
18
18
+
kafka = { config, ... }: {
19
19
+
services.apache-kafka = {
20
20
+
enable = true;
21
21
+
extraProperties = ''
22
22
+
offsets.topic.replication.factor = 1
23
23
+
'';
24
24
+
package = kafkaPackage;
25
25
+
zookeeper = "zookeeper1:2181";
26
26
+
};
27
27
+
28
28
+
networking.firewall.allowedTCPPorts = [ 9092 ];
29
29
+
virtualisation.memorySize = 2048;
30
30
+
};
31
31
+
};
32
32
+
33
33
+
testScript = ''
34
34
+
startAll;
35
35
+
36
36
+
$zookeeper1->waitForUnit("zookeeper");
37
37
+
$zookeeper1->waitForUnit("network.target");
38
38
+
$zookeeper1->waitForOpenPort(2181);
39
39
+
40
40
+
$kafka->waitForUnit("apache-kafka");
41
41
+
$kafka->waitForUnit("network.target");
42
42
+
$kafka->waitForOpenPort(9092);
43
43
+
44
44
+
$kafka->waitUntilSucceeds("${kafkaPackage}/bin/kafka-topics.sh --create --zookeeper zookeeper1:2181 --partitions 1 --replication-factor 1 --topic testtopic");
45
45
+
$kafka->mustSucceed("echo 'test 1' | ${kafkaPackage}/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testtopic");
46
46
+
$kafka->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'");
47
47
+
'';
48
48
+
})
+48
nixos/tests/kafka_0_9.nix
···
1
1
+
import ./make-test.nix ({ pkgs, lib, ... } :
2
2
+
let
3
3
+
kafkaPackage = pkgs.apacheKafka_0_9;
4
4
+
in {
5
5
+
name = "kafka_0_9";
6
6
+
meta = with pkgs.stdenv.lib.maintainers; {
7
7
+
maintainers = [ nequissimus ];
8
8
+
};
9
9
+
10
10
+
nodes = {
11
11
+
zookeeper1 = { config, ... }: {
12
12
+
services.zookeeper = {
13
13
+
enable = true;
14
14
+
};
15
15
+
16
16
+
networking.firewall.allowedTCPPorts = [ 2181 ];
17
17
+
};
18
18
+
kafka = { config, ... }: {
19
19
+
services.apache-kafka = {
20
20
+
enable = true;
21
21
+
extraProperties = ''
22
22
+
offsets.topic.replication.factor = 1
23
23
+
'';
24
24
+
package = kafkaPackage;
25
25
+
zookeeper = "zookeeper1:2181";
26
26
+
};
27
27
+
28
28
+
networking.firewall.allowedTCPPorts = [ 9092 ];
29
29
+
virtualisation.memorySize = 2048;
30
30
+
};
31
31
+
};
32
32
+
33
33
+
testScript = ''
34
34
+
startAll;
35
35
+
36
36
+
$zookeeper1->waitForUnit("zookeeper");
37
37
+
$zookeeper1->waitForUnit("network.target");
38
38
+
$zookeeper1->waitForOpenPort(2181);
39
39
+
40
40
+
$kafka->waitForUnit("apache-kafka");
41
41
+
$kafka->waitForUnit("network.target");
42
42
+
$kafka->waitForOpenPort(9092);
43
43
+
44
44
+
$kafka->waitUntilSucceeds("${kafkaPackage}/bin/kafka-topics.sh --create --zookeeper zookeeper1:2181 --partitions 1 --replication-factor 1 --topic testtopic");
45
45
+
$kafka->mustSucceed("echo 'test 1' | ${kafkaPackage}/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testtopic");
46
46
+
$kafka->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --zookeeper zookeeper1:2181 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'");
47
47
+
'';
48
48
+
})
+48
nixos/tests/kafka_1_0.nix
···
1
1
+
import ./make-test.nix ({ pkgs, lib, ... } :
2
2
+
let
3
3
+
kafkaPackage = pkgs.apacheKafka_1_0;
4
4
+
in {
5
5
+
name = "kafka_1_0";
6
6
+
meta = with pkgs.stdenv.lib.maintainers; {
7
7
+
maintainers = [ nequissimus ];
8
8
+
};
9
9
+
10
10
+
nodes = {
11
11
+
zookeeper1 = { config, ... }: {
12
12
+
services.zookeeper = {
13
13
+
enable = true;
14
14
+
};
15
15
+
16
16
+
networking.firewall.allowedTCPPorts = [ 2181 ];
17
17
+
};
18
18
+
kafka = { config, ... }: {
19
19
+
services.apache-kafka = {
20
20
+
enable = true;
21
21
+
extraProperties = ''
22
22
+
offsets.topic.replication.factor = 1
23
23
+
'';
24
24
+
package = kafkaPackage;
25
25
+
zookeeper = "zookeeper1:2181";
26
26
+
};
27
27
+
28
28
+
networking.firewall.allowedTCPPorts = [ 9092 ];
29
29
+
virtualisation.memorySize = 2048;
30
30
+
};
31
31
+
};
32
32
+
33
33
+
testScript = ''
34
34
+
startAll;
35
35
+
36
36
+
$zookeeper1->waitForUnit("zookeeper");
37
37
+
$zookeeper1->waitForUnit("network.target");
38
38
+
$zookeeper1->waitForOpenPort(2181);
39
39
+
40
40
+
$kafka->waitForUnit("apache-kafka");
41
41
+
$kafka->waitForUnit("network.target");
42
42
+
$kafka->waitForOpenPort(9092);
43
43
+
44
44
+
$kafka->waitUntilSucceeds("${kafkaPackage}/bin/kafka-topics.sh --create --zookeeper zookeeper1:2181 --partitions 1 --replication-factor 1 --topic testtopic");
45
45
+
$kafka->mustSucceed("echo 'test 1' | ${kafkaPackage}/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testtopic");
46
46
+
$kafka->mustSucceed("${kafkaPackage}/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testtopic --from-beginning --max-messages 1 | grep 'test 1'");
47
47
+
'';
48
48
+
})