kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mewwts <...@git.apache.org>
Subject [GitHub] kafka pull request #3999: MINOR: Add attributes `processedKeys` and `process...
Date Mon, 02 Oct 2017 07:17:10 GMT
GitHub user mewwts opened a pull request:

    https://github.com/apache/kafka/pull/3999

    MINOR: Add attributes `processedKeys` and `processedValues` to MockProcessorSupplier

    This would allow for easier testing of topologies using the following pattern:
    ```Scala
    // in Scala
    val builder = new KStreamBuilder
    val stream: KStream[K, V] = builder.stream(KSerde, VSerde, topic)
    
    val processedStream: KStream[K, VR] =createTopology(stream, builder)
    
    val processorSupplier = new MyMockProcessorSupplier[K, VR]
    processedStream.process(processorSupplier)
    
    val streamDriver = new MyKStreamTestDriver(builder, TestUtils.tempDirectory())
    streamDriver.setTime(0L)
    
    streamDriver.process(topic, somethingK, somethingV)
    streamDriver.flushState()
    
    val results = (processorSupplier.processedKeys zip processorSupplier.processedValues).toMap
    results(expectedK) should be(expectedVR)
    ```
    Without breaking any existing tests that rely on the `processed` `ArrayList`. Of course
it's not as elegant as rewriting the logic here, as we're (almost) duplicating the information
in the `processed` array.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mewwts/kafka add-processed-keys-and-values

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/3999.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3999
    
----
commit ab8d7071ffbf7231f5bc82265f654616acd8b483
Author: Mats Julian Olsen <mats@plysjbyen.net>
Date:   2017-10-02T07:04:21Z

    Add attributes `processedKeys` and `processedValues`
    
    to MockProcessorSupplier.

----


---

Mime
View raw message