goint

package module
v0.0.0-...-38be0f9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2016 License: Apache-2.0 Imports: 9 Imported by: 6

README

Integration testing in Go

goint is an integration testing framework written in Go. It was written for use in applications developed in Go. While the implementation of an integration test using the framework must be written in Go, much of the functionality can be used for applications written in other languages as well. Some of the functionality could be used in contexts other than integration testing (e.g., verifying deployments or health checks).

Features

goint implements several capabilities which can be called verbs. goint supports the following verbs:

  1. Exec - executes an arbitrary process. This can be anything that can be launched from a shell command line. One field in the Exec struct is Token which can be referenced in the Kill and Wait verbs.
  2. Kill - used to kill an Exec'd process. The process to be killed is identified by the Token field value in the corresponding Exec definition.
  3. Delay - does just that, it delays for a given amount of time and then continues
  4. Wait - waits for a process Exec'd with the matching Token value to exit
  5. Curl - will run an aribtrary curl request
  6. DelayHealthCheck - pings an arbitrary URL for a given number of times waiting a given number of sections between polls. It will complete with either an error or success.
  7. GoFunc - will run an arbitrary Go function.
  8. Comp - combines an arbitrary set of the above verbs into a composite action. Comp verbs can be nested to create arbitrarily complex hierarchies of arbitrarily complex steps.

Examples

See goint_test.go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TailReportOnError = stream{
		Report:   1,
		TailMode: true,
	}
	TailReportOn = stream{
		TailMode: true,
	}
	ReportOn = stream{}
)
View Source
var (
	Execs map[string]*Exec
)

Functions

func ReportNode

func ReportNode(dep int, name string, err error)

func ReportNodeSkipped

func ReportNodeSkipped(dep int, name string)

Types

type Comp

type Comp struct {
	// Name of this step
	Name       string // Name of the step. Documentation only
	Sequential bool   // The nodes in SubN should be done serially
	SubN       []Worker
	Err        error
}

Comp is a composite node. It groups multiple nodes together

func (*Comp) Go

func (w *Comp) Go(wg *sync.WaitGroup)

func (*Comp) Report

func (w *Comp) Report(dep int) error

func (*Comp) Start

func (w *Comp) Start()

type Curl

type Curl struct {
	Name          string // Name of the step. Documentation only
	URL           string
	PrintBodyFlag bool
	Resp          *http.Response
	Err           error
}

Curl is used to do an http request a la curl

func (*Curl) Go

func (w *Curl) Go(wg *sync.WaitGroup)

---------------- Curl Methods

func (*Curl) Report

func (w *Curl) Report(dep int) error

type Delay

type Delay struct {
	Name     string // Name of the step. Documentation only
	Duration time.Duration
	Err      error
}

These types are used to implement the integration test spec

func (*Delay) Go

func (w *Delay) Go(wg *sync.WaitGroup)

---------------- Delay Methods

func (*Delay) Report

func (w *Delay) Report(dep int) error

type DelayHealthCheck

type DelayHealthCheck struct {
	Name         string // Name of the step. Documentation only
	URL          string
	Resp         *http.Response
	PollInterval time.Duration
	NPolls       int
	Err          error
}

These types are used to implement the integration test spec

func (*DelayHealthCheck) Go

func (w *DelayHealthCheck) Go(wg *sync.WaitGroup)

---------------- DelayHealthCheck Methods

func (*DelayHealthCheck) Report

func (w *DelayHealthCheck) Report(dep int) error

type Exec

type Exec struct {
	Name       string // Name of the step. Documentation only
	Token      string
	Directory  string
	Precommand string
	Command    func() *exec.Cmd
	Args       []string
	Sequential bool // DEPRECATED, remove all references
	SubN       []Worker
	Cmd        *exec.Cmd
	Pid        int // Pid of process
	Err        error

	KilledExplicitly bool // Whether killed explicitly by Kill worker

	Stdout stream
	Stderr stream
	// contains filtered or unexported fields
}

These types are used to implement the integration test spec

func (*Exec) Go

func (w *Exec) Go(wg *sync.WaitGroup)

---------------- Exec Methods

func (*Exec) Report

func (w *Exec) Report(dep int) error

type GoFunc

type GoFunc struct {
	Name string    // Name of the step. Documentation only
	Func GoRoutine // Function to invoke
	Skip bool      // Flag to skip a test case, this will be reported SKIPPED in test report
	Err  error
}

GoFunc is used to embed

func (*GoFunc) Go

func (w *GoFunc) Go(wg *sync.WaitGroup)

---------------- GoFunc Methods

func (*GoFunc) Report

func (w *GoFunc) Report(dep int) error

type GoRoutine

type GoRoutine func(*GoFunc)

Type of functions in GoFunc

type Kill

type Kill struct {
	Name  string // Name of the step. Documentation only
	Token string
	Err   error
}

These types are used to implement the integration test spec

func (*Kill) Go

func (w *Kill) Go(wg *sync.WaitGroup)

----------- Kill Methods

func (*Kill) Report

func (w *Kill) Report(dep int) error

type Wait

type Wait struct {
	Name  string // Name of the step. Documentation only
	Token string
	Err   error
}

These types are used to implement the integration test spec

func (*Wait) Go

func (w *Wait) Go(wg *sync.WaitGroup)

func (*Wait) Report

func (w *Wait) Report(dep int) error

type Worker

type Worker interface {
	Report(int) error   // Prints Name and iterates over subnodes
	Go(*sync.WaitGroup) // Performs function of node
}

Worker interface is an interface that all nodes in the integration test spec must implement.

Jump to

Keyboard shortcuts

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