runner

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 62 Imported by: 1

Documentation

Overview

Package runner responsible for excute the test case

Package runner provides the common expr style functions

Index

Constants

This section is empty.

Variables

View Source
var RunnersNum = promauto.NewGauge(prometheus.GaugeOpts{
	Name: "atest_runners_count",
	Help: "The total number of runners",
})

Functions

func DeepCopy added in v0.0.16

func DeepCopy(src, dist interface{}) (err error)

func ExprFuncHTTPReady added in v0.0.14

func ExprFuncHTTPReady(params ...interface{}) (res interface{}, err error)

ExprFuncHTTPReady is an expr function for reading status from a HTTP server

func ExprFuncSleep added in v0.0.12

func ExprFuncSleep(params ...interface{}) (res interface{}, err error)

ExprFuncSleep is an expr function for sleeping

func IsJSONCompatileType added in v0.0.18

func IsJSONCompatileType(contentType string) bool

func RegisterRunner added in v0.0.16

func RegisterRunner(kind string, runner RunnerCreator) error

func Verify added in v0.0.13

func Verify(expect testing.Response, data map[string]any) (err error)

Verify if the data satisfies the expression.

Types

type BodyGetter added in v0.0.15

type BodyGetter interface {
	GetBody() string
	GetBodyFieldsExpect() map[string]interface{}
}

type BodyVerifier added in v0.0.15

type BodyVerifier interface {
	Parse(data []byte) (interface{}, error)
	Verify(data []byte) error
}

func NewBodyVerify added in v0.0.15

func NewBodyVerify(contentType string, body BodyGetter) BodyVerifier

type ContextKey added in v0.0.12

type ContextKey string

ContextKey is the alias type of string for context key

func NewContextKeyBuilder added in v0.0.12

func NewContextKeyBuilder() ContextKey

NewContextKeyBuilder returns an emtpy context key

func (ContextKey) GetContextValueOrEmpty added in v0.0.12

func (c ContextKey) GetContextValueOrEmpty(ctx context.Context) string

GetContextValueOrEmpty returns the value of the context key, if not exist, return empty string

func (ContextKey) ParentDir added in v0.0.12

func (c ContextKey) ParentDir() ContextKey

ParentDir returns the key of the parsent directory

type FormatPrinter added in v0.0.9

type FormatPrinter interface {
	Fprintf(w io.Writer, level, format string, a ...any) (n int, err error)
}

FormatPrinter represents a formart printer with level

type GithubPRCommentOption added in v0.0.15

type GithubPRCommentOption struct {
	Repo       string
	PR         int
	Identity   string
	Token      string
	ReportFile string
}

type LevelWriter added in v0.0.9

type LevelWriter interface {
	Info(format string, a ...any)
	Debug(format string, a ...any)
	Trace(format string, a ...any)
}

LevelWriter represents a writer with level

func NewDefaultLevelWriter added in v0.0.9

func NewDefaultLevelWriter(level string, writer io.Writer) LevelWriter

NewDefaultLevelWriter creates a default LevelWriter instance

type LogLevel added in v0.0.15

type LogLevel int
const (
	LogLevelInfo  LogLevel = 3
	LogLevelDebug LogLevel = 5
	LogLevelTrace LogLevel = 7
)

type Mutator added in v0.0.16

type Mutator interface {
	Render(*testing.TestCase) *testing.TestCase
	Message() string
}

type ReportRecord added in v0.0.4

type ReportRecord struct {
	Group     string
	Name      string
	Method    string
	API       string
	Body      string
	BeginTime time.Time
	EndTime   time.Time
	Error     error
}

ReportRecord represents the raw data of a request

func NewReportRecord added in v0.0.4

func NewReportRecord() *ReportRecord

NewReportRecord creates a record, and set the begin time to be now

func (*ReportRecord) Duration added in v0.0.4

func (r *ReportRecord) Duration() time.Duration

Duration returns the duration between begin and end time

func (*ReportRecord) ErrorCount added in v0.0.4

func (r *ReportRecord) ErrorCount() int

ErrorCount returns the count number of errors

func (*ReportRecord) GetErrorMessage added in v0.0.12

func (r *ReportRecord) GetErrorMessage() string

GetErrorMessage returns the error message

type ReportResult added in v0.0.4

type ReportResult struct {
	Name             string
	API              string
	Count            int
	Average          time.Duration
	Max              time.Duration
	Min              time.Duration
	QPS              int
	Error            int
	LastErrorMessage string
}

ReportResult represents the report result of a set of the same API requests

type ReportResultSlice added in v0.0.4

type ReportResultSlice []ReportResult

ReportResultSlice is the alias type of ReportResult slice

func (ReportResultSlice) Len added in v0.0.4

func (r ReportResultSlice) Len() int

Len returns the count of slice items

func (ReportResultSlice) Less added in v0.0.4

func (r ReportResultSlice) Less(i, j int) bool

Less returns if i bigger than j

func (ReportResultSlice) Swap added in v0.0.4

func (r ReportResultSlice) Swap(i, j int)

Swap swaps the items

type ReportResultWithTotal added in v0.0.4

type ReportResultWithTotal struct {
	ReportResult
	Total time.Duration
	First time.Time
	Last  time.Time
}

ReportResultWithTotal holds the total duration base on ReportResult

type ReportResultWriter added in v0.0.4

type ReportResultWriter interface {
	Output([]ReportResult) error
	WithAPIConverage(apiConverage apispec.APIConverage) ReportResultWriter
	WithResourceUsage([]ResourceUsage) ReportResultWriter
}

ReportResultWriter is the interface of the report writer

func NewDiscardResultWriter added in v0.0.4

func NewDiscardResultWriter() ReportResultWriter

NewDiscardResultWriter creates a report result writer which discard everything

func NewGRPCResultWriter added in v0.0.17

func NewGRPCResultWriter(ctx context.Context, url string) ReportResultWriter

NewGRPCResultWriter creates a new grpcResultWriter

func NewGithubPRCommentWriter added in v0.0.15

func NewGithubPRCommentWriter(opt *GithubPRCommentOption) (ReportResultWriter, error)

func NewHTMLResultWriter added in v0.0.12

func NewHTMLResultWriter(writer io.Writer) ReportResultWriter

NewHTMLResultWriter creates a new htmlResultWriter

func NewHTTPResultWriter added in v0.0.17

func NewHTTPResultWriter(requestType string, url string, parameters map[string]string, templateFile *TemplateOption) ReportResultWriter

NewHTTPResultWriter creates a new httpResultWriter

func NewJSONResultWriter added in v0.0.13

func NewJSONResultWriter(writer io.Writer) ReportResultWriter

NewJSONResultWriter creates a new jsonResultWriter

func NewMarkdownResultWriter added in v0.0.4

func NewMarkdownResultWriter(writer io.Writer) ReportResultWriter

NewMarkdownResultWriter creates the Markdown writer

func NewPDFResultWriter added in v0.0.13

func NewPDFResultWriter(writer io.Writer) ReportResultWriter

NewPDFResultWriter creates a new PDFResultWriter

func NewResultWriter added in v0.0.4

func NewResultWriter(writer io.Writer) ReportResultWriter

NewResultWriter creates a result writer with the specific io.Writer

type ResourceUsage added in v0.0.15

type ResourceUsage struct {
	Memory uint64
	CPU    uint64
	Time   time.Time
}

type ResponseRecord added in v0.0.14

type ResponseRecord interface {
	GetResponseRecord() SimpleResponse
}

HTTPResponseRecord represents a http response record

type RunnerCreator added in v0.0.16

type RunnerCreator func(suite *testing.TestSuite) TestCaseRunner

type SimpleResponse added in v0.0.13

type SimpleResponse struct {
	Header     map[string]string
	Body       string
	StatusCode int
}

SimpleResponse represents a simple response

type TemplateOption added in v0.0.17

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

func NewTemplateOption added in v0.0.17

func NewTemplateOption(filename string, fileType string) *TemplateOption

type TestCaseRunner added in v0.0.4

type TestCaseRunner interface {
	RunTestCase(testcase *testing.TestCase, dataContext interface{}, ctx context.Context) (output interface{}, err error)
	GetSuggestedAPIs(suite *testing.TestSuite, api string) ([]*testing.TestCase, error)
	WithSecure(secure *testing.Secure)
	WithOutputWriter(io.Writer)
	WithWriteLevel(level string)
	WithTestReporter(TestReporter)
	WithExecer(fakeruntime.Execer)
	WithSuite(*testing.TestSuite)
	WithAPISuggestLimit(int)
}

TestCaseRunner represents a test case runner

func GetTestSuiteRunner added in v0.0.13

func GetTestSuiteRunner(suite *testing.TestSuite) TestCaseRunner

GetTestSuiteRunner returns a proper runner according to the given test suite.

func NewGRPCTestCaseRunner added in v0.0.13

func NewGRPCTestCaseRunner(host string, proto testing.RPCDesc) TestCaseRunner

func NewGraphQLRunner added in v0.0.16

func NewGraphQLRunner(parent TestCaseRunner) TestCaseRunner

func NewReverseHTTPRunner added in v0.0.16

func NewReverseHTTPRunner(normal TestCaseRunner) TestCaseRunner

func NewSimpleTestCaseRunner added in v0.0.4

func NewSimpleTestCaseRunner() TestCaseRunner

NewSimpleTestCaseRunner creates the instance of the simple test case runner

type TestReporter added in v0.0.4

type TestReporter interface {
	PutRecord(*ReportRecord)
	GetAllRecords() []*ReportRecord
	ExportAllReportResults() (ReportResultSlice, error)
	GetResourceUsage() []ResourceUsage
}

TestReporter is the interface of the report

func NewDiscardTestReporter added in v0.0.4

func NewDiscardTestReporter() TestReporter

NewDiscardTestReporter creates a test reporter which discard everything

func NewMemoryTestReporter added in v0.0.5

func NewMemoryTestReporter(resMonitor monitor.MonitorClient, monitorTarget string) TestReporter

NewMemoryTestReporter creates a memory based test reporter

func NewPrometheusWriter added in v0.0.14

func NewPrometheusWriter(remote string, sync bool) TestReporter

NewPrometheusWriter creates a new PrometheusWriter

type UnimplementedRunner added in v0.0.13

type UnimplementedRunner struct {
	Secure *testing.Secure
	// contains filtered or unexported fields
}

UnimplementedRunner implements interface TestCaseRunner except method RunTestCase.

Generally, this struct can be inherited directly when implementing a new runner. It is recommended to use NewDefaultUnimplementedRunner to initalize rather than to fill it manully.

func NewDefaultUnimplementedRunner added in v0.0.13

func NewDefaultUnimplementedRunner() UnimplementedRunner

NewDefaultUnimplementedRunner initializes an unimplementedRunner using the default values.

func (*UnimplementedRunner) GetSuggestedAPIs added in v0.0.16

func (r *UnimplementedRunner) GetSuggestedAPIs(suite *testing.TestSuite, api string) (result []*testing.TestCase, err error)

func (*UnimplementedRunner) RunTestCase added in v0.0.13

func (r *UnimplementedRunner) RunTestCase(testcase *testing.TestCase, dataContext interface{}, ctx context.Context) (output interface{}, err error)

func (*UnimplementedRunner) WithAPISuggestLimit added in v0.0.18

func (r *UnimplementedRunner) WithAPISuggestLimit(int)

func (*UnimplementedRunner) WithExecer added in v0.0.13

func (r *UnimplementedRunner) WithExecer(execer fakeruntime.Execer)

WithExecer sets the execer

func (*UnimplementedRunner) WithOutputWriter added in v0.0.13

func (r *UnimplementedRunner) WithOutputWriter(writer io.Writer)

WithOutputWriter sets the io.Writer

func (*UnimplementedRunner) WithSecure added in v0.0.14

func (r *UnimplementedRunner) WithSecure(secure *testing.Secure)

WithSecure sets the secure option.

func (*UnimplementedRunner) WithSuite added in v0.0.18

func (s *UnimplementedRunner) WithSuite(suite *testing.TestSuite)

func (*UnimplementedRunner) WithTestReporter added in v0.0.13

func (r *UnimplementedRunner) WithTestReporter(reporter TestReporter)

WithTestReporter sets the TestReporter

func (*UnimplementedRunner) WithWriteLevel added in v0.0.13

func (r *UnimplementedRunner) WithWriteLevel(level string)

WithWriteLevel sets the level writer

Directories

Path Synopsis
Package kubernetes provides a low level client for small footprint consideration
Package kubernetes provides a low level client for small footprint consideration

Jump to

Keyboard shortcuts

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