FundingCircle / jackdaw

A Clojure library for the Apache Kafka distributed streaming platform.
https://fundingcircle.github.io/jackdaw/
BSD 3-Clause "New" or "Revised" License
369 stars 80 forks source link

Add ability to configure the group-config when creating a rest-proxy #206

Closed cddr closed 4 years ago

cddr commented 4 years ago

This change aims to allow test-machine users to supply their own consumer group configuration parameters when creating a test-machine that uses the rest-proxy. The allowed parameters are described in the API Docs.

One feature this is intended to support is to get the test-machine to read from the beginning of some topic that exists in another environment. This will allow users to retrieve data from e.g. production or staging environments, and run it through a test version of the application running on a developer machine without requiring access to the broker itself which can then be locked down for security purposes. Once this rest-proxy feature is merged, we'll get the ability to request data from a specific timestamp too.

When using this feature to read from the beginning, you'll likely want to also configure the fetch.min.bytes and consumer.fetch.timeout.ms properties to keep the response sizes reasonably small.

Example use would look something like this....

(deftest my-cool-regression-test
  (fix/with-fixtures [(app-topic-fixture)
                      (app-streams-fixture)]
    (with-open [uat-machine (jdt/test-machine (uat-transport))]
      (with-open [dev-machine (jdt/test-machine (dev-transport))]
        (let [uat-data (-> (jdt/run-test [[:watch (fn [journal]
                                                    (= 10
                                                       (count (get-in journal [:topics :my-app-topic]))))]])
                           :journal)]
          (let [regression-result (jdt/run-test (test-commands uat-data))]
            (is (ok? regression-result))))))))