mockingjay-server

command module
v0.0.0-...-1dcaa55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2016 License: MIT Imports: 16 Imported by: 0

README

mockingjay server

Build StatusCoverage StatusGoDoc

Mockingjay lets you define the contract between a consumer and producer and with just a configuration file you get:

  • A fast to launch fake server for your integration tests
  • Configurable to simulate the eratic nature of calling other services
  • Consumer driven contracts (CDCs) to run against your real downstream services.

Mockingjay makes it really easy to check your integration points. It's fast, requires no coding and is better than other solutions because it will ensure your mock servers and real integration points are consistent

Running a fake server

---
 - name: My very important integration point
   request:
     uri: /hello
     method: POST
     body: "Chris" # * matches any body
   response:
     code: 200
     body: '{"message": "hello, Chris"}'   # * matches any body
     headers:
       content-type: application/json

# define as many as you need...
$ mockingjay-server -config=example.yaml -port=1234 &
2015/04/13 14:27:54 Serving 3 endpoints defined from example.yaml on port 1234
$ curl http://localhost:1234/hello
{"message": "hello, world"}

Check configuration is compatible with a real server

$ mockingjay-server -config=example.yaml -realURL=http://some-real-api.com
2015/04/13 21:06:06 Test endpoint (GET /hello) is incompatible with http://some-real-api - Couldn't reach real server
2015/04/13 21:06:06 Test endpoint 2 (DELETE /world) is incompatible with http://some-real-api - Couldn't reach real server
2015/04/13 21:06:06 Failing endpoint (POST /card) is incompatible with http://some-real-api - Couldn't reach real server
2015/04/13 21:06:06 At least one endpoint was incompatible with the real URL supplied
Inspect what requests mockingjay has received
 http://{mockingjayhost}:{port}/requests

Calling this will return you a JSON list of requests

Make your fake server flaky

Mockingjay has an annoying friend, a monkey. Given a monkey configuration you can make your fake service misbehave. This can be useful for performance tests where you want to simulate a more realistic scenario (i.e all integration points are painful).

---
# Writes a different body 50% of the time
- body: "This is wrong :( "
  frequency: 0.5

# Delays initial writing of response by a second 20% of the time
- delay: 1000
  frequency: 0.2

# Returns a 404 30% of the time
- status: 404
  frequency: 0.3

# Write 10,000,000 garbage bytes 9% of the time
- garbage: 10000000
  frequency: 0.09
$ mockingjay-server -config=examples/example.yaml -monkeyConfig=examples/monkey-business.yaml
2015/04/17 14:19:53 Serving 3 endpoints defined from examples/example.yaml on port 9090
2015/04/17 14:19:53 Monkey config loaded
2015/04/17 14:19:53 50% of the time | Body: This is wrong :(
2015/04/17 14:19:53 20% of the time | Delay: 1s
2015/04/17 14:19:53 30% of the time | Status: 404
2015/04/17 14:19:53  9% of the time | Garbage bytes: 10000000

Building

Requirements
$ go get github.com/quii/mockingjay-server
$ cd $GOPATH/src/github.com/quii/mockingjay-server
$ ./build.sh

MIT license

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/clbanning/mxj
Marshal/Unmarshal XML to/from JSON and map[string]interface{} values, and extract/modify values from maps by key or key-path, including wildcards.
Marshal/Unmarshal XML to/from JSON and map[string]interface{} values, and extract/modify values from maps by key or key-path, including wildcards.
_workspace/src/github.com/clbanning/mxj/j2x
j2x.go - For (mostly) backwards compatibility with legacy j2x package.
j2x.go - For (mostly) backwards compatibility with legacy j2x package.
_workspace/src/github.com/clbanning/mxj/x2j
x2j - For (mostly) backwards compatibility with legacy x2j package.
x2j - For (mostly) backwards compatibility with legacy x2j package.
_workspace/src/github.com/fatih/structs
Package structs contains various utilities functions to work with structs.
Package structs contains various utilities functions to work with structs.
_workspace/src/github.com/johnmuth/xmlcompare
Package xmlcompare provides functions for comparing bits of XML.
Package xmlcompare provides functions for comparing bits of XML.
_workspace/src/github.com/quii/jsonequaliser
Package jsonequaliser tries to determine if two JSON strings (A and B) are compatible with each other in terms of having the same fields matched to the same types.
Package jsonequaliser tries to determine if two JSON strings (A and B) are compatible with each other in terms of having the same fields matched to the same types.
_workspace/src/gopkg.in/yaml.v2
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.
Package mockingjay allows you to create a HTTP server to return canned responses for certain requests.
Package mockingjay allows you to create a HTTP server to return canned responses for certain requests.
Package monkey lets you wrap bad behaviour around your http.Handlers, such as request delays, incorrect responses, bodies and returning garbage from configuration.
Package monkey lets you wrap bad behaviour around your http.Handlers, such as request delays, incorrect responses, bodies and returning garbage from configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL