badnet

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

badnet

badnet is a lightweight TCP proxy that sits in the middle of your tests and what they're trying to connect to. badnet sits outside of your application or tests to help simulate real network failures without modifying application code.

  1. Setup a proxy
  2. Connect your application
  3. Run typical tests

Future Ideas

  • Add channel / helpers to modify proxy behavior in the middle of an integration test

Related

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Listen, Target string

	Read  Direction
	Write Direction
}

type Direction

type Direction struct {
	MaxKBps      int // set 0 for unlimited
	Latency      time.Duration
	FailureRatio int
}

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

func ForTest

func ForTest(t *testing.T, conf Config) *Proxy

func (*Proxy) BindAddr

func (p *Proxy) BindAddr() string

func (*Proxy) FailureRatio added in v0.3.0

func (p *Proxy) FailureRatio() float64

FailureRatio is a ratio of the injected failures and failures to connect with the target against the overall number of connections made to the proxy.

func (*Proxy) Port added in v0.1.1

func (p *Proxy) Port() int

Jump to

Keyboard shortcuts

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