immune

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MPL-2.0 Imports: 6 Imported by: 0

README

Immune - Testing Tool

Immune a testing tool, that will be used to load test convoy's api, and possibly other APIs.

Problem

As of today, there is no comprehensive test suite for convoy, to ensure its stability in a production environment. As such we are unable to ensure the durability of convoy under reasonable load beforehand.

Structure

Given how convoy works, the proper way to do testing would be to simulate the entire flow that a user would go through. An example:

♟️ user_api → convoy → various_endpoints

This goal of immune is to simulate it in this manner:

♟️ immune → convoy → immune_callback

Immune will send events to convoy and expect those events to come through to its callback endpoint. This does not mean it will wait indefinitely, immune will have its own deadline, any callbacks that did not come through before the deadline is hit, will be reported.

Documentation

Index

Constants

View Source
const CallbackIDFieldName = "immune_callback_id"

Variables

View Source
var (
	ErrFieldNotFoundInResponse = errors.New("field not found in response")
)

Functions

func InjectCallbackID

func InjectCallbackID(field string, value interface{}, r M) error

InjectCallbackID injects a callback id into field(expected to be a map[string]interface{} in r) in r, using CallbackIDFieldName as the key and value as the value.

Types

type Callback

type Callback struct {
	Enabled bool `json:"enabled"`
	Times   uint `json:"times"`
}

type CallbackConfiguration

type CallbackConfiguration struct {
	MaxWaitSeconds uint   `json:"max_wait_seconds"`
	Port           uint   `json:"port"`
	Route          string `json:"route"`
	SSL            bool   `json:"ssl" envconfig:"IMMUNE_SSL"`
	SSLKeyFile     string `json:"ssl_key_file" envconfig:"IMMUNE_SSL_KEY_FILE"`
	SSLCertFile    string `json:"ssl_cert_file" envconfig:"IMMUNE_SSL_CERT_FILE"`
	IDLocation     string `json:"id_location"`
}

type CallbackServer

type CallbackServer interface {
	ReceiveCallback(rc chan<- *Signal)
	Start(ctx context.Context) error
	Stop()
}

type Database

type Database struct {
	Type string `json:"type"`
	Dsn  string `json:"dsn"`
}

type M

type M map[string]interface{}

type Method

type Method string
const (
	MethodPost    Method = "POST"
	MethodPUT     Method = "PUT"
	MethodGet     Method = "GET"
	MethodPatch   Method = "PATCH"
	MethodHead    Method = "HEAD"
	MethodDelete  Method = "DELETE"
	MethodConnect Method = "CONNECT"
	MethodOptions Method = "OPTIONS"
	MethodTrace   Method = "TRACE"
)

func (Method) IsValid

func (m Method) IsValid() bool

func (Method) String

func (m Method) String() string

func (*Method) UnmarshalJSON

func (m *Method) UnmarshalJSON(b []byte) error

type S

type S map[string]string

type SetupTestCase

type SetupTestCase struct {
	Name                   string `json:"name"`
	StoreResponseVariables S      `json:"store_response_variables"`
	RequestBody            M      `json:"request_body"`
	ResponseBody           bool   `json:"response_body"`
	Endpoint               string `json:"endpoint"`
	HTTPMethod             Method `json:"http_method"`
	StatusCode             int    `json:"status_code"`
}

type SetupTestCaseReport

type SetupTestCaseReport struct {
	WantsResponseBody bool
	HasResponseBody   bool
}

type Signal

type Signal struct {
	// ImmuneCallBackID collects the callback id from the request body, it's json tag
	// must always match immune.CallbackIDFieldName
	ImmuneCallBackID string `json:"immune_callback_id"`

	Err error
}

A Signal represents a single callback

func (*Signal) Error added in v0.2.0

func (s *Signal) Error() string

func (*Signal) HasError added in v0.2.0

func (s *Signal) HasError() bool

type TestCase

type TestCase struct {
	Name         string   `json:"name"`
	Setup        []string `json:"setup"`
	StatusCode   int      `json:"status_code"`
	HTTPMethod   Method   `json:"http_method"`
	Endpoint     string   `json:"endpoint"`
	ResponseBody bool     `json:"response_body"`
	Callback     Callback `json:"callback"`
	RequestBody  M        `json:"request_body"`
}

type VariableMap

type VariableMap struct {
	VariableToValue M
}

func NewVariableMap

func NewVariableMap() *VariableMap

func (*VariableMap) Get

func (v *VariableMap) Get(key string) (interface{}, bool)

Get gets the value of key from the variable map

func (*VariableMap) GetString

func (v *VariableMap) GetString(key string) (string, bool)

GetString gets the value of key from the variable map, if the value isn't of the string type, it will be converted to string via fmt.Sprintf and returned

func (*VariableMap) ProcessResponse

func (v *VariableMap) ProcessResponse(ctx context.Context, variableToField S, values M) error

ProcessResponse takes the variables declared in variableToField from values, and stores them in the variable map.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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