Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test Machine to Jackdaw #28

Merged
merged 6 commits into from
Jan 16, 2019
Merged

Add Test Machine to Jackdaw #28

merged 6 commits into from
Jan 16, 2019

Conversation

99-not-out
Copy link
Contributor

@99-not-out 99-not-out commented Jan 7, 2019

Moving the work from @cddr into Jackdaw (all credit to @cddr).

Adds machinery to Jackdaw for running black box tests against a kafka application, either directly against the brokers or via the confluent Rest Proxy API. Allows generation of a test which can then (without modification) be run locally, in CI or against a remote environment.

Documentation will be added soon!

@99-not-out 99-not-out added enhancement New feature or request WIP labels Jan 7, 2019
@99-not-out 99-not-out requested a review from a team as a code owner January 7, 2019 17:05
project.clj Outdated Show resolved Hide resolved
src/jackdaw/client.clj Outdated Show resolved Hide resolved
@99-not-out 99-not-out removed the WIP label Jan 10, 2019
@99-not-out 99-not-out changed the title [WIP] Add Test Machine to Jackdaw Add Test Machine to Jackdaw Jan 10, 2019
Matt Searle added 2 commits January 11, 2019 12:47
* Test machien run halts on first failed step
* Removed the NS from the keywords for test machine commands
* Made the logging stop splatting everything up the console
* If a test machine command is not recognoised, return a nicer error
* Added a pretty printing equivalent of the :println command
Copy link
Contributor

@cddr cddr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@creese creese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We should confirm aviso works with Clojure 1.10 style stack traces and after we upgrade to 1.10. there is still value there.

@@ -1,7 +1,9 @@
(defproject fundingcircle/jackdaw "_"
:description "A Clojure library for the Apache Kafka distributed streaming platform."

:dependencies [[clj-time "0.13.0"]
:dependencies [[aleph "0.4.6"]
[clj-time "0.13.0"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elsewhere, we have standardized on clojure.java-time. This is not a blocker.

:dependencies [[clj-time "0.13.0"]
:dependencies [[aleph "0.4.6"]
[clj-time "0.13.0"]
[org.clojure/core.async "0.4.474"]
Copy link
Contributor

@creese creese Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combination of aleph and core.async is an interesting choice. Would it be possible refactor towards one of these (with the possible addition of manifold)? This is not a blocker. I'm just wondering.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I think that makes sense. I ended up introducing aleph to support asynchronous http requests initiated by the rest-proxy transport.

But the go-loop in the test-machine should be relatively portable to aleph's d/loop and it shouldn't change the external contract to do so.

@@ -66,11 +69,11 @@

:test
{:resource-paths ["test/resources"]
:dependencies [[arohner/wait-for "1.0.2"]
:injections [(require 'io.aviso.logging.setup)]
:dependencies [[io.aviso/logging "0.3.1"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this compatible with Clojure 1.10 style stack traces? Do we use this for more than pretty printing of exceptions?

;; the options map `opts`.
;; - Further, the `opts` map can contain an explciit `:key` and/or
;; `:partition`, which if set will provide the values to use
;; If both specified, `opts` values will override values in the topic map.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a doc-string.

`consumer` should be a kafka consumer
`topic-config` should be a sequence of topic-metadata maps"
[consumer topic-config]
(kafka/subscribe consumer topic-config))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is subscribe meant to be part of a public API? Why not just use jackdaw.client/subscribe?

(doseq [assigned-partition assigned-partitions]
;; This forces the seek to happen now
(.position consumer assigned-partition))
consumer))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks similar to jackdaw.client/seek-to-end-eager. Can we use that instead?

https://github.com/FundingCircle/jackdaw/blob/master/src/jackdaw/client.clj#L218

[kafka-config topic-collection]
(-> (kafka/consumer kafka-config byte-array-serde)
(subscribe topic-collection)
(seek-to-end)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is similar to jackdaw.client/subscribed-consumer:
https://github.com/FundingCircle/jackdaw/blob/master/src/jackdaw/client.clj#L141

src/jackdaw/test/transports/kafka.clj Show resolved Hide resolved
src/jackdaw/test/transports/kafka.clj Show resolved Hide resolved
[clojure.test :refer :all]
[jackdaw.serdes.avro.schema-registry :as reg]
[jackdaw.streams :as k]
[jackdaw.test :as jd.test]
Copy link
Contributor

@creese creese Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elsewhere, we've used the equivalent of '[jackdaw.test :as jt]. I've also seen '[jackdaw.test :as j.test]. We should standardize on one of these three.

@99-not-out 99-not-out merged commit e9a1ad6 into master Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants