• Stars
    star
    561
  • Rank 79,380 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fake server, Consumer Driven Contracts and help with testing performance from one configuration file with zero system dependencies and no coding whatsoever

mockingjay server

Build StatusCoverage StatusGoDoc

mj example

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 HTTP 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 so that you never have a green build but failing software.

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

This ensures your integration test is working against a reliable fake.

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

Build application

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

MIT license

More Repositories

1

learn-go-with-tests

Learn Go with test-driven development
Go
21,957
star
2

todo

spiking out a todo list with htmx
Go
208
star
3

go-graceful-shutdown

Go
31
star
4

testing-gorillas

Go
24
star
5

go-http-reference-impl

Go
22
star
6

monolith-to-micro

Go
12
star
7

learn-ts-react-with-tests

TypeScript
11
star
8

ci-league

Go
9
star
9

docker-crash-course

Dockerfile
8
star
10

learn-clojure-with-tests

Clojure
8
star
11

mockingjay-server-two

Go
6
star
12

learn-python-with-tests

Python
6
star
13

leadership-ci

Go
6
star
14

quickcheck-example

Go
6
star
15

enterprise-temp-converter

Go
5
star
16

go-specs-greet

Go
5
star
17

learn-kotlin-with-tests

Kotlin
4
star
18

tdd-a-twitter

JavaScript
4
star
19

CoffeeScript-snippets

Lots of small code snippets to introduce basic constructs in CS.
CoffeeScript
4
star
20

learning-clojure

Clojure
3
star
21

dotfiles

Vim Script
3
star
22

jsonequaliser

Go
3
star
23

goland-templates

3
star
24

go-book

Go
3
star
25

over-poker

Scala
3
star
26

go-mod-example

Go
3
star
27

good-handlers

Go
2
star
28

scalatra-slick

A short example of using Slick with Scalatra with an in memory h2 database
Shell
2
star
29

go-embed-example

Go
2
star
30

learn-hyperscript-with-tests

JavaScript
2
star
31

v60

Go
2
star
32

learn-es

Go
2
star
33

learning-kotlin

Kotlin
2
star
34

vue-fast

JavaScript
2
star
35

go-cucumber

Go
1
star
36

everything-is-ok

JavaScript
1
star
37

silly-content-hub

Go
1
star
38

clock

Adds some basic arithmetic for clock based things in Golang
Go
1
star
39

akka-spray-neo-fun

Just messing around with akka, spray and neo4j
Scala
1
star
40

helloKobalt

Kotlin
1
star
41

wire-example

Go
1
star
42

SpringerLite

Using CoffeeScript and the Springer API to make a simple, fast search of Springer's database
JavaScript
1
star
43

testcase-playground

Go
1
star
44

Coffeescript-Euler-solutions

Trying to solve as many Euler problems as I can in Coffeescript
CoffeeScript
1
star
45

ruby-sinatra-capybara-boilerplate

Ruby
1
star
46

try-grpc

Go
1
star
47

donkey-decider

Go
1
star
48

word-converter-api

JavaScript
1
star
49

mums-the-word

Go
1
star
50

code-review-report

Go
1
star
51

Springer-Research

Using web sockets to help users research Springer's content in a more social way
CoffeeScript
1
star
52

property-based-tests

TypeScript
1
star