env

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const MySQLFixtureResetDDL = `` /* 614-byte string literal not displayed */

MySQLFixtureResetDDL drops and recreates the fixture in the currently selected database.

View Source
const MySQLFixtureSeedDDL = `` /* 649-byte string literal not displayed */

MySQLFixtureSeedDDL seeds the fixture in the currently selected database.

View Source
const PostgresFixtureResetDDL = `` /* 617-byte string literal not displayed */

PostgresFixtureResetDDL drops and recreates the fixture in the public schema.

View Source
const PostgresFixtureSeedDDL = `` /* 638-byte string literal not displayed */

PostgresFixtureSeedDDL seeds the fixture in the public schema.

Variables

View Source
var ErrDockerUnavailable = dockerutil.ErrUnavailable

ErrDockerUnavailable reports that no Docker-compatible container runtime could be reached. Callers turn it into a skip so that the suite behaves as documented on machines without Docker.

Functions

func CleanupIntegrationServerBinaryCache

func CleanupIntegrationServerBinaryCache()

CleanupIntegrationServerBinaryCache removes the cached integration server binary.

func DockerAvailable

func DockerAvailable(ctx context.Context) bool

DockerAvailable reports whether a Docker-compatible container runtime is reachable.

func ExternalServicesConfigured

func ExternalServicesConfigured() bool

ExternalServicesConfigured reports whether the harness was pointed at already-running services through the INTEGRATION_* variables.

func ValidateIntegrationEnv

func ValidateIntegrationEnv() error

ValidateIntegrationEnv rejects a partial external-service configuration: the harness either starts both databases with testcontainers or connects to both external services, never a mix.

Types

type ServiceEnv

type ServiceEnv struct {
	Store *store.Store

	MetadataPGURL string
	BaseURL       string
	PostgresHost  string
	PostgresPort  string
	MySQLHost     string
	MySQLPort     string
	// contains filtered or unexported fields
}

ServiceEnv owns the self-booted infrastructure and the real server process.

func StartMySQLServiceEnv

func StartMySQLServiceEnv(ctx context.Context) (*ServiceEnv, func(), error)

SetupMySQLServiceEnv starts metadata PostgreSQL, source MySQL, the real server process, and API clients. SetupPostgresServiceEnv starts metadata PostgreSQL, seeds a PostgreSQL source database on the same server, then starts the real server process and API clients. StartMySQLServiceEnv starts metadata PostgreSQL, source MySQL, and the real server process. The returned cleanup function is idempotent and should be called once the shared environment is no longer needed.

func StartPostgresServiceEnv

func StartPostgresServiceEnv(ctx context.Context) (*ServiceEnv, func(), error)

StartPostgresServiceEnv starts metadata PostgreSQL, a seeded PostgreSQL source database, and the real server process. The returned cleanup function is idempotent and should be called once the shared environment is no longer needed.

func (*ServiceEnv) AdminToken

func (e *ServiceEnv) AdminToken() string

AdminToken returns the access token of the bootstrapped first user, which is the workspace admin. It lets a test build clients for services ServiceEnv does not own.

func (*ServiceEnv) CreateDataSource

func (e *ServiceEnv) CreateDataSource(ctx context.Context, parent string, dataSource *v1pb.DataSource, dataSourceID string, validateOnly bool) (*v1pb.DataSource, error)

CreateDataSource adds a data source through the public API.

func (*ServiceEnv) CreateManualSQL

func (e *ServiceEnv) CreateManualSQL(ctx context.Context, t *testing.T, parent, manualSQLID string, manualSQL *v1pb.ManualSQL) *v1pb.ManualSQL

CreateManualSQL creates manual SQL through the public API so lineage is queued through the real service path.

func (*ServiceEnv) CreateMySQLInstance

func (e *ServiceEnv) CreateMySQLInstance(ctx context.Context, instanceID string) (*v1pb.Instance, error)

CreateMySQLInstance creates an instance against the self-booted MySQL source database.

func (*ServiceEnv) CreatePostgresInstance

func (e *ServiceEnv) CreatePostgresInstance(ctx context.Context, instanceID string) (*v1pb.Instance, error)

CreatePostgresInstance creates an instance against the PostgreSQL source database.

func (*ServiceEnv) DeleteDataSource

func (e *ServiceEnv) DeleteDataSource(ctx context.Context, name string) error

DeleteDataSource removes a data source through the public API.

func (*ServiceEnv) DeleteInstance

func (e *ServiceEnv) DeleteInstance(ctx context.Context, name string) (*emptypb.Empty, error)

DeleteInstance deletes an instance through the public API.

func (*ServiceEnv) DeleteManualSQL

func (e *ServiceEnv) DeleteManualSQL(ctx context.Context, t *testing.T, name string)

DeleteManualSQL deletes manual SQL through the public API.

func (*ServiceEnv) EnsureDatabaseVisible

func (e *ServiceEnv) EnsureDatabaseVisible(ctx context.Context, t *testing.T, instanceName, databaseName string) *v1pb.Database

EnsureDatabaseVisible returns the named database, falling back to SyncInstance once when needed.

func (*ServiceEnv) ExecMySQL

func (e *ServiceEnv) ExecMySQL(ctx context.Context, statement string) error

ExecMySQL executes SQL directly against the source MySQL server used by the scenario.

func (*ServiceEnv) ExecPostgres

func (e *ServiceEnv) ExecPostgres(ctx context.Context, databaseName, statement string) error

ExecPostgres executes SQL directly against the PostgreSQL server used by the scenario.

func (*ServiceEnv) GetInstance

func (e *ServiceEnv) GetInstance(ctx context.Context, name string) (*v1pb.Instance, error)

GetInstance reads an instance through the public API.

func (*ServiceEnv) LoginAs

func (e *ServiceEnv) LoginAs(ctx context.Context, email, password string) (string, error)

LoginAs signs in as an existing user and returns the access token.

func (*ServiceEnv) ResetMySQLSource

func (e *ServiceEnv) ResetMySQLSource(ctx context.Context) error

ResetMySQLSource restores the shared MySQL source server to the baseline schema used by the integration tests.

func (*ServiceEnv) ResetPostgresSource

func (e *ServiceEnv) ResetPostgresSource(ctx context.Context) error

ResetPostgresSource restores the shared PostgreSQL source server to the baseline schema used by the integration tests.

func (*ServiceEnv) ServerLogs

func (e *ServiceEnv) ServerLogs() string

ServerLogs returns the buffered output from the shared integration server process.

func (*ServiceEnv) SetInstanceMaximumConnections

func (e *ServiceEnv) SetInstanceMaximumConnections(ctx context.Context, instanceName string, maximum int32) error

SetInstanceMaximumConnections caps how many connections the instance may have outstanding, so a test can make two overlapping syncs of one database prove they serialize rather than each opening their own.

func (*ServiceEnv) SyncDatabase

func (e *ServiceEnv) SyncDatabase(ctx context.Context, t *testing.T, databaseName string) *v1pb.Database

SyncDatabase syncs a single database and waits until a sync that the request itself caused has landed.

A schema sync is single-flight per database, so a request that arrives while another sync of the same database is running is coalesced into it and returns its result. That running sync may have written its timestamp before this request was made, and - worse for a caller that just changed the schema - may have read the schema before that change. Two rounds settle both: the second request cannot be coalesced into the first round's sync, because the first round only ends after the timestamp that proves it finished is visible.

func (*ServiceEnv) SyncDatabaseRaw

func (e *ServiceEnv) SyncDatabaseRaw(ctx context.Context, databaseName string) error

SyncDatabaseRaw calls SyncDatabase and returns its error instead of failing the test, for scenarios that drive the failure paths.

func (*ServiceEnv) SyncInstance

func (e *ServiceEnv) SyncInstance(ctx context.Context, t *testing.T, instanceName string, enableFullSync bool) *v1pb.SyncInstanceResponse

SyncInstance explicitly refreshes the database inventory for an instance.

func (*ServiceEnv) UpdateDataSource

func (e *ServiceEnv) UpdateDataSource(ctx context.Context, name string, dataSource *v1pb.DataSource, updateMask []string, validateOnly bool) (*v1pb.DataSource, error)

UpdateDataSource writes the masked fields of one data source through the public API.

func (*ServiceEnv) WaitForContextLineage

func (e *ServiceEnv) WaitForContextLineage(ctx context.Context, t *testing.T, guid string, metaType v1pb.MetaType, predicate func([]*v1pb.LineageRelation) bool) []*v1pb.LineageRelation

WaitForContextLineage waits until the lineage API returns the expected context relations.

type TestEnv

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

TestEnv owns real DB containers and pre-wired runner dependencies. TestEnv owns the database containers started for one integration test.

Jump to

Keyboard shortcuts

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