test

package
v0.0.0-...-211e212 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: GPL-3.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const RaceDetectorEnabled = false

Variables

View Source
var Bar_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "test.Bar",
	HandlerType: (*BarServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Bar",
			Handler:       _Bar_Bar_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "pkg/test/test.proto",
}

Bar_ServiceDesc is the grpc.ServiceDesc for Bar service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var Benchmark_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "test.Benchmark",
	HandlerType: (*BenchmarkServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Stream",
			Handler:       _Benchmark_Stream_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "pkg/test/test.proto",
}

Benchmark_ServiceDesc is the grpc.ServiceDesc for Benchmark service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var DefaultTestToolchain *types.Toolchain
View Source
var File_pkg_test_test_proto protoreflect.FileDescriptor
View Source
var Foo_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "test.Foo",
	HandlerType: (*FooServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Foo",
			Handler:    _Foo_Foo_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "pkg/test/test.proto",
}

Foo_ServiceDesc is the grpc.ServiceDesc for Foo service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var TestToolchainExecutable = "/path/to/test-toolchain"

Functions

func AddToStore

func AddToStore(store *run.ToolchainRunnerStore)

func AddToStoreSim

func AddToStoreSim(store *run.ToolchainRunnerStore)

func EqualProto

func EqualProto(expected proto.Message) types.GomegaMatcher

func EventuallyHealthStatusShouldBeReady

func EventuallyHealthStatusShouldBeReady(ctx context.Context, env Environment)

func ExtendTimeoutsIfDebugging

func ExtendTimeoutsIfDebugging()

func InGithubWorkflow

func InGithubWorkflow() bool

InGithubWorkflow returns true if the test is running inside github workflow CI, otherwise false. The GITHUB_WORKFLOW environment variable is set in .github/workflows/go.yml.

func IsRaceDetectorEnabled

func IsRaceDetectorEnabled() bool

func MakeHashTaskPool

func MakeHashTaskPool(numTasks int) chan task

func MakeSleepTaskPool

func MakeSleepTaskPool(numTasks int, genDuration ...func() string) chan task

func NewCacheClient

func NewCacheClient(e Environment, ctx context.Context, name ...string) types.CacheClient

func NewConsumerdClient

func NewConsumerdClient(e Environment, ctx context.Context, name ...string) types.ConsumerdClient

func NewMonitorClient

func NewMonitorClient(e Environment, ctx context.Context, name ...string) types.MonitorClient

func NewSchedulerClient

func NewSchedulerClient(e Environment, ctx context.Context, name ...string) types.SchedulerClient

func ProcessTaskPool

func ProcessTaskPool(testEnv Environment, cdName string, jobs int, pool chan task, duration time.Duration)

func RegisterBarServer

func RegisterBarServer(s grpc.ServiceRegistrar, srv BarServer)

func RegisterBenchmarkServer

func RegisterBenchmarkServer(s grpc.ServiceRegistrar, srv BenchmarkServer)

func RegisterFooServer

func RegisterFooServer(s grpc.ServiceRegistrar, srv FooServer)

func SkipInGithubWorkflow

func SkipInGithubWorkflow()

SkipInGithubWorkflow will skip the current ginkgo test if running inside github workflow CI.

func SpawnAgent

func SpawnAgent(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

func SpawnCache

func SpawnCache(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

func SpawnConsumerd

func SpawnConsumerd(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

func SpawnMonitor

func SpawnMonitor(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

func SpawnScheduler

func SpawnScheduler(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

Types

type Action

type Action int
const (
	Sleep Action = iota
	Hash
)

type BarClient

type BarClient interface {
	Bar(ctx context.Context, opts ...grpc.CallOption) (Bar_BarClient, error)
}

BarClient is the client API for Bar service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewBarClient

func NewBarClient(cc grpc.ClientConnInterface) BarClient

type BarServer

type BarServer interface {
	Bar(Bar_BarServer) error
	// contains filtered or unexported methods
}

BarServer is the server API for Bar service. All implementations must embed UnimplementedBarServer for forward compatibility

type Bar_BarClient

type Bar_BarClient interface {
	Send(*Baz) error
	Recv() (*Baz, error)
	grpc.ClientStream
}

type Bar_BarServer

type Bar_BarServer interface {
	Send(*Baz) error
	Recv() (*Baz, error)
	grpc.ServerStream
}

type Baz

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

func (*Baz) Descriptor deprecated

func (*Baz) Descriptor() ([]byte, []int)

Deprecated: Use Baz.ProtoReflect.Descriptor instead.

func (*Baz) ProtoMessage

func (*Baz) ProtoMessage()

func (*Baz) ProtoReflect

func (x *Baz) ProtoReflect() protoreflect.Message

func (*Baz) Reset

func (x *Baz) Reset()

func (*Baz) String

func (x *Baz) String() string

type BenchmarkClient

type BenchmarkClient interface {
	Stream(ctx context.Context, opts ...grpc.CallOption) (Benchmark_StreamClient, error)
}

BenchmarkClient is the client API for Benchmark service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewBenchmarkClient

func NewBenchmarkClient(cc grpc.ClientConnInterface) BenchmarkClient

type BenchmarkServer

type BenchmarkServer interface {
	Stream(Benchmark_StreamServer) error
	// contains filtered or unexported methods
}

BenchmarkServer is the server API for Benchmark service. All implementations must embed UnimplementedBenchmarkServer for forward compatibility

type Benchmark_StreamClient

type Benchmark_StreamClient interface {
	Send(*Payload) error
	Recv() (*Payload, error)
	grpc.ClientStream
}

type Benchmark_StreamServer

type Benchmark_StreamServer interface {
	Send(*Payload) error
	Recv() (*Payload, error)
	grpc.ServerStream
}

type BufconnEnvironment

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

BufconnEnvironment is an in-process simulated kubecc cluster environment used in tests.

func (*BufconnEnvironment) Context

func (e *BufconnEnvironment) Context() context.Context

func (*BufconnEnvironment) DefaultConfig

func (e *BufconnEnvironment) DefaultConfig() config.KubeccSpec

func (*BufconnEnvironment) Dial

func (*BufconnEnvironment) Log

func (*BufconnEnvironment) MetricF

func (e *BufconnEnvironment) MetricF(srvCtx context.Context, out proto.Message) func() (proto.Message, error)

func (*BufconnEnvironment) Serve

func (e *BufconnEnvironment) Serve(ctx context.Context, server interface{}, name string)

func (*BufconnEnvironment) Shutdown

func (e *BufconnEnvironment) Shutdown()

func (*BufconnEnvironment) WaitForReady

func (e *BufconnEnvironment) WaitForReady(uuid string, timeout ...time.Duration)

type Environment

type Environment interface {
	// Context returns the top level environment context.
	Context() context.Context

	// DefaultConfig returns a reasonable set of default values for testing.
	DefaultConfig() config.KubeccSpec

	// Dial creates a grpc client connection to the component named by the component
	// type and an optional name which defaults to "default" if not provided.
	Dial(ctx context.Context, c types.Component, name ...string) *grpc.ClientConn

	// Shutdown terminates all components running in the environment by canceling
	// the top-level parent context.
	Shutdown()

	// WaitForReady blocks until the component with the given UUID posts a
	// Ready status. Requires a running monitor.
	WaitForReady(uuid string, timeout ...time.Duration)

	// MetricF returns a function that when called will populate out with the
	// current values of the metric of the matching type.
	MetricF(srvCtx context.Context, out proto.Message) func() (proto.Message, error)

	// Serve starts a server component. This function should not block.
	Serve(ctx context.Context, server interface{}, name string)
}

func NewBufconnEnvironment

func NewBufconnEnvironment(cfg config.KubeccSpec) Environment

func NewBufconnEnvironmentWithLogLevel

func NewBufconnEnvironmentWithLogLevel(lv zapcore.Level) Environment

func NewDefaultBufconnEnvironment

func NewDefaultBufconnEnvironment() Environment

func NewDefaultLocalhostEnvironment

func NewDefaultLocalhostEnvironment() Environment

func NewLocalhostEnvironmentWithLogLevel

func NewLocalhostEnvironmentWithLogLevel(lv zapcore.Level) Environment

type FooClient

type FooClient interface {
	Foo(ctx context.Context, in *Baz, opts ...grpc.CallOption) (*Baz, error)
}

FooClient is the client API for Foo service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewFooClient

func NewFooClient(cc grpc.ClientConnInterface) FooClient

type FooServer

type FooServer interface {
	Foo(context.Context, *Baz) (*Baz, error)
	// contains filtered or unexported methods
}

FooServer is the server API for Foo service. All implementations must embed UnimplementedFooServer for forward compatibility

type HashTask

type HashTask struct {
	run.TaskOptions
	util.NullableError
	Input string
}

HashTask will compute the md5 sum of the Input string and write the output to the OutputWriter specified in the task options.

func (*HashTask) Run

func (t *HashTask) Run()

type LocalhostEnvironment

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

func NewLocalhostEnvironment

func NewLocalhostEnvironment(cfg config.KubeccSpec) *LocalhostEnvironment

func (*LocalhostEnvironment) Context

func (e *LocalhostEnvironment) Context() context.Context

func (*LocalhostEnvironment) DefaultConfig

func (e *LocalhostEnvironment) DefaultConfig() config.KubeccSpec

func (*LocalhostEnvironment) Dial

func (*LocalhostEnvironment) Log

func (*LocalhostEnvironment) MetricF

func (e *LocalhostEnvironment) MetricF(srvCtx context.Context, out proto.Message) func() (proto.Message, error)

func (*LocalhostEnvironment) Serve

func (e *LocalhostEnvironment) Serve(ctx context.Context, server interface{}, name string)

func (*LocalhostEnvironment) Shutdown

func (e *LocalhostEnvironment) Shutdown()

func (*LocalhostEnvironment) WaitForReady

func (e *LocalhostEnvironment) WaitForReady(uuid string, timeout ...time.Duration)

type NoopArgParser

type NoopArgParser struct{}

func (NoopArgParser) CanRunRemote

func (NoopArgParser) CanRunRemote() bool

func (*NoopArgParser) Parse

func (*NoopArgParser) Parse()

type NoopRunner

type NoopRunner struct{}

func (*NoopRunner) Run

func (*NoopRunner) Run() error

type Payload

type Payload struct {
	Data []byte `protobuf:"bytes,1,opt,name=Data,proto3" json:"Data,omitempty"`
	// contains filtered or unexported fields
}

func (*Payload) Descriptor deprecated

func (*Payload) Descriptor() ([]byte, []int)

Deprecated: Use Payload.ProtoReflect.Descriptor instead.

func (*Payload) GetData

func (x *Payload) GetData() []byte

func (*Payload) ProtoMessage

func (*Payload) ProtoMessage()

func (*Payload) ProtoReflect

func (x *Payload) ProtoReflect() protoreflect.Message

func (*Payload) Reset

func (x *Payload) Reset()

func (*Payload) String

func (x *Payload) String() string

type ProtoEqualMatcher

type ProtoEqualMatcher struct {
	Expected proto.Message
}

func (*ProtoEqualMatcher) FailureMessage

func (matcher *ProtoEqualMatcher) FailureMessage(actual interface{}) (message string)

func (*ProtoEqualMatcher) Match

func (matcher *ProtoEqualMatcher) Match(actual interface{}) (success bool, err error)

func (*ProtoEqualMatcher) NegatedFailureMessage

func (matcher *ProtoEqualMatcher) NegatedFailureMessage(actual interface{}) (message string)

type SampleQuerier

type SampleQuerier struct{}

SampleQuerier is a querier that will return predefined values for some common compiler toolchains

func (SampleQuerier) IsPicDefault

func (q SampleQuerier) IsPicDefault(compiler string) (bool, error)

func (SampleQuerier) IsPieDefault

func (q SampleQuerier) IsPieDefault(compiler string) (bool, error)

func (SampleQuerier) Kind

func (q SampleQuerier) Kind(compiler string) (types.ToolchainKind, error)

func (SampleQuerier) Lang

func (q SampleQuerier) Lang(compiler string) (types.ToolchainLang, error)

func (SampleQuerier) ModTime

func (q SampleQuerier) ModTime(compiler string) (time.Time, error)

func (SampleQuerier) TargetArch

func (q SampleQuerier) TargetArch(compiler string) (string, error)

func (SampleQuerier) Version

func (q SampleQuerier) Version(compiler string) (string, error)

type SleepTask

type SleepTask struct {
	util.NullableError
	Context  context.Context
	Duration time.Duration
}

func (*SleepTask) Run

func (t *SleepTask) Run()

type SpawnOption

type SpawnOption func(*SpawnOptions)

func WaitForReady

func WaitForReady() SpawnOption

func WithAgentOptions

func WithAgentOptions(opts ...agent.AgentServerOption) SpawnOption

func WithCacheOptions

func WithCacheOptions(opts ...cachesrv.CacheServerOption) SpawnOption

func WithConfig

func WithConfig(cfg interface{}) SpawnOption

WithConfig is used to override specific config values when spawning a component. Any values provided here will be merged with the defaults.

func WithConsumerdOptions

func WithConsumerdOptions(opts ...consumerd.ConsumerdServerOption) SpawnOption

func WithName

func WithName(name string) SpawnOption

WithName provides a component name. Each component has a default name of "default" which can be used to dial that component when creating the in-memory connection.

func WithSchedulerOptions

func WithSchedulerOptions(opts ...scheduler.SchedulerServerOption) SpawnOption

func WithUUID

func WithUUID(uuid string) SpawnOption

type SpawnOptions

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

func (*SpawnOptions) Apply

func (o *SpawnOptions) Apply(opts ...SpawnOption)

type Spawner

type Spawner interface {
	// SpawnAgent adds a new agent to the environment. If the returned context
	// is canceled, the agent will be stopped.
	SpawnAgent(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

	// SpawnScheduler adds a new scheduler to the environment. If the returned context
	// is canceled, the scheduler will be stopped.
	SpawnScheduler(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

	// SpawnConsumerd adds a new consumerd to the environment. If the returned context
	// is canceled, the consumerd will be stopped.
	SpawnConsumerd(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

	// SpawnMonitor adds a new monitor to the environment. If the returned context
	// is canceled, the monitor will be stopped.
	SpawnMonitor(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)

	// SpawnCache adds a new cache server  to the environment. If the returned context
	// is canceled, the cache server will be stopped.
	SpawnCache(e Environment, opts ...SpawnOption) (context.Context, context.CancelFunc)
}

type Test1

type Test1 struct {
	Counter int32 `protobuf:"varint,1,opt,name=Counter,proto3" json:"Counter,omitempty"`
	// contains filtered or unexported fields
}

func (*Test1) Descriptor deprecated

func (*Test1) Descriptor() ([]byte, []int)

Deprecated: Use Test1.ProtoReflect.Descriptor instead.

func (*Test1) GetCounter

func (x *Test1) GetCounter() int32

func (*Test1) ProtoMessage

func (*Test1) ProtoMessage()

func (*Test1) ProtoReflect

func (x *Test1) ProtoReflect() protoreflect.Message

func (*Test1) Reset

func (x *Test1) Reset()

func (*Test1) String

func (x *Test1) String() string

type Test2

type Test2 struct {
	Value string `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"`
	// contains filtered or unexported fields
}

func (*Test2) Descriptor deprecated

func (*Test2) Descriptor() ([]byte, []int)

Deprecated: Use Test2.ProtoReflect.Descriptor instead.

func (*Test2) GetValue

func (x *Test2) GetValue() string

func (*Test2) ProtoMessage

func (*Test2) ProtoMessage()

func (*Test2) ProtoReflect

func (x *Test2) ProtoReflect() protoreflect.Message

func (*Test2) Reset

func (x *Test2) Reset()

func (*Test2) String

func (x *Test2) String() string

type Test3

type Test3 struct {
	Counter int32 `protobuf:"varint,1,opt,name=counter,proto3" json:"counter,omitempty"`
	// contains filtered or unexported fields
}

func (*Test3) Descriptor deprecated

func (*Test3) Descriptor() ([]byte, []int)

Deprecated: Use Test3.ProtoReflect.Descriptor instead.

func (*Test3) GetCounter

func (x *Test3) GetCounter() int32

func (*Test3) ProtoMessage

func (*Test3) ProtoMessage()

func (*Test3) ProtoReflect

func (x *Test3) ProtoReflect() protoreflect.Message

func (*Test3) Reset

func (x *Test3) Reset()

func (*Test3) String

func (x *Test3) String() string

type Test4

type Test4 struct {
	Value string `protobuf:"bytes,1,opt,name=Value,proto3" json:"Value,omitempty"`
	// contains filtered or unexported fields
}

func (*Test4) Descriptor deprecated

func (*Test4) Descriptor() ([]byte, []int)

Deprecated: Use Test4.ProtoReflect.Descriptor instead.

func (*Test4) GetValue

func (x *Test4) GetValue() string

func (*Test4) ProtoMessage

func (*Test4) ProtoMessage()

func (*Test4) ProtoReflect

func (x *Test4) ProtoReflect() protoreflect.Message

func (*Test4) Reset

func (x *Test4) Reset()

func (*Test4) String

func (x *Test4) String() string

type TestArgParser

type TestArgParser struct {
	Args     []string
	Duration time.Duration
	Input    string
	Action   Action
}

func (TestArgParser) CanRunRemote

func (TestArgParser) CanRunRemote() bool

func (TestArgParser) DeepCopy

func (t TestArgParser) DeepCopy() run.ArgParser

func (*TestArgParser) Parse

func (ap *TestArgParser) Parse()

type TestQuerier

type TestQuerier struct{}

func (TestQuerier) IsPicDefault

func (q TestQuerier) IsPicDefault(compiler string) (bool, error)

func (TestQuerier) IsPieDefault

func (q TestQuerier) IsPieDefault(compiler string) (bool, error)

func (TestQuerier) Kind

func (q TestQuerier) Kind(compiler string) (types.ToolchainKind, error)

func (TestQuerier) Lang

func (q TestQuerier) Lang(compiler string) (types.ToolchainLang, error)

func (TestQuerier) ModTime

func (q TestQuerier) ModTime(compiler string) (time.Time, error)

func (TestQuerier) TargetArch

func (q TestQuerier) TargetArch(compiler string) (string, error)

func (TestQuerier) Version

func (q TestQuerier) Version(compiler string) (string, error)

type TestToolchainCtrl

type TestToolchainCtrl struct{}

func (*TestToolchainCtrl) NewArgParser

func (r *TestToolchainCtrl) NewArgParser(_ context.Context, args []string) run.ArgParser

func (*TestToolchainCtrl) RecvRemote

func (r *TestToolchainCtrl) RecvRemote() run.RequestManager

func (*TestToolchainCtrl) RunLocal

func (*TestToolchainCtrl) SendRemote

type TestToolchainCtrlLocal

type TestToolchainCtrlLocal struct{}

TestToolchainCtrlLocal is similar to TestToolchainRunner, except that it will simulate a remote connection. All tasks are run locally but separate executors can be used to measure local and remote usage.

func (*TestToolchainCtrlLocal) NewArgParser

func (r *TestToolchainCtrlLocal) NewArgParser(_ context.Context, args []string) run.ArgParser

func (*TestToolchainCtrlLocal) RecvRemote

func (r *TestToolchainCtrlLocal) RecvRemote() run.RequestManager

func (*TestToolchainCtrlLocal) RunLocal

func (*TestToolchainCtrlLocal) SendRemote

type TestToolchainFinder

type TestToolchainFinder struct{}

func (TestToolchainFinder) FindToolchains

func (f TestToolchainFinder) FindToolchains(
	ctx context.Context,
	opts ...toolchains.FindOption,
) *toolchains.Store

type UnimplementedBarServer

type UnimplementedBarServer struct {
}

UnimplementedBarServer must be embedded to have forward compatible implementations.

func (UnimplementedBarServer) Bar

type UnimplementedBenchmarkServer

type UnimplementedBenchmarkServer struct {
}

UnimplementedBenchmarkServer must be embedded to have forward compatible implementations.

func (UnimplementedBenchmarkServer) Stream

type UnimplementedFooServer

type UnimplementedFooServer struct {
}

UnimplementedFooServer must be embedded to have forward compatible implementations.

func (UnimplementedFooServer) Foo

type UnsafeBarServer

type UnsafeBarServer interface {
	// contains filtered or unexported methods
}

UnsafeBarServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to BarServer will result in compilation errors.

type UnsafeBenchmarkServer

type UnsafeBenchmarkServer interface {
	// contains filtered or unexported methods
}

UnsafeBenchmarkServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to BenchmarkServer will result in compilation errors.

type UnsafeFooServer

type UnsafeFooServer interface {
	// contains filtered or unexported methods
}

UnsafeFooServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to FooServer will result in compilation errors.

Directories

Path Synopsis
Package mock_types is a generated GoMock package.
Package mock_types is a generated GoMock package.

Jump to

Keyboard shortcuts

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