Git Product home page Git Product logo

pact-kafka-schema-registry-demo's Introduction

Using PACT with Kafka and Schema Registry

Setup - PACT broker

This section will get you a PACT broker up and running locally, on port 9292. You need docker and docker-compose. From the command line:

docker-compose up

The PACT broker will now be reachable at: http://localhost:9292/

Run the consumer tests from the IDE

This will generate the PACTs, and the files will be found under target/pacts

Publish the PACTs to the broker:

mvn pact:publish

(Take a look on http://localhost:9292/)

Run the provider tests from the IDE

Note: They will read the PACTs from the broker but not publish their results to it

Run the provider tests from maven:

This will publish the provider test results to the broker:

mvn verify -Dpact.verifier.publishResults=true

(note the green and red fields on the broker)

The tests

These tests demonstrate how PACT deals with "messaging", as opposed to the more traditional (or at least, longer supported) HTTP Request-Response pairs.

The tests in the [consumer|provider].kafka package show:

  • a Kafka message with a JSON payload/value
  • a Kafka message with a Schema Registry verified JSON payload/value
  • a normal JSON consumer against a schema registry provider (failure!)

The tests also demonstrate some shortcomings. As the messaging layer from PACT does not involve you actually using that messaging from the tests (unlike the HTTP implementation), we can get tests to pass in strange ways:

  • We could have a consumer application listening on a websocket.
  • We could have a provider application writing to Kafka. and we can make the tests pass. Obviously, this would never work in reality, sad

pact-kafka-schema-registry-demo's People

Contributors

muirandy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ramzus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.