tests

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ListenPort             = 8000
	IpV6Localhost          = "::1"
	ServerTimeout          = 3 * time.Second
	CertFile               = "utils/localhost.crt"
	KeyFile                = "utils/localhost.key"
	ServerPath             = "tlsserver/tlsserver" // The test could also build the server
	SockAddr               = "/tmp/comm.sock"
	ReadyString            = "ServerIsReady :)"
	CommunicationSeparator = "\n,,,,\n"

	ReqDelayAddition = 3 * time.Millisecond
	BaseDuration     = 300 * time.Millisecond
	BaseReqDelay     = 20 * time.Millisecond
	FailRequestEvery = 4

	TlsHandshakeTraceName = "TlsHandshakeDone"
	FirstByteTraceName    = "FirstByte"
	ReadingBodyTraceName  = "ReadingBody"
	NonSeededRequest      = "PreSeeded"
)
View Source
const NumberOfTasksToFinish = 2 /* If these two tasks doesn't finish with a reasonable time- we declare test timeout
a. The http bench process
b. The result channel is closed
*/

Variables

View Source
var (
	DummySleepTraceSummary = GenerateTestTraceSummary(100 * time.Millisecond)
	FailInRow              = []int64{1, 3} // Not relevant if response fail type is Http200
)

Functions

func GenerateResponse

func GenerateResponse(code int, body string, headers map[string][]string) []byte

func GenerateTestTraceSummary

func GenerateTestTraceSummary(sleepDuration time.Duration) *engine.TraceSummary

func GetRequest

func GetRequest(url string) func(string) (*http.Request, error)

func GetTlsServerAddress

func GetTlsServerAddress() string

func GetTlsServerUrl

func GetTlsServerUrl() string

func IsValueInRange

func IsValueInRange(baseVal, refVal interface{}) error

func RunLocalServer

func RunLocalServer(f func(w http.ResponseWriter, r *http.Request)) *httptest.Server

func RunTest

func RunTest(t *testing.T, p *httpbench.Preset, benchConfig BenchConfig, f func() *httpbench.PresetResult)

func WrapTestTimeout

func WrapTestTimeout(bench BenchConfig, finish <-chan bool) error

Types

type BenchConfig

type BenchConfig struct {
	MaxConcurrentLimit uint64                    `json: MaxConcurrentLimit`
	SyncedConcurrent   uint64                    `json: SyncedConcurrent`
	MaxRequests        uint64                    `json: MaxRequests`
	FailsEveryReq      uint64                    `json: FailsEveryReq`
	FailsInRow         uint64                    `json: FailsInRow`
	ReqDelay           time.Duration             `json: ReqDelay`
	Duration           time.Duration             `json: Duration`
	DummyTraceSummary  *engine.TraceSummary      `json: DummyTraceSummary`
	WaitHook           syncedtrace.TraceHookType `json: WaitHook`
	FailType           HttpResponseType          `json: FailType`
	Type               HttpBenchType             `json: Type`
	HitsGraph          httpbench.HitsGraph       `json: HitsGraph`
}

func GenerateBenchConfigs

func GenerateBenchConfigs(inputBenches []BenchConfig, inputValues [][]int64) []BenchConfig

func (*BenchConfig) SetPermutation

func (bench *BenchConfig) SetPermutation(permutation []int64)

type CombinedTestResult

type CombinedTestResult struct {
	TraceResults  *engine.TraceResult  `json:"bench_result"`
	ServerResults *ServerRequestResult `json:"server_result"`
}

type CombinedTestResults

type CombinedTestResults struct {
	TraceResults  map[string]*engine.TraceResult
	ServerResults map[string]*ServerRequestResult
}

func NewTestResults

func NewTestResults() *CombinedTestResults

type HttpBenchType

type HttpBenchType int
const (
	PerDuration HttpBenchType = iota
	Synced
	SyncedOnce
	UnSynced
	Graph
)

type HttpResponseType

type HttpResponseType int
const (
	Http200 HttpResponseType = iota
	//Http300 // No supported for now. raises panic
	Http400
	Http500
	HttpRand
)

func (HttpResponseType) Get

func (ht HttpResponseType) Get() []byte

Used httpstat.us for errors

type ServerRequestResult

type ServerRequestResult struct {
	Hooks              map[syncedtrace.TraceHookType]*syncedtrace.Hook `json:"hooks"`
	UniqueId           string                                          `json:"unique_id"`
	EndTime            time.Time                                       `json:"start_time"`
	BeforeRead         time.Time                                       `json:"waited_for_hook"`
	AggregatedDuration time.Duration                                   `json:"aggregated_duration"`
	Err                string                                          `json:"error"`
}

type SockIpc

type SockIpc struct {
	Closed bool
	// contains filtered or unexported fields
}

func (*SockIpc) Close

func (sock *SockIpc) Close()

func (*SockIpc) Connect

func (sock *SockIpc) Connect() error

func (*SockIpc) HandleConnection

func (sock *SockIpc) HandleConnection(conn net.Conn, f func(data []byte))

func (*SockIpc) ListenAndServe

func (sock *SockIpc) ListenAndServe(writeOnAccept []byte, recvFunc func(data []byte))

func (*SockIpc) ReadConfig

func (sock *SockIpc) ReadConfig() []byte

func (*SockIpc) SendData

func (sock *SockIpc) SendData(data []byte)

type TestResults

type TestResults struct {
	T            *testing.T
	Bench        *BenchConfig
	TestResults  *CombinedTestResults
	PresetResult *httpbench.PresetResult
	// contains filtered or unexported fields
}

func (*TestResults) SetupAndRunServer

func (tr *TestResults) SetupAndRunServer(ServReadyChan chan error) (*TlsServerCmd, error)

func (*TestResults) VerifyServerResults

func (tr *TestResults) VerifyServerResults()

func (*TestResults) WaitForAllResults

func (tr *TestResults) WaitForAllResults() (int, int, bool)

type TlsServerCmd

type TlsServerCmd struct {
	Cmd *exec.Cmd

	StdoutPipe io.ReadCloser
	StderrPipe io.ReadCloser
	// contains filtered or unexported fields
}

func (*TlsServerCmd) Done

func (s *TlsServerCmd) Done() <-chan struct{}

func (*TlsServerCmd) Stop

func (s *TlsServerCmd) Stop()

Jump to

Keyboard shortcuts

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