Skip to content

Commit

Permalink
refactors code and introduces lint stage in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
theanirudhvyas committed Mar 25, 2019
1 parent 488abc1 commit 197c785
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ services:
- rabbitmq
- docker
stages:
- lint-check
- test
- name: deploy
if: (repo == gojektech/ziggurat) AND (tag IS present)
jobs:
include:
- stage: lint-check
script:
- lein cljfmt check
- lein kibit
- stage: test
name: "kafka-1"
env:
Expand Down
1 change: 0 additions & 1 deletion bin/run_tests_in_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set -ex
lein clean
lein deps
mv -fv resources/config.test.{ci.edn,edn}
lein cljfmt check
docker-compose up -d
sleep 15
docker exec -it ziggurat_kafka1_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --topic topic --partitions 3 --replication-factor 1 --zookeeper ziggurat_zookeeper_1
Expand Down
3 changes: 1 addition & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
[org.apache.kafka/kafka_2.11 "2.1.0" :classifier "test"]]
:plugins [[lein-cloverage "1.0.13"]]
:repositories [["confluent-repo" "https://packages.confluent.io/maven/"]]}
:dev {:plugins [[jonase/eastwood "0.2.6"]
[lein-cljfmt "0.6.3"]
:dev {:plugins [[lein-cljfmt "0.6.3"]
[lein-cloverage "1.0.13"]
[lein-kibit "0.1.6"]]}
:1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}
Expand Down
2 changes: 1 addition & 1 deletion src/ziggurat/timestamp_transformer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(deftype IngestionTimeExtractor [] TimestampExtractor
(extract [_ record _]
(let [ingestion-time (get-timestamp-from-record record)]
(if (< ingestion-time 0)
(if (neg? ingestion-time)
(get-current-time-in-millis)
ingestion-time))))

Expand Down
7 changes: 5 additions & 2 deletions test/ziggurat/streams_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
(defn mapped-fn [_]
:success)

(defn rand-application-id []
(str "test" "-" (rand-int 999999999)))

(deftest start-streams-with-since-test
(let [message-received-count (atom 0)]
(with-redefs [mapped-fn (fn [message-from-kafka]
Expand All @@ -46,7 +49,7 @@
oldest-processed-message-in-s 10
kvs (repeat times message-key-value)
streams (start-streams {:vehicle {:handler-fn mapped-fn}} (-> config-map
(assoc-in [:stream-router :vehicle :application-id] (str "test" "-" (rand-int 999999999)))
(assoc-in [:stream-router :vehicle :application-id] (rand-application-id))
(assoc-in [:stream-router :vehicle :oldest-processed-message-in-s] oldest-processed-message-in-s)
(assoc-in [:stream-router :vehicle :origin-topic] topic)))]
(Thread/sleep 20000) ;;waiting for streams to start
Expand All @@ -65,7 +68,7 @@
times 6
kvs (repeat times message-key-value)
streams (start-streams {:vehicle {:handler-fn mapped-fn}} (-> config-map
(assoc-in [:stream-router :vehicle :application-id] (str "test" "-" (rand-int 999999999)))
(assoc-in [:stream-router :vehicle :application-id] (rand-application-id))
(assoc-in [:stream-router :vehicle :origin-topic] topic)))]
(Thread/sleep 20000) ;;waiting for streams to start
(IntegrationTestUtils/produceKeyValuesSynchronously topic kvs props (MockTime.))
Expand Down

0 comments on commit 197c785

Please sign in to comment.