Apache Kafka is getting used as an event backbone in new organizations every day. We would love to send every byte of data through the event bus. Like traditional REST APIs, a contract-first approach is very useful when designing event-driven architectures. In the case of asynchronous APIs, we have the AsyncAPI specification to document the endpoints where the schema of the records become the main part of the contract payload. Microcks allows us to deploy a testing and mocking platform to have a unified view of the endpoints to speed-up application delivery.
In this session we will:
- Go over the evolution of API specifications
- Review the approach for contract-first design with Apache Kafka
- Introduce the AsyncAPI specification
- Take an overview of an implementation example for automated mocking and testing
4. #KAFKASUMMIT
icons by Made x Made from the Noun Project
@MICROCKSIO
The importance of
CONTRACT and EXAMPLES
GENERATED
EXAMPLES
GENERATED
REAL-LIFE
BUSINESS EXPECTATIONS
EXECUTABLE SPECIFICATIONS
MOCKS
& TESTS
5. @MICROCKSIO #KAFKASUMMIT
A new approach on Contracts
icons by Made x Made from the Noun Project
Service
Contract.
Development Test & Release
Specification
Service
Contract.
Synchronisation points
GOAL: DEFINE A PRAGMATIC APPROACH TO
MAKE SERVICE CONTRACTS USEFUL
FINALLY ;-)
THINK EXECUTABLE SPECIFICATION and *DD
Syntactic contract
Examples
Matching rules
6. Events everywhere.
Why the raise of events-driven API ?
Photo by Carol Jeng on Unsplash
#KAFKASUMMIT
@MICROCKSIO
8. @MICROCKSIO #EVENT-HASHTAG
SoapUI Project
(XML)
5.1+
Postman Collection
(JSON)
1.0, 2.x
Apicurio
(Studio)
OpenAPI 3.x
OpenAPI
(YAML, JSON)
3.x
AsyncAPI
(YAML, JSON)
2.x
SOAP WEB-
SERVICES REST APIs Event-driven APIs
(Kafka, AMQP, MQTT)
For what types of APIs ?
icons by Made x Made from the Noun Project
9. @MICROCKSIO #KAFKASUMMIT
Event-Driven Secret-Weapon
An open source initiative that seeks to improve the
current state of Event-Driven Architectures.
Created to describe Event-driven APIs using MQTT,
AMQP, Apache Kafka, ...
“Sister” specification to OpenAPI: same base syntax,
use JSON Schema or Avro underhood.
11. @MICROCKSIO #KAFKASUMMIT
AsyncAPI Anatomy
Info: metadata and documentation for this asynchronous API: version, title,
description, contact and licensing terms
Servers: list of brokers with binding details (URLs and security protocols)
Channel Item: destination that will be used by the API to publish or consume
events. Destination may be mapped to a topic, queue, address name depending
on the protocol binding.
Operation: whether the application using the AsyncAPI should subscribe or
produce messages. Holds its own descriptive metadata
Message: the content-type and structure of message headers and payload. May
reference schemas of different types (AsyncAPI, JSON, Avro). May contain
examples!
Components: Common definitions (schemas, traits, messages) like in OpenAPI v3
14. @MICROCKSIO #KAFKASUMMIT
Introducing Microcks
Open source Kubernetes-native tool for API Mocking
and Testing.
It provides an enterprise-grade solution to speed up,
secure and scale your API strategy for the digital era.
Microcks references any types of APIs or microservices
contracts and examples.
16. @MICROCKSIO #EVENT-HASHTAG
icons by Made x Made from the Noun Project
TECHNICAL
BUSINESS
SMOKE TESTS
SYNTACTIC CONTRACT TESTS
BUSINESS EXPECTATIONS TESTS
Ensure API endpoint is
correctly deployed
Ensure API implementation is
compliant with Swagger, OpenAPI
or WSDL contracts
Ensure API implementation
correctly respond - with respect to
business rules - to invocations
Different strategies available. Usable on
demand, matching your life cycle.
Test strategies
16
18. @MICROCKSIO #KAFKASUMMIT
All Kafkas
Every N sec.
user-signedup-api-
0.1.1-user-signedup
Microcks
connected broker
(mocking topic generated by Microcks)
Microcks
connected schema
registry
Any Schema
Registry
Listen events
during test
Any Kafka
broker
user-registration
(real application topic)
Azure Event
Hubs
19. EASE COLLABORATION
REUSE YOUR ASSETS
FOSTER INNOVATION
AND RAPID FEEDBACKS
CONTINUOUS SIMULATION AND
COMPLIANCE VALIDATION
SAME TOOLS FOR REST & SOAP
AND ASYNC API
COMING SOON: A COMMUNITY HUB TO SHARE
MOCKS AND TESTS !!
Microcks Benefits
#EVENT-HASHTAG
icons by Made x Made from the Noun Project
@MICROCKSIO
20. @MICROCKSIO #KAFKASUMMIT
More Resources
Apache Kafka Mocking and Testing
https://microcks.io/blog/apache-kafka-mocking-testing/
Continuous Testing - OpenAPI & AsyncAPI Together
https://microcks.io/blog/continuous-testing-all-your-apis/
How Microcks Can Speed-Up Your AsyncAPI Adoption - Part 1 & 2
https://www.asyncapi.com/blog/microcks-asyncapi-part1
https://www.asyncapi.com/blog/microcks-asyncapi-part2
Join the community on Zulip
https://microcksio.zulipchat.com
21. @MICROCKSIO #KAFKASUMMIT
We Need You!
Try Microcks (microcks.io) !
Come chat on Zulip microcksio.zulipchat.com
Follow us on Twitter @microcksio,
Distribute, & if you like it.
It’s a 100% Open Source.
And if you love it, contribute !
22. @MICROCKSIO #KAFKASUMMIT
THANK YOU !
Hugo Guerrero
Twitter: @hguerreroo
https://www.youtube.com/user/hguerreroo
https://developers.redhat.com/author/hugo-guerrero