Skip to content
/ gaos Public

HTTP mocking to test API services for chaos scenarios

License

Notifications You must be signed in to change notification settings

Trendyol/gaos

Repository files navigation

GAOS

HTTP mocking to test API services for chaos scenarios

Apache 2.0 Go Report Build Status GitHub release


Gaos, can create and provide custom mock restful services via using your fully-customizable scenarios and runs them on Docker & Kubernetes & localhost flawlessly.

Warning: Currently in Beta.

asciicast

Features

  • API response mocking
  • Custom behaviour scenarios
  • Create custom actions for each scenario
  • Robust routing
  • Serve static & dynamic responses
  • Duration, Latency, Error scenarios
  • Deploy your services on Docker & K8S
  • ... and much more, explore the Gaos!

Installation

  • Via HomeBrew
$ brew tap trendyol/trendyol-tap
$ brew install gaos
  • Via Go
$ go get -u github.com/Trendyol/gaos 
  • Build on Docker
$ make build

Scenarios

Scenario Explanation
latency Adds extra latency for request
duration Adds duration limit for request
span Executes accept if in the specified time range, ignore otherwise.
rate Executes ignore if reaches the value or on multiples of, accept otherwise.

Actions

Action Explanation
accept Execute if span and rate conditions doesn't match in the specified scenario
ignore Execute if span and rate conditions does match in the specified scenario
direct Specifies which scenario should be handled by next request
result Specifies Result Type that will be return eventually
status Specifies Status Code for given Result Type

Results

Result Explanation
type Result Type of the content
content Definitions the relevant result's content, according to Result Type

Result Type

Result Type Explanation
static Returns json content
file Returns content.type after reading the file in content.path
redirect Sends request to remote content.host and awaits response (reverse proxy)

Usage

Usage:
  gaos [command]

Available Commands:
  help        Help about any command
  run         Run Gaos server on localhost
  start       Start Gaos server on given engine (Docker, K8S)

Flags:
  -h, --help   help for gaos

Run Command

Run Gaos server on your localhost

Usage:
  gaos run [flags]

Flags:
  -x, --execute string    execute scenario services
  -s, --scenario string   scenario file input (default "./scenario.json")

Example:

$ gaos run -s ./examples/example.json

After Gaos server started:

$ go run ./examples/example.go

Start Command

Start Gaos server on given engine (Docker, K8S)

Usage:
  gaos start [flags]

Flags:
  -c, --config string        choose k8s config (default "minikube")
      --cpu string           cpu limit (default "500m")
  -e, --environment string   gaos running environment {docker, k8s} (default "local")
	  --memory string        memory limit (default "500mi")
  -n, --namespace string     choose namespace (default "default")
  -p, --password string      image registry password
  -r, --registry string      image registry
	  --replica string       replica count (default "1")
  -s, --scenario string      scenario file input (default "./scenario.json")
	  --secret string        secret key name
  -t, --timeout string       client timeout (default "5m")
  -u, --username string      image registry username
  • Example: Docker
$ gaos start -e docker -s './examples/example.json'
  • Example: Kubernetes
$ gaos start -e k8s -s './examples/example.json'

Running Tests

Requirements:

$ bats e2e.bats

Known Issues

  • Lack of some unit tests
  • E2E tests are not running on pipeline yet. (Manually: bats e2e.bats)
  • Not tested in Windows yet

TO-DO

  • Add ./docs folder for better documentation
  • Scenario linter - to check rules, keys and paths
  • Remote server config reader
  • API client
  • Envoy support - sidecar feature
  • Consul support - service mesh feature

License

The base project code is licensed under Apache License unless otherwise specified. Please see the LICENSE file for more information.

GAOS