integration

package
v4.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSkip

func CheckSkip(t testing.TB)

CheckSkip marks a test to be skipped unless the integration test has been specifically requested using the -run flag.

func GetFreePort

func GetFreePort() (int, error)

GetFreePort attempts to get a free port. This involves creating a bind and then immediately dropping it and so it's ever so slightly flakey.

Types

type CachePreTestFn

type CachePreTestFn func(t testing.TB, ctx context.Context, testID string, vars *CacheTestConfigVars)

CachePreTestFn is an optional closure to be called before tests are run, this is an opportunity to mutate test config variables and mess with the environment.

type CacheTestConfigVars

type CacheTestConfigVars struct {
	// A unique identifier for separating this test configuration from others.
	// Usually used to access a different topic, consumer group, directory, etc.
	ID string

	// A Port to use in connector URLs. Allowing tests to override this
	// potentially enables tests that check for faulty connections by bridging.
	Port string

	// Generic variables.
	Var1 string
}

CacheTestConfigVars exposes some variables injected into template configs for cache unit tests.

type CacheTestDefinition

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

CacheTestDefinition encompasses a unit test to be executed against an integration environment. These tests are generic and can be run against any configuration containing an input and an output that are connected.

func CacheTestDelete

func CacheTestDelete() CacheTestDefinition

CacheTestDelete checks that deletes work.

func CacheTestDoubleAdd

func CacheTestDoubleAdd() CacheTestDefinition

CacheTestDoubleAdd ensures that a double add returns an error.

func CacheTestGetAndSet

func CacheTestGetAndSet(n int) CacheTestDefinition

CacheTestGetAndSet checks that we can set and then get n items.

func CacheTestMissingKey

func CacheTestMissingKey() CacheTestDefinition

CacheTestMissingKey checks that we get an error on missing key.

func CacheTestOpenClose

func CacheTestOpenClose() CacheTestDefinition

CacheTestOpenClose checks that the cache can be started, an item added, and then stopped.

type CacheTestList

type CacheTestList []CacheTestDefinition

CacheTestList is a list of cache test definitions that can be run with a single template and function args.

func CacheTests

func CacheTests(tests ...CacheTestDefinition) CacheTestList

CacheTests creates a list of tests from variadic arguments.

func (CacheTestList) Run

func (i CacheTestList) Run(t *testing.T, configTemplate string, opts ...CacheTestOptFunc)

Run all the tests against a config template. Tests are run in parallel.

type CacheTestOptFunc

type CacheTestOptFunc func(*cacheTestEnvironment)

CacheTestOptFunc is an opt func for customizing the behaviour of cache tests, these are useful for things that are integration environment specific, such as the port of the service being interacted with.

func CacheTestOptLogging

func CacheTestOptLogging(level string) CacheTestOptFunc

CacheTestOptLogging allows components to log with the given log level. This is useful for diagnosing issues.

func CacheTestOptPort

func CacheTestOptPort(port string) CacheTestOptFunc

CacheTestOptPort defines the port of the integration service.

func CacheTestOptPreTest

func CacheTestOptPreTest(fn CachePreTestFn) CacheTestOptFunc

CacheTestOptPreTest adds a closure to be executed before each test.

func CacheTestOptTimeout

func CacheTestOptTimeout(timeout time.Duration) CacheTestOptFunc

CacheTestOptTimeout describes an optional timeout spanning the entirety of the test suite.

func CacheTestOptVarOne

func CacheTestOptVarOne(v string) CacheTestOptFunc

CacheTestOptVarOne sets an arbitrary variable for the test that can be injected into templated configs.

type GetMessageFunc

type GetMessageFunc func(ctx context.Context, testID, messageID string) (string, []string, error)

GetMessageFunc is a closure used to extract message contents from an output directly and can be used to test outputs without the need for an input in the config template.

type StreamBenchDefinition

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

StreamBenchDefinition encompasses a benchmark to be executed against an integration environment. These tests are generic and can be run against any configuration containing an input and an output that are connected.

func StreamBenchSend

func StreamBenchSend(batchSize, parallelism int) StreamBenchDefinition

StreamBenchSend benchmarks the speed at which messages are sent over the templated output and then subsequently received from the input with a given batch size and parallelism.

func StreamBenchWrite

func StreamBenchWrite(batchSize int) StreamBenchDefinition

StreamBenchWrite benchmarks the speed at which messages can be written to the output, with no attempt made to consume the written data.

type StreamBenchList

type StreamBenchList []StreamBenchDefinition

StreamBenchList is a list of stream benchmark definitions that can be run with a single template and function args.

func StreamBenchs

func StreamBenchs(tests ...StreamBenchDefinition) StreamBenchList

StreamBenchs creates a list of benchmarks from variadic arguments.

func (StreamBenchList) Run

func (i StreamBenchList) Run(b *testing.B, configTemplate string, opts ...StreamTestOptFunc)

Run the benchmarks against a config template.

type StreamPreTestFn

type StreamPreTestFn func(t testing.TB, ctx context.Context, testID string, vars *StreamTestConfigVars)

StreamPreTestFn is an optional closure to be called before tests are run, this is an opportunity to mutate test config variables and mess with the environment.

type StreamTestConfigVars

type StreamTestConfigVars struct {
	// A unique identifier for separating this test configuration from others.
	// Usually used to access a different topic, consumer group, directory, etc.
	ID string

	// Used by batching testers to check the input honours batching fields.
	InputBatchCount int

	// Used by batching testers to check the output honours batching fields.
	OutputBatchCount int

	// Used by metadata filter tests to check that filters work.
	OutputMetaExcludePrefix string

	// Used by testers to check the max in flight option of outputs.
	MaxInFlight int

	// Generic variables.
	Var1 string
	Var2 string
	Var3 string
	Var4 string
	// contains filtered or unexported fields
}

StreamTestConfigVars defines variables that will be accessed by test definitions when generating components through the config template. The main value is the id, which is generated for each test for isolation, and the port which is injected into the config template.

type StreamTestDefinition

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

StreamTestDefinition encompasses a unit test to be executed against an integration environment. These tests are generic and can be run against any configuration containing an input and an output that are connected.

func StreamTestAtLeastOnceDelivery

func StreamTestAtLeastOnceDelivery() StreamTestDefinition

StreamTestAtLeastOnceDelivery ensures data is delivered through nacks and restarts.

func StreamTestCheckpointCapture

func StreamTestCheckpointCapture() StreamTestDefinition

StreamTestCheckpointCapture ensures that data received out of order doesn't result in wrongly acknowledged messages.

func StreamTestMetadata

func StreamTestMetadata() StreamTestDefinition

StreamTestMetadata ensures that we are able to send and receive metadata values.

func StreamTestMetadataFilter

func StreamTestMetadataFilter() StreamTestDefinition

StreamTestMetadataFilter ensures that we are able to send and receive metadata values, and that they are filtered. The provided config template should inject the variable $OUTPUT_META_EXCLUDE_PREFIX into the output metadata filter field.

func StreamTestOpenClose

func StreamTestOpenClose() StreamTestDefinition

StreamTestOpenClose ensures that both the input and output can be started and stopped within a reasonable length of time. A single message is sent to check the connection.

func StreamTestOpenCloseIsolated

func StreamTestOpenCloseIsolated() StreamTestDefinition

StreamTestOpenCloseIsolated ensures that both the input and output can be started and stopped within a reasonable length of time. A single message is sent to check the connection but the input is only started after the message is sent.

func StreamTestOutputOnlyOverride

func StreamTestOutputOnlyOverride(getFn GetMessageFunc) StreamTestDefinition

StreamTestOutputOnlyOverride tests a config template without an input where duplicate IDs are sent (where we expect updates).

func StreamTestOutputOnlySendBatch

func StreamTestOutputOnlySendBatch(n int, getFn GetMessageFunc) StreamTestDefinition

StreamTestOutputOnlySendBatch tests a config template without an input.

func StreamTestOutputOnlySendSequential

func StreamTestOutputOnlySendSequential(n int, getFn GetMessageFunc) StreamTestDefinition

StreamTestOutputOnlySendSequential tests a config template without an input.

func StreamTestReceiveBatchCount

func StreamTestReceiveBatchCount(n int) StreamTestDefinition

StreamTestReceiveBatchCount tests that batches can be consumed with an input configured batch count.

func StreamTestSendBatch

func StreamTestSendBatch(n int) StreamTestDefinition

StreamTestSendBatch ensures we can send a batch of a given size.

func StreamTestSendBatchCount

func StreamTestSendBatchCount(n int) StreamTestDefinition

StreamTestSendBatchCount ensures we can send batches using a configured batch count.

func StreamTestSendBatchCountIsolated

func StreamTestSendBatchCountIsolated(n int) StreamTestDefinition

StreamTestSendBatchCountIsolated checks batches can be sent and then received. The input is created after the output has written data.

func StreamTestSendBatches

func StreamTestSendBatches(batchSize, batches, parallelism int) StreamTestDefinition

StreamTestSendBatches ensures that we can send N batches of M parallelism.

func StreamTestStreamIsolated

func StreamTestStreamIsolated(n int) StreamTestDefinition

StreamTestStreamIsolated tests that data can be sent and received, where data is sent sequentially. The input is created after the output has written data.

func StreamTestStreamParallel

func StreamTestStreamParallel(n int) StreamTestDefinition

StreamTestStreamParallel tests data transfer with parallel senders.

func StreamTestStreamParallelLossy

func StreamTestStreamParallelLossy(n int) StreamTestDefinition

StreamTestStreamParallelLossy ensures that data is delivered through parallel nacks.

func StreamTestStreamParallelLossyThroughReconnect

func StreamTestStreamParallelLossyThroughReconnect(n int) StreamTestDefinition

StreamTestStreamParallelLossyThroughReconnect ensures data is delivered through nacks and restarts.

func StreamTestStreamSaturatedUnacked

func StreamTestStreamSaturatedUnacked(n int) StreamTestDefinition

StreamTestStreamSaturatedUnacked writes N messages as a backlog, then consumes half of those messages without acking them, and then after a pause acknowledges them all and resumes consuming.

The purpose of this test is to ensure that after a period of back pressure is applied the input correctly resumes.

func StreamTestStreamSequential

func StreamTestStreamSequential(n int) StreamTestDefinition

StreamTestStreamSequential tests that data can be sent and received, where data is sent sequentially.

type StreamTestList

type StreamTestList []StreamTestDefinition

StreamTestList is a list of stream definitions that can be run with a single template and function args.

func StreamTests

func StreamTests(tests ...StreamTestDefinition) StreamTestList

StreamTests creates a list of tests from variadic arguments.

func (StreamTestList) Run

func (i StreamTestList) Run(t *testing.T, configTemplate string, opts ...StreamTestOptFunc)

Run all the tests against a config template. Tests are run in parallel.

func (StreamTestList) RunSequentially

func (i StreamTestList) RunSequentially(t *testing.T, configTemplate string, opts ...StreamTestOptFunc)

RunSequentially executes all the tests against a config template sequentially.

type StreamTestOptFunc

type StreamTestOptFunc func(*streamTestEnvironment)

StreamTestOptFunc is an opt func for customizing the behaviour of stream tests, these are useful for things that are integration environment specific, such as the port of the service being interacted with.

func StreamTestOptAllowDupes

func StreamTestOptAllowDupes() StreamTestOptFunc

StreamTestOptAllowDupes specifies across all stream tests that in this environment we can expect duplicates and these are not considered errors.

func StreamTestOptLogging

func StreamTestOptLogging(level string) StreamTestOptFunc

StreamTestOptLogging allows components to log with the given log level. This is useful for diagnosing issues.

func StreamTestOptMaxInFlight

func StreamTestOptMaxInFlight(n int) StreamTestOptFunc

StreamTestOptMaxInFlight configures a maximum inflight (to be injected into the config template) for all tests.

func StreamTestOptPort

func StreamTestOptPort(port string) StreamTestOptFunc

StreamTestOptPort defines the port of the integration service.

func StreamTestOptPortTwo

func StreamTestOptPortTwo(portTwo string) StreamTestOptFunc

StreamTestOptPortTwo defines a secondary port of the integration service.

func StreamTestOptPreTest

func StreamTestOptPreTest(fn StreamPreTestFn) StreamTestOptFunc

StreamTestOptPreTest adds a closure to be executed before each test.

func StreamTestOptSleepAfterInput

func StreamTestOptSleepAfterInput(t time.Duration) StreamTestOptFunc

StreamTestOptSleepAfterInput adds a sleep to tests after the input has been created.

func StreamTestOptSleepAfterOutput

func StreamTestOptSleepAfterOutput(t time.Duration) StreamTestOptFunc

StreamTestOptSleepAfterOutput adds a sleep to tests after the output has been created.

func StreamTestOptTimeout

func StreamTestOptTimeout(timeout time.Duration) StreamTestOptFunc

StreamTestOptTimeout describes an optional timeout spanning the entirety of the test suite.

func StreamTestOptVarOne

func StreamTestOptVarOne(v string) StreamTestOptFunc

StreamTestOptVarOne sets an arbitrary variable for the test that can be injected into templated configs.

func StreamTestOptVarThree

func StreamTestOptVarThree(v string) StreamTestOptFunc

StreamTestOptVarThree sets a third arbitrary variable for the test that can be injected into templated configs.

func StreamTestOptVarTwo

func StreamTestOptVarTwo(v string) StreamTestOptFunc

StreamTestOptVarTwo sets a second arbitrary variable for the test that can be injected into templated configs.

Jump to

Keyboard shortcuts

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