@@ -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
1615Add KafkaEx to your mix.exs dependencies:
1716
@@ -244,54 +243,95 @@ KafkaEx.produce(produce_request)
244243
245244Compression 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```
291331mix dialyzer
292332```
293333
294- ### Contributing
334+ ## Contributing
295335
296336All contributions are managed through the
297337[ kafkaex github repo] ( https://github.com/kafkaex/kafka_ex ) .
0 commit comments