Skip to content

emicklei/zazkia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1f6c2f2 · Dec 6, 2024

History

86 Commits
Jun 3, 2024
Jun 16, 2017
Feb 11, 2017
Oct 2, 2017
Apr 8, 2021
Apr 8, 2021
Feb 8, 2017
May 28, 2024
Jun 4, 2023
Jun 3, 2024
Jun 3, 2024
Feb 14, 2017
Jun 3, 2024
May 28, 2024
Dec 6, 2024
Feb 14, 2017
Apr 9, 2021
Feb 14, 2017
Feb 14, 2017
Feb 14, 2017
Feb 14, 2017
Jun 16, 2017
Feb 14, 2017
Feb 14, 2017
Feb 14, 2017
May 28, 2024
Feb 14, 2017
Dec 6, 2024
Dec 6, 2024
Apr 8, 2021
Dec 6, 2024
Apr 8, 2021
Dec 19, 2019
Apr 8, 2021
Dec 6, 2024
Oct 2, 2017
Dec 6, 2024
Dec 19, 2019
Dec 6, 2024
Nov 4, 2016
Apr 9, 2021
Apr 8, 2021
Feb 14, 2017
Dec 19, 2019

Repository files navigation

zazkia is a tool that simulates all kinds of connection problems with a tcp connection (reset,delay,throttle,corrupt).

systemtest dashboard

How does it work ?

In order to apply misbehavior, zazkia must be used as a proxy between a client and service. It will accept tcp connections from a client and for each new one, will create a connection to the target service.

Routes

By specifying routes, you can tell zazkia on what ports to listen and what target to connect to (host and port).

Minimal zazkia-routes.json example

[
    {
        "label": "oracle",
        "service-hostname": "some.host.name",
        "service-port": 1521,
        "listen-port": 49997
    }
]

With this route definition, your application should use "localhost:49997" instead of "some.host.name:1521" in the connection specification. Your application (the client) will setup a tcp connection with zazkia which will setup another tcp connection to oracle (the service).

Initial transport behavior

The transport part of a route configuration can be used to setup the initial behavior of a new connection pair (called link). Using a REST api, the transport behavior can be changed on a per-link basis.

Full zazkia-routes.json example

[
    {
        "label": "postgresql",
        "service-hostname": "some.other.host.name",
        "service-port": 5432,
        "listen-port": 49998,
        "transport": {
			"accept-connections": true,
			"throttle-service-response": 1000,
			"delay-service-response": 100,
			"break-service-response": 10,
			"service-response-corrupt-method": "randomize",
			"sending-to-client": true,
			"receiving-from-client": true,
			"sending-to-service": true,
			"receiving-from-service": true,
			"verbose": true
        }
    }
]
transport property comment effective values
accept-connections whether connections from the client are accepted true, false
throttle-service-response bytes per second non-negative integer
delay-service-response milliseconds delay non-negative integer
break-service-response percentage of broken connections integer between 0 and 100
service-response-corrupt-method how the bytes are mangled empty, randomize
sending-to-client whether a response from the service is sent back to the client true, false
receiving-from-client whether a request from the client is read true, false
sending-to-service whether a request from the client is sent to the service true, false
receiving-from-service whether a response from the service is read true, false
verbose log each message that is transported between client and service true, false

Default transport behavior

"transport": {
	"accept-connections": true,
	"throttle-service-response": 0,
	"delay-service-response": 0,
	"break-service-response": 0,
	"service-response-corrupt-method": "",
	"sending-to-client": true,
	"receiving-from-client": true,
	"sending-to-service": true,
	"receiving-from-service": true,
	"verbose": false
}

Build

go test
go build

Run

Usage

./zazkia  -h
2021/03/26 14:38:06 zazkia - tpc proxy for simulating network problems
Usage of ./zazkia:
  -f string
        route definition (default "zazkia-routes.json")
  -p int
        port on which the admin http server will listen (default 9191)
  -v    verbose logging

Defaults (-p 9191 -f zazkia-routes.json)

./zazkia

Dashboard

A simple HTML dashboard is available to change the transport behavior of individual links. See the Swagger tab for documentation of the REST API.

http://localhost:9191

Docker

A Docker image is available on Docker Hub.

Usage

docker run -d -p 9200-9300:9200-9300 -p 9191:9191 -v $(pwd):/data emicklei/zazkia

Zazkia will look for a file called zazkia-routes.json. The web UI will be running on http://localhost:9191 When using Docker, routes must use listener ports in the range 9200-9300 or 3306 (mysql) or 5432 (postgres) or 8080 (tomcat,jboss).

Examples

See the examples folder for simple usecase examples.

Build your own image

GOOS=linux go build && docker build -t emicklei/zazkia:latest .

© 2024, ernestmicklei.com. Apache v2 License. Contributions welcome.