gubrak

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2019 License: Apache-2.0 Imports: 13 Imported by: 1

README

Gubrak

an experimental Command Line performance testing tool for your services. What this means, this tool will run concurrently againts your service.

Gubrak Gopher

TODO

  • Better code
  • Writing test
  • Better output

Usage

  • Install from Homebrew
$ brew install Bhinneka/tool/gubrak
  • Install binary from source
$ go get github.com/Bhinneka/gubrak

$ go install github.com/Bhinneka/gubrak/cmd/gubrak

$ gubrak --version
Send JSON payload

create config.json file with signature like this for "Content-Type" : application/json:

{
    "url": "http://example.com",
    "headers": {
        "Authorization": "Basic exnfekeoeoeojsjalaljahhd",
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
	"payload": {
		"from": "Bob",
		"content": {
			"header": "This is Message 3",
			"body": "Hello There"
		}
	}
}
Send form-urlencoded payload

create config.json file with signature like this for "Content-Type": "application/x-www-form-urlencoded":

{
    "url": "http://example.com",
    "headers": {
        "Authorization": "Basic exnfekeoeoeojsjalaljahhd",
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
	"payload": "from=Bob&content=hello from bob"
}
  • run gubrak
$ gubrak -m get -c /Users/wurianto/Documents/config.json -u https://jsonplaceholder.typicode.com/posts -r 100

Send 100 Concurrent HTTP Request

List flag and arguments

  • -m | --method (default GET) HTTP method, example -m POST or -m post
  • -r (default 10) Size of Concurrent request, example -r 1000
  • -c | --config config.json (default config.json) location, example -c /Users/wurianto/Documents/config.json
  • -u | --url URL full with path (default in config.json), example -u https://jsonplaceholder.typicode.com/posts
  • -v | --version show gubrak version, example gubrak -v
  • -h | --help show Help, example ./gubrak -h

Documentation

Index

Constants

View Source
const (
	// DefaultRequestNum total default concurrent request
	DefaultRequestNum uint64 = 10
	// Version for -v options
	Version = "zero"
)

Variables

View Source
var (
	// ErrorConfigNotFound for error config file not found
	ErrorConfigNotFound = errors.New("--config file not found--")

	// ErrorFormatConfigNotValid for invalid format config error
	ErrorFormatConfigNotValid = errors.New("--format config is not valid--")
)

Functions

func Consume

func Consume(id uint64, jobs <-chan Output, results chan<- Output)

Consume func will consume the result from Output from Scan function. This function only consume the channel results

func Scan

func Scan(jobs chan<- Output,
	client *Client,
	method string,
	path string,
	payload interface{},
	headers map[string]string,
	requestSize uint64)

Scan func will doing the HTTP call to defined request url within the request body if exists

Types

type Argument

type Argument struct {
	Method      string
	Config      string
	URL         string
	RequestNum  uint64
	ShowVersion bool
	Help        func()
}

Argument struct

func ParseArgument

func ParseArgument() (*Argument, error)

ParseArgument for parse argument to Argument

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client http client wrapper

func NewClient

func NewClient(timeout time.Duration) *Client

NewClient function for intialize Client object Paramter, timeout in time.Duration

type Config

type Config struct {
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
	Payload interface{}       `json:"payload"`
}

Config struct

func LoadConfig

func LoadConfig(source string) (*Config, error)

LoadConfig for load config from json file

type Gubrak

type Gubrak struct {
	// contains filtered or unexported fields
}

Gubrak struct

func New

func New(timeout time.Duration, args *Argument) (*Gubrak, error)

New Gubrak

func (*Gubrak) Run

func (g *Gubrak) Run()

Run method

type Output

type Output struct {
	Trace *Trace
	Error error
}

Output struct for Scan returns

type Result

type Result struct {
	TotalSuccess uint64
	TotalFail    uint64
}

Result struct

type Trace

type Trace struct {
	HTTPResponse  *http.Response
	Duration      time.Duration
	ConnDuration  time.Duration // connection setup(DNS lookup + Dial up) duration
	DNSDuration   time.Duration // dns lookup duration
	ReqDuration   time.Duration // request "write" duration
	ResDuration   time.Duration // response "read" duration
	DelayDuration time.Duration // delay between response and request

}

Trace represent the struct of tracing data

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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