tester

package module
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 8 Imported by: 0

README

grpc-tester

grpc-tester is a simple command-line tool cum library for testing gRPC services.

This tool leverage grpcurl to create dynamic requests and jq for comparing/validating responses.

NOTE: currently doesn't work on windows cmd/powershell.

DOCUMENTATION is work in progress, have a look at examples/ to get overview of tool usage!

Install From Source
go install github.com/shivuslr41/grpc-tester/cmd/grpc-tester@v0.1.0-beta

Usage

$ grpc-tester --help

FORMAT:
        ./tester [COMMAND] [FLAGS]

EXAMPLE:
        ./tester list --server mygrpcserver:443 --tls

COMMANDS:
        gen             generates sample json.
        list            list services and methods.
        run             run requests provided in json.
        test            test responses againt expectation set.

Usage of ./grpc-tester:
  -d, --data string            request in json format - '{"name":"Bob"}'
  -e, --endpoint string        service and method to call
  -g, --grpcurl-flags string   pass additional grpcurl flags - '-H "Authorization: <TOKEN>"'
  -h, --help                   shows tool usage
  -j, --json string            json file containing test scopes
  -f, --proto-file string      proto file
  -p, --proto-path string      proto path, if server doesn't support grpc reflection
  -s, --server string          gRPC server address
  -m, --stream-payload         send multiple messages to server
  -t, --tls                    use tls connection

Examples

gen

This generates json format file, add scopes and pass it to grpc-tester run/test commands.

grpc-tester gen 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(endpoints []Endpoint)

func Generate

func Generate()

Types

type Endpoint

type Endpoint struct {
	Runner
	Tests []T `json:"tests"`
}

type Lister

type Lister struct {
	Server    string `json:"server"`
	ProtoPath string `json:"proto_path"`
	ProtoFile string `json:"proto_file"`
	TLS       bool   `json:"tls"`
}

func (*Lister) Execute

func (l *Lister) Execute()

func (*Lister) List

func (l *Lister) List() (map[string][]string, error)

type Runner

type Runner struct {
	Lister
	Endpoint      string        `json:"endpoint"`
	Data          []interface{} `json:"-"`
	GrpcurlFlags  string        `json:"-"`
	StreamPayload bool          `json:"stream_payload"`
	// contains filtered or unexported fields
}

func (*Runner) Execute

func (r *Runner) Execute()

func (*Runner) Run

func (r *Runner) Run(reader func(io.ReadCloser) error) error

type T

type T struct {
	ID           string        `json:"id"`
	Description  string        `json:"description"`
	Request      []interface{} `json:"request"`
	Queries      []string      `json:"queries"`
	Compare      bool          `json:"compare"`
	Expectations []interface{} `json:"expectation"`
	Skip         bool          `json:"skip"`
	Response     []interface{} `json:"-"`
	Print        bool          `json:"print"`
	GrpcurlFlags string        `json:"grpcurl_flags"`
	IgnoreOrder  bool          `json:"ignore_order"`
	Pass         bool          `json:"-"`
}

func (*T) Test

func (t *T) Test(r Runner) error

Directories

Path Synopsis
cmd
grpc-tester command
examples
greeter/server command

Jump to

Keyboard shortcuts

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