grpc

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: BSD-3-Clause Imports: 18 Imported by: 0

README

Venom - Executor Grpc

Step for execute GRPC Request

Based on grpcurl, see grpcurl for more information. This executor relies on the gRPC server reflection, which should be enabled on the server as described here. gRPC server reflection is not enabled by default and not implemented for every gRPC library, make sure your library of choice supports reflection before implementing tests using this executor. gRPC server reflection also does not properly work with gogo/protobuf: grpc/grpc-go#1873

Tests

Results of test are parsed as json and saved in bodyjson. Status codes correspond to the official status codes of gRPC. You can find what individual return codes mean here.

Input

In your yaml file, you can use:

  - url mandatory
  - service mandatory: service to call
  - method mandatory: list, describe, or method of the endpoint
  - plaintext optional: use plaintext protocol instead of TLS
  - data optional: data to marshal to json and send as a request
  - headers optional: data to send as additional headers
  - connect_timeout optional: The maximum time, in seconds, to wait for connection to be established. Defaults to 10 seconds.
  - default_fields optional: whether json formatter should emit default fields
  - include_text_separator optional: when protobuf string formatter is invoked to format multiple messages, all messages after the first one will be prefixed with character (0x1E).

Example:


name: Title of TestSuite
testcases:

- name: request GRPC
  steps:
  - type: grpc
    url: serverUrlWithoutHttp:8090
    plaintext: true # skip TLS
    data:
      foo: bar
    service: coolService.api
    method: GetAllFoos
    assertions:
    - result.code ShouldEqual 0
    - result.bodyjson.foo ShouldEqual bar

Output

executor
systemout
systemerr
err
code
timeseconds
timehuman
  • result.timeseconds & result.timehuman: time of execution
  • result.executor.executor.script: script executed
  • result.err: if exists, this field contains error
  • result.systemout: Standard Output of executed script
  • result.systemerr: Error Output of executed script
  • result.code: Exit Code

Documentation

Index

Constants

View Source
const Name = "grpc"

Name for test exec

Variables

This section is empty.

Functions

func New

func New() venom.Executor

New returns a new Test Exec

Types

type Executor

type Executor struct {
	Url                  string                 `json:"url" yaml:"url"`
	Service              string                 `json:"service" yaml:"service"`
	Method               string                 `json:"method" yaml:"method"`
	Plaintext            bool                   `json:"plaintext,omitempty" yaml:"plaintext,omitempty"`
	JsonDefaultFields    bool                   `json:"default_fields" yaml:"default_fields"`
	IncludeTextSeparator bool                   `json:"include_text_separator" yaml:"include_text_separator"`
	Data                 map[string]interface{} `json:"data" yaml:"data"`
	Headers              map[string]string      `json:"headers" yaml:"headers"`
	ConnectTimeout       *int64                 `json:"connect_timeout" yaml:"connect_timeout"`
}

Executor represents a Test Exec

func (Executor) GetDefaultAssertions

func (Executor) GetDefaultAssertions() *venom.StepAssertions

GetDefaultAssertions return default assertions for type exec

func (Executor) Run

func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step venom.TestStep, workdir string) (venom.ExecutorResult, error)

Run execute TestStep of type exec

func (Executor) ZeroValueResult

func (Executor) ZeroValueResult() venom.ExecutorResult

ZeroValueResult return an empty implemtation of this executor result

type Result

type Result struct {
	Executor      Executor    `json:"executor,omitempty" yaml:"executor,omitempty"`
	Systemout     string      `json:"systemout,omitempty" yaml:"systemout,omitempty"`
	SystemoutJSON interface{} `json:"systemoutjson,omitempty" yaml:"systemoutjson,omitempty"`
	Systemerr     string      `json:"systemerr,omitempty" yaml:"systemerr,omitempty"`
	SystemerrJSON interface{} `json:"systemerrjson,omitempty" yaml:"systemerrjson,omitempty"`
	Err           string      `json:"err,omitempty" yaml:"err,omitempty"`
	Code          string      `json:"code,omitempty" yaml:"code,omitempty"`
	TimeSeconds   float64     `json:"timeseconds,omitempty" yaml:"timeseconds,omitempty"`
	TimeHuman     string      `json:"timehuman,omitempty" yaml:"timehuman,omitempty"`
}

Result represents a step result

Jump to

Keyboard shortcuts

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