Testing Camel K integrations with Cloud Native BDD...Testing Camel K integrations with Cloud Native...

35
Testing Camel K integrations with Cloud Native BDD APACHECON @HOME Spt, 29th – Oct. 1st 2020

Transcript of Testing Camel K integrations with Cloud Native BDD...Testing Camel K integrations with Cloud Native...

  • Testing Camel K integrationswith Cloud Native BDD

    APACHECON @HOMESpt, 29th – Oct. 1st 2020

  • with Cloud Native BDD

    Testing Camel K integrations

    2

  • Testing Camel K integrations with Cloud Native BDD

    3

    ApacheCon @Home 2020

    ● Open source enthusiast● Middleware Integration● Test Automation

    ● Founder of https://citrusframework.org ● Senior Software Engineer @RedHat

    ● Twitter: @freaky_styley

    Speaker informationChristoph Deppisch

    https://citrusframework.orghttps://twitter.com/freaky_styley

  • Testing Camel K integrations with Cloud Native BDD

    4

    ApacheCon @Home 2020

    ● Apache Camel K

    ● Behavior Driven Development

    ● Why Cloud Native BDD?

    ● YAKS

    ● Demo

    ● Status & future work

    Agenda

  • Testing Camel K integrations with Cloud Native BDD

    5

    ApacheCon @Home 2020

    Apache Camel K

  • Testing Camel K integrations with Cloud Native BDD

    6

    ApacheCon @Home 2020

    What is Camel K!?

    Camel K

    A lightweight integration platform, born on Kubernetes, with serverless superpowers

    https://github.com/apache/camel-k

    https://github.com/apache/camel-k

  • Testing Camel K integrations with Cloud Native BDD

    7

    ApacheCon @Home 2020

    ● Subproject of Apache Camel (https://camel.apache.org/)

    ○ Swiss knife of integration

    ○ 340+ components

    ○ >10 years of development - still one of the most active Apache projects

    ● Camel K

    ○ Started on August 31st, 2018

    ○ Reached version 1.0.0 on June 9, 2020

    ○ A platform for directly running integrations on Openshift and Kubernetes

    ○ Based on (ex Core OS) operator-sdk

    What is Camel K!?

    https://camel.apache.org/

  • Testing Camel K integrations with Cloud Native BDD

    8

    ApacheCon @Home 2020

    Why integration?

    My app/service

  • Testing Camel K integrations with Cloud Native BDD

    9

    ApacheCon @Home 2020

    Why integration?

    My app/service

    App BApp A

    App C

  • Testing Camel K integrations with Cloud Native BDD

    10

    ApacheCon @Home 2020

    Why Camel?

    My app/service

    AppB

    AppA

  • Testing Camel K integrations with Cloud Native BDD

    11

    ApacheCon @Home 2020

    Why Camel?

    My app/service

    AppB

    AppA

    from(“pulsar://company/nsx/topic1”) .unmarshal().json() .transform().simple(“${body[data]}”) .to(“knative:event/activity”)

    from(“knative:event/produced”) .pollEnrich() .simple(“aws2-s3://bucket/fs/${header.Ce-File}”) .to(“kafka:ext-topic”)

  • Testing Camel K integrations with Cloud Native BDD

    12

    ApacheCon @Home 2020

    ● Write an integration file (Java, Groovy, Kotlin, JS, XML…)

    ● Execute (CLI)

    ● Running serverless on Kubernetes

    Camel K in action

    from(“knative:channel/xxxx”) .transform()... .to(“kafka:topic”)

    $ kamel run integration.java

  • Testing Camel K integrations with Cloud Native BDD

    13

    ApacheCon @Home 2020

    How can I test Camel K?

  • Testing Camel K integrations with Cloud Native BDD

    14

    ApacheCon @Home 2020

    Behavior Driven Development

  • Testing Camel K integrations with Cloud Native BDD

    15

    ApacheCon @Home 2020

    Communication

  • Testing Camel K integrations with Cloud Native BDD

    16

    ApacheCon @Home 2020

    Explaining the behavior

  • Testing Camel K integrations with Cloud Native BDD

    17

    ApacheCon @Home 2020

    Concrete Examples

  • Testing Camel K integrations with Cloud Native BDD

    18

    ApacheCon @Home 2020

    Gherkin

    Given a certain contextWhen some event happens

    Then an outcome should occur

  • Testing Camel K integrations with Cloud Native BDD

    19

    ApacheCon @Home 2020

    ● Write a feature file

    ● Execute (CLI)

    ● Running test on Kubernetes

    Why BDD?

    Given a certain contextWhen some event happensThen an outcome should occur

    $ yaks test integration.feature

  • Testing Camel K integrations with Cloud Native BDD

    20

    ApacheCon @Home 2020

    Why Cloud Native testing?

  • Testing Camel K integrations with Cloud Native BDD

    21

    ApacheCon @Home 2020

    ● Tests running within the container management platform

    ○ Tests as integrated part of the cloud infrastructure

    ○ Tests able to access internal services

    ○ Tests can simulate service providers

    ○ Tests are self contained

    Why Cloud Native!?

  • Kubernetes / OpenShift

    Testing Camel K integrations with Cloud Native BDD

    22

    ApacheCon @Home 2020

    Why Cloud Native?

    Testing tools

  • Testing Camel K integrations with Cloud Native BDD

    23

    ApacheCon @Home 2020

    YAKS

  • Testing Camel K integrations with Cloud Native BDD

    24

    ApacheCon @Home 2020

    ● https://github.com/citrusframework/yaks

    ● Born out of Camel K

    ● Current version 0.1.0 on September 29, 2020

    What is YAKS?

    YAKS

    Integration test framework to enable Cloud Native BDD testing on Kubernetes

    https://github.com/citrusframework/yaks

  • Testing Camel K integrations with Cloud Native BDD

    25

    ApacheCon @Home 2020

    Framework to run Gherkin BDD feature files as Java

    unit tests

    1st class tool support in IDE

    Open Source ACL 2.0

    Test framework with focus on messaging integration

    Powerful validation for message content such as Json, XML,

    plaintext, ...

    Open Source ACL 2.0

  • Testing Camel K integrations with Cloud Native BDD

    26

    ApacheCon @Home 2020

    Feature: Todo service

    Background: Given URL: http://todo.service

    Scenario: Health check Given wait for URL http://todo.service to return 200 OK Then path /health is healthy

    Scenario: Create task Given variable id is "citrus:randomNumber(5)" Given HTTP request body: {"id": "${id}", "task": "New task", "completed": 0} When send POST /todo/${id} Then receive HTTP 201 CREATED

    Scenario: GET When send GET /todo/${id} Then verify HTTP response body: {"id": "${id}", "task": "New task", "completed": 0} And receive HTTP 200 OK

  • Testing Camel K integrations with Cloud Native BDD

    27

    ApacheCon @Home 2020

    $ yaks test integration.feature

  • YAKS architecture

    Testing Camel K integrations with Cloud Native BDD

    28

    ApacheCon @Home 2020

    references

    Kubernetes / OpenShift

    Operation Runtime

    yaks CLI

    runtime

    http

    Ru

    ntim

    e

    jms

    kafka

    knative

    openapiYAKS

    Operator

    operator

    Test

    defines

    uses

    watches/manages

    Maven registry

    System Under Test

    invokes/verifies

    tools

    install

    csv

    generates

    OLM

    watches

    reconciles

    use

    Operator

    API

    Development

    com

    pile

    generates

  • 29

    Demo time!

  • Testing Camel K integrations with Cloud Native BDD

    30

    ApacheCon @Home 2020

    greeting-service

    en: “Hello ApacheCon!”de: “Hallo ApacheCon!”

    fr: “Bonjour ApacheCon!”it: “Ciao ApacheCon!”

    esp: “Hola ApacheCon!”

    greeting.feature

    Http GET /en

  • Testing Camel K integrations with Cloud Native BDD

    31

    ApacheCon @Home 2020

    greeting-service

    greeting.feature

    topic: greetings

    Http POST /en

    {“message”: “Hello ApacheCon!” }

  • Testing Camel K integrations with Cloud Native BDD

    32

    ApacheCon @Home 2020

    greeting-splitter

    greeting-service

    greeting.feature

    topic: greetings

    Http POST /en

    {“message”: “Hello ApacheCon!” }

  • Testing Camel K integrations with Cloud Native BDD

    33

    ApacheCon @Home 2020

    greeting-splitter

    greeting-service

    greeting.feature

    topic: greetings

    topic: greetings

    Http POST /en

    {“message”: “Hello ApacheCon!” }

    “Hello”

    “ApacheCon!”

    “Hello”

    “ApacheCon!”

  • Testing Camel K integrations with Cloud Native BDD

    34

    ApacheCon @Home 2020

    ● Attract community by helping to test

    ○ Camel K

    ○ Knative

    ○ Kafka

    ● Integrate test approach with CI pipelines (Tekton)

    ● Autodiscover infrastructure components (message brokers, APIs, DBs, ...)

    ● Contract driven testing (Open API)

    ● Visual tooling

    Get involved! https://github.com/citrusframework/yaks/issues

    Future work

    https://github.com/citrusframework/yaks/issues

  • linkedin.com/company/red-hat

    youtube.com/user/RedHatVideos

    facebook.com/redhatinc

    twitter.com/RedHat

    Red Hat is the world’s leading provider of enterprise

    open source software solutions. Award-winning

    support, training, and consulting services make

    Red Hat a trusted adviser to the Fortune 500.

    Thank you

    35