gomparator

command module
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: MIT Imports: 18 Imported by: 0

README

gomparator

gomparator compares HTTP GET JSON responses from different hosts by checking if they respond with the same json (deep equal ignoring order) and status code.

Download and install

go get -u github.com/emacampolo/gomparator

Create a file with relative URL

eg:

/v1/payment_methods?client.id=1
/v1/payment_methods?client.id=2
/v1/payment_methods?client.id=3

Run

$ gomparator --path "/path/to/file/with/urls" --host "http://host1.com" --host "http://host2.com" -H "X-Auth-Token: abc"

By Default, it will use 1 worker, and the rate limit will be 5 req/s

Options

--help, -h

Shows a list of commands or help for one command

--version, -v

Print the version

--path value

Specifies the file from which to read targets. It should contain one column only with a rel path. eg: /v1/cards?query=123

--host value

Targeted hosts. Exactly 2 hosts must be specified. eg: --host 'http://host1.com --host 'http://host2.com'

--header value, -H value

Headers to be used in the http call

--ratelimit value, -r value

Operation rate limit per second (default: 5)

--workers value, -w value

Number of workers running concurrently (default: 1)

--status-code-only

Whether it only compares status code ignoring response body

--timeout value

Request timeout (default: 30s)

--duration value, -d value

Duration of the comparison [0 = forever] (default: 0s)

--exclude value

Excludes a value from both json for the specified path. A path is a series of keys separated by a dot or #.

Path syntax

Given the following json input:

{
  "name": {"first": "Tom", "last": "Anderson"},
  "friends": [
	{"first": "James", "last": "Murphy"},
	{"first": "Roger", "last": "Craig"}
  ]
}
pathoutput
"name.friends"

{
    "name": {"first": "Tom", "last": "Anderson"}
}

"friends.#.last"

{
    "name": {"first": "Tom", "last": "Anderson"},
    "friends": [
        {"first": "James"},
        {"first": "Roger"}
    ]
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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