kubernetes: github.com/erimatnor/kubernetes/pkg/client/chaosclient Index | Files

package chaosclient

import "github.com/erimatnor/kubernetes/pkg/client/chaosclient"

Package chaosclient makes it easy to simulate network latency, misbehaving servers, and random errors from servers. It is intended to stress test components under failure conditions and expose weaknesses in the error handling logic of the codebase.


Package Files



var ErrSimulatedConnectionResetByPeer = Error{errors.New("connection reset by peer")}

ErrSimulatedConnectionResetByPeer emulates the golang net error when a connection is reset by a peer. TODO: make this more accurate TODO: add other error types TODO: add a helper for returning multiple errors randomly.

var LogChaos = ChaosNotifier(logChaos{})

LogChaos is the default ChaosNotifier and writes a message to the Golang log.

func NewChaosRoundTripper Uses

func NewChaosRoundTripper(rt http.RoundTripper, notify ChaosNotifier, c ...Chaos) http.RoundTripper

NewChaosRoundTripper creates an http.RoundTripper that will intercept requests based on the provided Chaos functions. The notifier is invoked when a Chaos Intercept is fired.

type Chaos Uses

type Chaos interface {
    // Intercept should return true if the normal flow should be skipped, and the
    // return response and error used instead. Modifications to the request will
    // be ignored, but may be used to make decisions about types of failures.
    Intercept(req *http.Request) (bool, *http.Response, error)

Chaos intercepts requests to a remote HTTP endpoint and can inject arbitrary failures.

type ChaosFunc Uses

type ChaosFunc func(req *http.Request) (bool, *http.Response, error)

ChaosFunc takes an http.Request and decides whether to alter the response. It returns true if it wishes to mutate the response, with a http.Response or error.

func (ChaosFunc) Intercept Uses

func (fn ChaosFunc) Intercept(req *http.Request) (bool, *http.Response, error)

func (ChaosFunc) String Uses

func (fn ChaosFunc) String() string

type ChaosNotifier Uses

type ChaosNotifier interface {
    // OnChaos is invoked when a chaotic outcome was triggered. fn is the
    // source of Chaos and req was the outgoing request
    OnChaos(req *http.Request, c Chaos)

ChaosNotifier notifies another component that the ChaosRoundTripper has simulated a failure.

type Error Uses

type Error struct {
    // contains filtered or unexported fields

Error returns the nested error when C() is invoked.

func (Error) Intercept Uses

func (e Error) Intercept(_ *http.Request) (bool, *http.Response, error)

C returns the nested error

type Seed Uses

type Seed struct {

Seed represents a consistent stream of chaos.

func NewSeed Uses

func NewSeed(seed int64) Seed

NewSeed creates an object that assists in generating random chaotic events based on a deterministic seed.

func (Seed) P Uses

func (s Seed) P(p float64, c Chaos) Chaos

P returns a ChaosFunc that fires with a probabilty of p (p between 0.0 and 1.0 with 0.0 meaning never and 1.0 meaning always).

Package chaosclient imports 7 packages (graph). Updated 2017-05-11. Refresh now. Tools for package owners.