Documentation
¶
Index ¶
- Constants
- Variables
- func CleanupIntegrationServerBinaryCache()
- func DockerAvailable(ctx context.Context) bool
- func ExternalServicesConfigured() bool
- func ValidateIntegrationEnv() error
- type ServiceEnv
- func (e *ServiceEnv) AdminToken() string
- func (e *ServiceEnv) CreateDataSource(ctx context.Context, parent string, dataSource *v1pb.DataSource, ...) (*v1pb.DataSource, error)
- func (e *ServiceEnv) CreateManualSQL(ctx context.Context, t *testing.T, parent, manualSQLID string, ...) *v1pb.ManualSQL
- func (e *ServiceEnv) CreateMySQLInstance(ctx context.Context, instanceID string) (*v1pb.Instance, error)
- func (e *ServiceEnv) CreatePostgresInstance(ctx context.Context, instanceID string) (*v1pb.Instance, error)
- func (e *ServiceEnv) DeleteDataSource(ctx context.Context, name string) error
- func (e *ServiceEnv) DeleteInstance(ctx context.Context, name string) (*emptypb.Empty, error)
- func (e *ServiceEnv) DeleteManualSQL(ctx context.Context, t *testing.T, name string)
- func (e *ServiceEnv) EnsureDatabaseVisible(ctx context.Context, t *testing.T, instanceName, databaseName string) *v1pb.Database
- func (e *ServiceEnv) ExecMySQL(ctx context.Context, statement string) error
- func (e *ServiceEnv) ExecPostgres(ctx context.Context, databaseName, statement string) error
- func (e *ServiceEnv) GetInstance(ctx context.Context, name string) (*v1pb.Instance, error)
- func (e *ServiceEnv) LoginAs(ctx context.Context, email, password string) (string, error)
- func (e *ServiceEnv) ResetMySQLSource(ctx context.Context) error
- func (e *ServiceEnv) ResetPostgresSource(ctx context.Context) error
- func (e *ServiceEnv) ServerLogs() string
- func (e *ServiceEnv) SetInstanceMaximumConnections(ctx context.Context, instanceName string, maximum int32) error
- func (e *ServiceEnv) SyncDatabase(ctx context.Context, t *testing.T, databaseName string) *v1pb.Database
- func (e *ServiceEnv) SyncDatabaseRaw(ctx context.Context, databaseName string) error
- func (e *ServiceEnv) SyncInstance(ctx context.Context, t *testing.T, instanceName string, enableFullSync bool) *v1pb.SyncInstanceResponse
- func (e *ServiceEnv) UpdateDataSource(ctx context.Context, name string, dataSource *v1pb.DataSource, ...) (*v1pb.DataSource, error)
- func (e *ServiceEnv) WaitForContextLineage(ctx context.Context, t *testing.T, guid string, metaType v1pb.MetaType, ...) []*v1pb.LineageRelation
- type TestEnv
Constants ¶
const MySQLFixtureResetDDL = `` /* 614-byte string literal not displayed */
MySQLFixtureResetDDL drops and recreates the fixture in the currently selected database.
const MySQLFixtureSeedDDL = `` /* 649-byte string literal not displayed */
MySQLFixtureSeedDDL seeds the fixture in the currently selected database.
const PostgresFixtureResetDDL = `` /* 617-byte string literal not displayed */
PostgresFixtureResetDDL drops and recreates the fixture in the public schema.
const PostgresFixtureSeedDDL = `` /* 638-byte string literal not displayed */
PostgresFixtureSeedDDL seeds the fixture in the public schema.
Variables ¶
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 ¶
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 ¶
DeleteInstance deletes an instance through the public API.
func (*ServiceEnv) DeleteManualSQL ¶
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 ¶
GetInstance reads an instance through the public API.
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.