Skip to content

Commit ddc34a4

Browse files
authored
Remove unused scripts, update documentation wrt contributing & testing (#182)
* Remove unused scripts, update documentation * Increase heading levels Technically KafkaEx is the top-level header * Clarify in CONTRIBUTING.md After updating the README
1 parent da283f8 commit ddc34a4

File tree

11 files changed

+98
-102
lines changed

11 files changed

+98
-102
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- [Fork](https://github.com/kafkaex/kafka_ex/fork), then clone the repo: `git clone git@github.com:your-username/kafka_ex.git`
44
- Create a feature branch: `git checkout -b feature_branch`
55
- Make your changes
6+
- Make sure the tests all pass with the dockerized test cluster. See the "Testing" section of the README.
7+
```
8+
mix test --include integration --include consumer_group --include server_0_p_9_p_0
9+
```
610
- Make sure the unit tests pass: `mix test --no-start`
711
- Make sure the integration tests pass: `mix test --only integration`
812
- Make sure the consumer group tests pass: `mix test --only consumer_group`

README.md

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ KafkaEx
1010

1111
[Apache Kafka](http://kafka.apache.org/) (>= 0.8.0) client for Elixir/Erlang.
1212

13-
Usage
14-
-----
13+
## Usage
1514

1615
Add KafkaEx to your mix.exs dependencies:
1716

@@ -244,54 +243,95 @@ KafkaEx.produce(produce_request)
244243

245244
Compression is handled automatically on the consuming/fetching end.
246245

247-
### Test
246+
## Testing
247+
248+
It is strongly recommended to test using the Dockerized test cluster described
249+
below. This is required for contributions to KafkaEx.
250+
251+
**NOTE** You may have to run the test suite twice to get tests to pass. Due to
252+
asynchronous issues, the test suite sometimes fails on the first try.
253+
254+
### Dockerized Test Cluster
255+
256+
Testing KafkaEx requires a local SSL-enabled Kafka cluster with 3 nodes: one
257+
node listening on each port 9092, 9093, and 9093. The easiest way to do this
258+
is using the scripts in
259+
this repository that utilize [Docker](https://www.docker.com) and
260+
[Docker Compose](https://www.docker.com/products/docker-compose) (both of which
261+
are freely available). This is the method we use for our CI testing of
262+
KafkaEx.
263+
264+
To launch the included test cluster, run
248265

249-
#### Unit tests
250266
```
251-
mix test --no-start
267+
./scripts/docker_up.sh
252268
```
253269

254-
#### Integration tests
255-
Add the broker config to `config/config.exs` and run:
256-
##### Kafka >= 0.8.2
270+
The `docker_up.sh` script will attempt to determine an IP address for your
271+
computer on an active network interface. If it has trouble with this, you can
272+
try manually specifying a network interface in the `IP_IFACE` environment
273+
variable:
274+
257275
```
258-
mix test --only consumer_group --only integration
276+
IP_IFACE=eth0 ./scripts/docker_up.sh
259277
```
260-
##### Kafka < 0.8.2
278+
279+
The test cluster runs Kafka 0.9.2.
280+
281+
### Running the KafkaEx Tests
282+
283+
The KafkaEx tests are split up using tags to handle testing multiple scenarios
284+
and Kafka versions.
285+
286+
#### Unit tests
287+
288+
These tests do not require a Kafka cluster to be running.
289+
261290
```
262-
mix test --only integration
291+
mix test --no-start
263292
```
264293

265-
#### All tests
266-
##### Kafka >= 0.8.2
294+
#### Integration tests
295+
296+
If you are not using the Docker test cluster, you may need to modify
297+
`config/config.exs` for your set up.
298+
299+
The full test suite requires Kafka 0.9+.
300+
301+
##### Kafka >= 0.9.0
302+
303+
The 0.9 client includes functionality that cannot be tested with older
304+
clusters.
305+
267306
```
268-
mix test --include consumer_group --include integration
307+
mix test --include integration --include consumer_group --include server_0_p_9_p_0
269308
```
270-
##### Kafka < 0.8.2
309+
310+
##### Kafka >= 0.8.2 and < 0.9.0
311+
312+
Kafka 0.8.2 introduced the consumer group API.
313+
271314
```
272-
mix test --include integration
315+
mix test --include consumer_group --include integration
273316
```
274317

275-
### Testing with Docker
318+
##### Kafka < 0.8.2
276319

277-
Assuming you have Docker 1.12 or later installed, you can use the included
278-
scripts to launch a Kafka 0.9 cluster for testing.
320+
If your test cluster is older, the consumer group tests must be omitted.
279321

280322
```
281-
./scripts/docker_up.sh
282-
mix test --include integration --include consumer_group --include server_0_p_9_p_0
323+
mix test --include integration
283324
```
284325

285-
If `docker_up.sh` has trouble finding the correct network interface, you can
286-
manually specify one by running, e.g., `IP_IFACE=eth0 ./scripts/docker_up.sh`.
287-
288326
### Static analysis
289327

328+
This requires Elixir 1.3.2+.
329+
290330
```
291331
mix dialyzer
292332
```
293333

294-
### Contributing
334+
## Contributing
295335

296336
All contributions are managed through the
297337
[kafkaex github repo](https://github.com/kafkaex/kafka_ex).

scripts/README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
This directory contains three scripts to:
2-
* Install the Kafka version preferred for developing kafka_ex;
3-
* Start a three-node Kafka (and Zookeeper cluster);
4-
* Clean everything back up again.
5-
6-
The script `kafka_base_dir.sh` is used by the others to decide where to place Kafka; this way
7-
we can drop Kafka in a directory cached betweeen builds by Travis, hopefully speeding up builds
8-
and making them less dependent on the availability of Apache mirrors.
1+
The scripts in this directory are used for testing KafkaEx and are not part of
2+
the release package. Each script should have a comment near the top explaining
3+
its purpose.

scripts/active_ifaces.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/usr/bin/awk -f
2-
# print only active ifaces from ifconfig
2+
3+
# Print only active ifaces from ifconfig
34
# from http://unix.stackexchange.com/questions/103241/how-to-use-ifconfig-to-show-active-interface-only
45
# (using a version without pcregrep because that may not be available)
6+
#
7+
# We need the ip of an active network interface in order to properly launch the
8+
# dockerized Kafka cluster.
9+
510
BEGIN { print_it = 0 }
611
/status: active/ { print_it = 1 }
712
/^($|[^\t])/ { if(print_it) print buffer; buffer = $0; print_it = 0 }

scripts/ci_tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

33
# Runs the test suite for the travis build
4+
#
5+
# If COVERALLS is true, then we report test coverage to coveralls.
6+
#
7+
# This script could be used for local testing as long as COVERALLS is not set.
48

59
set -ev
610

scripts/cleanup_kafka.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

scripts/docker-start-kafka.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/bin/bash
22

3-
# this script is used when the docker kafka container starts
4-
# this version is specialized from
3+
# This script is used when the docker kafka container starts
4+
#
5+
# This version is specialized from
56
# https://github.com/wurstmeister/kafka-docker/blob/master/start-kafka.sh
67
# to work with our setup (esp. with ssl)
8+
#
9+
# Note that we mainly manage the server.properties file during `docker_up.sh`;
10+
# the wurstmeister/kafka behavior of translating KAFKA_* env vars to settings
11+
# is removed from this script.
712

813
set -ev
914

scripts/docker_up.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/bin/bash
22

3-
# launches the dockerized kafka cluster
3+
# Launches a dockerized kafka cluster configured for testing with KafkaEx
4+
#
5+
# This script attempts to auto-detect the ip address of an active network
6+
# interface using `./scripts/active_ifaces.sh`. You can override this by
7+
# supplying the name of an interface through the IP_IFACE env var - e.g.,
8+
#
9+
# IP_IFACE=eth0 ./scripts/docker_up.sh
10+
#
11+
# This script should be run from the project root
412

513
set -e
614

scripts/install_kafka.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

scripts/kafka_base_dir.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)