checks

package
v0.0.1-77 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestFeatureEnhancedPreparedStatements = "enhancedprepared"
	TestFeature3Replicas                  = "3replicas"
	TestFeatureErrMap                     = "errmap"
)

The following is a list of all supported features.

Variables

This section is empty.

Functions

func Register

func Register(group, name string, fn func(*T), desc string)

Register registers a check suite check

Types

type BucketRef

type BucketRef struct {
	Cluster    ClusterRef
	BucketName string
}

BucketRef represents a bucket within the checks system.

func (BucketRef) HookHelper

func (c BucketRef) HookHelper(handler mock.KvHookFunc) KVHook

func (BucketRef) KvExpectReq

func (c BucketRef) KvExpectReq() *KvExpect

KvExpectReq returns a new expectation of a kv request.

type Check

type Check struct {
	Group       string
	Name        string
	Description string
	Fn          func(t *T)
}

Check represents a single check that has been registered.

type ClusterRef

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

ClusterRef represents a cluster within the checks system.

func (ClusterRef) HookHelper

func (c ClusterRef) HookHelper(handler mock.KvHookFunc) KVHook

func (ClusterRef) KvExpectReq

func (c ClusterRef) KvExpectReq() *KvExpect

KvExpectReq returns a new expectation of a kv request.

func (ClusterRef) KvExpectRes

func (c ClusterRef) KvExpectRes() *KvExpect

KvExpectReq returns a new expectation of a kv response.

type CollectionRef

type CollectionRef struct {
	Scope          ScopeRef
	CollectionName string
}

CollectionRef represents a collection within the checks system.

func (CollectionRef) HookHelper

func (c CollectionRef) HookHelper(handler mock.KvHookFunc) KVHook

func (CollectionRef) KvExpectReq

func (c CollectionRef) KvExpectReq() *KvExpect

KvExpectReq returns a new expectation of a kv request.

type KVHook

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

func NewKvHook

func NewKvHook(expect *KvExpect, handler mock.KvHookFunc) KVHook

func (KVHook) Build

func (hook KVHook) Build() mock.KvHookFunc

func (KVHook) Cmd

func (hook KVHook) Cmd(command memd.CmdCode) *KVHook

func (KVHook) Key

func (hook KVHook) Key(key string) *KVHook

func (KVHook) Times

func (hook KVHook) Times(times uint32) *KVHook

type KvExpect

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

KvExpect represents a Kv expectation.

func (KvExpect) BucketName

func (e KvExpect) BucketName(name string) *KvExpect

BucketName specifies a specific bucket name which is expected.

func (KvExpect) Cmd

func (e KvExpect) Cmd(cmd memd.CmdCode) *KvExpect

Cmd specifies a specific cmd which is expected.

func (KvExpect) CollectionID

func (e KvExpect) CollectionID(id uint32) *KvExpect

CollectionID specifies a specific collection id which is expected.

func (KvExpect) CollectionName

func (e KvExpect) CollectionName(name string) *KvExpect

CollectionName specifies a specific collection name which is expected.

func (KvExpect) Custom

func (e KvExpect) Custom(chkFn func(mock.KvClient, *memd.Packet) bool) *KvExpect

Custom allows specifying custom logic to use to check the packet.

func (KvExpect) Key

func (e KvExpect) Key(key string) *KvExpect

Key specifies a specific key which is expected.

func (KvExpect) KeyBytes

func (e KvExpect) KeyBytes(key []byte) *KvExpect

KeyBytes specifies a specific key which is expected as bytes.

func (KvExpect) Magic

func (e KvExpect) Magic(magic memd.CmdMagic) *KvExpect

Magic specifies a specific magic which is expected.

func (KvExpect) Opaque

func (e KvExpect) Opaque(opaque uint32) *KvExpect

Opaque specifies a specific opaque which is expected.

func (KvExpect) ReplyTo

func (e KvExpect) ReplyTo(source mock.KvClient, pak *memd.Packet) *KvExpect

ReplyTo specifies to expect the reply to another packet.

func (KvExpect) ScopeName

func (e KvExpect) ScopeName(name string) *KvExpect

ScopeName specifies a specific scope name which is expected.

func (KvExpect) Source

func (e KvExpect) Source(cli mock.KvClient) *KvExpect

Source specifies a specific source which is expected.

func (KvExpect) String

func (e KvExpect) String() string

func (KvExpect) Wait

func (e KvExpect) Wait() (mock.KvClient, *memd.Packet)

Wait will wait until this expectation is satisfied.

type RecordedPacket

type RecordedPacket struct {
	ID                     uint64
	WasSent                bool
	SrcAddr                string
	SrcName                string
	DestAddr               string
	DestName               string
	IsTLS                  bool
	SelectedBucketName     string
	ResolvedScopeName      string
	ResolvedCollectionName string
	Data                   memd.Packet
}

type ScopeRef

type ScopeRef struct {
	Bucket    BucketRef
	ScopeName string
}

ScopeRef represents a scope within the checks system.

func (ScopeRef) HookHelper

func (c ScopeRef) HookHelper(handler mock.KvHookFunc) KVHook

func (ScopeRef) KvExpectReq

func (c ScopeRef) KvExpectReq() *KvExpect

KvExpectReq returns a new expectation of a kv request.

type T

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

T represents a singular check test that is being run.

func (*T) Bucket

func (t *T) Bucket() BucketRef

Bucket returns a reference to the bucket associated with this check.

func (*T) Cluster

func (t *T) Cluster() ClusterRef

Cluster returns a reference to the cluster associated with this check.

func (*T) Collection

func (t *T) Collection() CollectionRef

Collection returns a reference to the collection associated with this check.

func (*T) End

func (t *T) End(result interface{})

End ends this test as quickly as possible.

func (*T) Errorf

func (t *T) Errorf(format string, args ...interface{})

Errorf writes a log message as part of this check and then calls Fail.

func (*T) Fail

func (t *T) Fail()

Fail marks this check as having failed.

func (*T) FailNow

func (t *T) FailNow()

FailNow mark this check as having failed and immediately bails out of the check.

func (*T) Fatalf

func (t *T) Fatalf(format string, args ...interface{})

Fatalf writes a log message as part of this check and then calls FailNow.

func (*T) Logf

func (t *T) Logf(format string, args ...interface{})

Logf writes a log message as part of this check.

func (*T) Mock

func (t *T) Mock() mock.Cluster

Mock returns the mock associated with this check.

func (*T) RequireFeature

func (t *T) RequireFeature(feature TestFeature)

RequireFeature marks a feature as required by this check.

func (*T) RequireMock

func (t *T) RequireMock()

RequireMock marks this check as requiring a non default cluster instance.

func (*T) Scope

func (t *T) Scope() ScopeRef

Scope returns a reference to the scope associated with this check.

func (*T) SetBucket

func (t *T) SetBucket(name string)

func (*T) Start

func (t *T) Start() (*TestStartedSpec, error)

Start will start a test and wait till it is configured.

func (*T) UseManagementConnString

func (t *T) UseManagementConnString()

type TestFeature

type TestFeature string

TestFeature represents a feature that may be required by a test.

type TestResult

type TestResult struct {
	Name        string
	Description string
	Status      TestStatus
	Logs        []string
	Packets     []*RecordedPacket
}

TestResult represents the result of a test.

type TestRunner

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

TestRunner represents a single run of all tests.

func NewTestRunner

func NewTestRunner() (*TestRunner, error)

NewTestRunner creates a new test run group for running tests.

func (*TestRunner) DefaultCluster

func (g *TestRunner) DefaultCluster() mock.Cluster

DefaultCluster returns the default cluster associated with this test run.

func (*TestRunner) End

func (g *TestRunner) End()

End will end any currently running test, then the whole test group.

func (*TestRunner) EndRunningTest

func (g *TestRunner) EndRunningTest(result interface{}) error

EndRunningTest will end whatever test is currently running.

func (*TestRunner) Results

func (g *TestRunner) Results() []*TestResult

Results returns the results of this test run once it has ended.

func (*TestRunner) StartTest

func (g *TestRunner) StartTest(name string) (*TestStartedSpec, error)

StartTest will begin a test by name.

type TestStartedSpec

type TestStartedSpec struct {
	Connstr        string
	BucketName     string
	ScopeName      string
	CollectionName string
}

TestStartedSpec represents all the information needed to run a test.

type TestStatus

type TestStatus int
const (
	TestStatusUnknown TestStatus = iota
	TestStatusSkipped
	TestStatusSuccess
	TestStatusFailed
)

Jump to

Keyboard shortcuts

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