all

package
v0.0.0-...-9e054ec Latest Latest
Warning

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

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

Documentation

Overview

Package all contains a test rig for all services.

Index

Constants

View Source
const (
	// IntegrationEnvName is an environment variable that enables
	// integration tests for some databases. We expect this to be of the
	// format "database-v123".
	IntegrationEnvName = "CDC_INTEGRATION"
	// KafkaName must be kept in alignment with the
	// .github/docker-compose.yml file and the integration matrix
	// variable in workflows/tests.yaml.
	KafkaName = "kafka"

	// MySQLName must be kept in alignment with the
	// .github/docker-compose.yml file and the integration matrix
	// variable in workflows/tests.yaml.
	MySQLName = "mysql"
	// PostgreSQLName must be kept in alignment with the
	// .github/docker-compose.yml file and the integration matrix
	// variable in workflows/tests.yaml.
	PostgreSQLName = "postgresql"
)

Variables

TestSet contains providers to create a self-contained Fixture.

Functions

func IntegrationMain

func IntegrationMain(m *testing.M, db string)

IntegrationMain runs the tests if the value of IntegrationEnvName equals the given string, or starts with the given string, followed by a hyphen. This method calls os.Exit() and therefore never returns.

func ProvideDLQConfig

func ProvideDLQConfig() (*dlq.Config, error)

ProvideDLQConfig emits a default configuration.

func ProvideWatcher

func ProvideWatcher(target sinktest.TargetSchema, watchers types.Watchers) (types.Watcher, error)

ProvideWatcher is called by Wire to construct a Watcher bound to the testing database.

Types

type Fixture

type Fixture struct {
	*base.Fixture

	ApplyAcceptor  *apply.Acceptor
	Checkpoints    *checkpoint.Checkpoints
	Configs        *applycfg.Configs
	Diagnostics    *diag.Diagnostics
	DLQConfig      *dlq.Config
	DLQs           types.DLQs
	Memo           types.Memo
	Stagers        types.Stagers
	VersionChecker *version.Checker
	Watchers       types.Watchers

	Watcher types.Watcher // A watcher for TestDB.
}

Fixture provides a complete set of database-backed services. One can be constructed by calling NewFixture or by incorporating TestSet into a Wire provider set.

func NewFixture

func NewFixture(t testing.TB) (*Fixture, error)

NewFixture constructs a self-contained test fixture for all services in the target sub-packages.

func (*Fixture) Applier

func (f *Fixture) Applier(ctx context.Context, table ident.Table) func([]types.Mutation) error

Applier returns a bound function that will apply mutations to the given table.

func (*Fixture) CreateDLQTable

func (f *Fixture) CreateDLQTable(ctx context.Context) (ident.Table, error)

CreateDLQTable ensures that a DLQ table exists. The name of the table is returned so that tests may inspect it.

func (*Fixture) CreateTargetTable

func (f *Fixture) CreateTargetTable(
	ctx context.Context, schemaSpec string,
) (base.TableInfo[*types.TargetPool], error)

CreateTargetTable creates a test table within the TargetPool and TargetSchema. If the table is successfully created, the schema watcher will be refreshed. The schemaSpec parameter must have exactly one %s substitution parameter for the database name and table name.

func (*Fixture) PeekStaged

func (f *Fixture) PeekStaged(
	ctx context.Context, tbl ident.Table, bounds hlc.Range,
) ([]types.Mutation, error)

PeekStaged peeks at the data which has been staged for the target table between the given timestamps.

func (*Fixture) ReadStagingQuery

func (f *Fixture) ReadStagingQuery(
	ctx context.Context, q *types.StagingQuery,
) (*types.MultiBatch, error)

ReadStagingQuery executes the staging query, returning the complete result set.

Jump to

Keyboard shortcuts

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