Git Product home page Git Product logo

disruptor-example's Introduction

Disruptor example

Basic example of chaos testing using xk6-disruptor extension.

In this example you can find three dummy services:

  • Frontend books service which exposes a frontend application showing the list of books available and purchased.
  • Books service which exposes an endpoint that list of available books to be purchased.
  • Bookstore service which exposes two endpoints to purchase books using their name and to check which books where purchased.

All the data is stored in memory without using any database to make it simple and focus on the disruptor.

โš ๏ธ The ingress deployed will use the host's 80 and 443 ports

Requirements

Prepare the cluster

  1. First we create a kind cluster, for that we use kind-cluster.yml configuration file to expose ports on the host machine:
kind create cluster --config kind-cluster.yml
  1. Next, we deploy an nginx ingress prepared for kind
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
  1. Wait for the ingress to be ready
kubectl wait --namespace ingress-nginx \
  --for=condition=ready pod \
  --selector=app.kubernetes.io/component=controller \
  --timeout=90s
  1. Deploy ingress configuration
kubectl apply -f ingress.yml
  1. Build the three images
docker build -t books-frontend:1.0.0 books-frontend
docker build -t bookstore:1.0.0 bookstore
docker build -t books:1.0.0 books
  1. Deploy the images inside kind cluster
kind load docker-image books-frontend:1.0.0
kind load docker-image bookstore:1.0.0
kind load docker-image books:1.0.0
  1. Deploy books-frontend, books and bookstore deployments into kind cluster
kubectl apply -f books-frontend/deployment.yml
kubectl apply -f books/deployment.yml
kubectl apply -f bookstore/deployment.yml

Prepare a k6 binary with xk6-disruptor extension

  1. Install xk6 cli
go install go.k6.io/xk6/cmd/xk6@latest
  1. Build k6 binary with xk6-disruptor
xk6 build --output k6-disruptor --with github.com/grafana/xk6-disruptor

Execute your disruptor test

  1. Without disruptors
./k6-disruptor run --env SKIP_FAULTS=1 disrup-test.js
  1. With disruptors
./k6-disruptor run disrup-test.js

The disruptor applied on the example test will inject http faults on the books-service causing it to have 500ms of latency and an error rate of 0.1.

Clean up

If you want you can delete the kind cluster with the command:

kind delete cluster

And remove any image left:

docker image rm books:1.0.0
docker image rm bookstore:1.0.0
docker image rm books-frontend:1.0.0

disruptor-example's People

Contributors

igomezal avatar

Watchers

 avatar  avatar

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.