Documentation
¶
Overview ¶
Package auxiliary provides shared testcontainer-based services for E2E tests. These run the same regardless of deployment (K8s or Quadlet): registry, git server, prometheus, jaeger. For deployment-specific infrastructure (where Flight Control runs), see the parent infra package and infra/k8s, infra/quadlet.
Index ¶
- Constants
- Variables
- func ConfigureDockerHost()
- func CreateContainer(ctx context.Context, req testcontainers.ContainerRequest, reuse bool, ...) (testcontainers.Container, error)
- func GetContainerHostname() string
- func GetDockerNetwork() string
- func GetHostIP() string
- func GetProviderType() testcontainers.ProviderType
- func HeaderSHA256(value string) string
- func QueryPrometheus(prometheusURL, query string) (*http.Response, error)
- func RegisterContainer(c testcontainers.Container)
- func ReloadPrometheusConfig(prometheusURL string) error
- func ShutdownAll(ctx context.Context)
- func StopModelRegistryContainers()
- func StopServices(services []Service) error
- func StopTrustifyContainers()
- type AuthenticatedEndpoint
- type ContainerRequestOption
- type FileServer
- type GitServer
- type Jaeger
- type Keycloak
- type MetadataStringValue
- type ModelArtifact
- type ModelRegistry
- func (m *ModelRegistry) ArchiveModelVersion(ctx context.Context, versionID string) error
- func (m *ModelRegistry) ArchiveRegisteredModel(ctx context.Context, modelID string) error
- func (m *ModelRegistry) CreateModelArtifact(ctx context.Context, versionID string, artifact ModelArtifact) (*ModelArtifact, error)
- func (m *ModelRegistry) CreateModelVersion(ctx context.Context, modelID string, version ModelVersion) (*ModelVersion, error)
- func (m *ModelRegistry) CreateRegisteredModel(ctx context.Context, model RegisteredModel) (*RegisteredModel, error)
- func (m *ModelRegistry) InternalURL() string
- func (m *ModelRegistry) Start(ctx context.Context, network string, reuse bool) error
- func (m *ModelRegistry) Stop(ctx context.Context) error
- func (m *ModelRegistry) UpdateRegisteredModel(ctx context.Context, modelID string, update RegisteredModelUpdate) (*RegisteredModel, error)
- type ModelVersion
- type Prometheus
- type RegisteredModel
- type RegisteredModelUpdate
- type Registry
- type Service
- type Services
- func (s *Services) Cleanup(ctx context.Context)
- func (s *Services) GetGitSSHPrivateKey() (util.SSHPrivateKeyContent, error)
- func (s *Services) GetGitSSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)
- func (s *Services) GetRegistrySSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)
- func (s *Services) GetRegistrySSHPublicKeyPath() (string, error)
- func (s *Services) MirrorExternalTestImages(ctx context.Context) error
- func (s *Services) UploadCharts() error
- func (s *Services) UploadImages(ctx context.Context) error
- func (s *Services) UploadQuadlets() error
- type TelemetryGRPCCollector
- func (c *TelemetryGRPCCollector) Export(_ context.Context, request *collectormetrics.ExportMetricsServiceRequest) (*collectormetrics.ExportMetricsServiceResponse, error)
- func (c *TelemetryGRPCCollector) MetricsContain(ctx context.Context, value string) (bool, error)
- func (c *TelemetryGRPCCollector) Stop(ctx context.Context) error
- type TelemetryHTTPCollector
- type Trustify
Constants ¶
const ( // KeycloakE2EClientSecret is the client secret for flightctl-client in the e2e realm. KeycloakE2EClientSecret = "e2e-flightctl-client-secret" //nolint:gosec // G101: e2e test client secret only // KeycloakE2EOAuth2ClientSecret is the client secret for the suite-owned OAuth2 client in the e2e realm. KeycloakE2EOAuth2ClientSecret = "e2e-flightctl-oauth2-client-secret" //nolint:gosec // G101: e2e test client secret only // KeycloakE2ECatalogCollectorClientID is the confidential client with a // service account (client-credentials grant) that the catalog collector // e2e suite uses to authenticate against the Flight Control API. KeycloakE2ECatalogCollectorClientID = "flightctl-catalog-collector" // KeycloakE2ECatalogCollectorSecret is the client secret for // KeycloakE2ECatalogCollectorClientID in the e2e realm. KeycloakE2ECatalogCollectorSecret = "e2e-flightctl-catalog-collector-secret" //nolint:gosec // G101: e2e test client secret only )
const ( ModelStateLive = "LIVE" ModelStateArchived = "ARCHIVED" )
Model Registry lifecycle states used by the e2e suites. The collector selects LIVE resources by default; ARCHIVED is how a seeded resource is retired, because the REST API exposes no delete for registered models or versions.
const E2EAuxHostEnv = containers.E2EAuxHostEnv
E2EAuxHostEnv is the env var to override the host used for registry/git/prometheus (e.g. when the test VM has multiple NICs and the cluster is on a different interface).
const ( // ModelRegistryAPIPath is the REST prefix the Model Registry serves and the // generated client appends on its own; the collector is configured with the // bare endpoint, while direct seeding calls need the full path. ModelRegistryAPIPath = "/api/model_registry/v1alpha3" )
Variables ¶
var AllServices = []Service{ServiceRegistry, ServiceGitServer, ServicePrometheus}
AllServices is the default set of shared aux services (started by Get(ctx)). Does not include ServiceTracing, ServiceFileServer, ServiceKeycloak, ServiceTrustify, ServiceModelRegistry; start on-demand.
var ApplyDeltaWorkerRegistryRemap func(ctx context.Context, registryURL string) error
ApplyDeltaWorkerRegistryRemap is set by infra/setup. It writes remap config through InfraProvider and restarts the delta worker and render worker through Lifecycle.
var WithHostAccess = containers.WithHostAccess
WithHostAccess adds host.containers.internal for Podman.
var WithNetwork = containers.WithNetwork
WithNetwork sets the container network.
Functions ¶
func ConfigureDockerHost ¶
func ConfigureDockerHost()
ConfigureDockerHost sets up the container runtime environment for testcontainers.
func CreateContainer ¶
func CreateContainer(ctx context.Context, req testcontainers.ContainerRequest, reuse bool, opts ...ContainerRequestOption) (testcontainers.Container, error)
CreateContainer creates and starts a container, registering it for cleanup.
func GetContainerHostname ¶
func GetContainerHostname() string
GetContainerHostname returns the hostname for host access from inside containers.
func GetDockerNetwork ¶
func GetDockerNetwork() string
GetDockerNetwork returns the network name for testcontainers (kind, host, podman, bridge).
func GetHostIP ¶
func GetHostIP() string
GetHostIP returns the host's external IP for container access.
func GetProviderType ¶
func GetProviderType() testcontainers.ProviderType
GetProviderType returns the testcontainers provider type based on the detected runtime.
func HeaderSHA256 ¶ added in v1.4.0
HeaderSHA256 returns the collector log value for a received header without exposing the raw header value.
func QueryPrometheus ¶
QueryPrometheus runs a PromQL query.
func RegisterContainer ¶
func RegisterContainer(c testcontainers.Container)
RegisterContainer adds a container to the cleanup registry.
func ReloadPrometheusConfig ¶
ReloadPrometheusConfig triggers a config reload via the lifecycle API.
func ShutdownAll ¶
ShutdownAll terminates all registered containers.
func StopModelRegistryContainers ¶ added in v1.4.0
func StopModelRegistryContainers()
StopModelRegistryContainers force-removes the Model Registry containers and network by name. Used by StopServices when no live instance is available.
func StopServices ¶
StopServices force-removes the containers for the requested aux services.
func StopTrustifyContainers ¶
func StopTrustifyContainers()
StopTrustifyContainers force-removes Trustify containers and network by name. Used by StopServices for cleanup when the Trustify instance is not available.
Types ¶
type AuthenticatedEndpoint ¶
AuthenticatedEndpoint holds connection details for the credential-required view of this registry (same backend, nginx + basic auth on another port). HostPort is for docker:// / oci:// style refs (host:port), not an OAuth issuer or login URL.
type ContainerRequestOption ¶
type ContainerRequestOption = containers.ContainerRequestOption
ContainerRequestOption is an alias for the shared containers package option type.
type FileServer ¶
type FileServer struct {
URL string
InternalURL string
Host string
Port string
DataDir string
// contains filtered or unexported fields
}
FileServer holds connection info and the container for the aux HTTP file server.
func (*FileServer) GetInternalURL ¶ added in v1.3.0
func (f *FileServer) GetInternalURL() string
GetInternalURL returns the internal (cluster-reachable) URL of the file server.
func (*FileServer) PushFile ¶
func (f *FileServer) PushFile(relativePath, content string) error
PushFile writes content to a file relative to the data directory, creating parent dirs as needed.
type GitServer ¶
type GitServer struct {
URL string
Host string
Port int
InternalHost string
InternalPort int
// contains filtered or unexported fields
}
GitServer holds connection info, SSH key path, and the container for the aux git server.
func (*GitServer) GetGitSSHPrivateKey ¶
func (g *GitServer) GetGitSSHPrivateKey() (util.SSHPrivateKeyContent, error)
GetGitSSHPrivateKey returns the SSH private key content for the git server.
func (*GitServer) GetGitSSHPrivateKeyPath ¶
func (g *GitServer) GetGitSSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)
GetGitSSHPrivateKeyPath returns the path to the SSH private key for the git server.
type Jaeger ¶
type Jaeger struct {
URL string
Host string
Port string
OTLPEndpoint string
// contains filtered or unexported fields
}
Jaeger holds connection info and the container for the aux Jaeger.
type Keycloak ¶
type Keycloak struct {
URL string
Host string
Port string
// contains filtered or unexported fields
}
Keycloak holds connection info and the container for the aux Keycloak.
func (*Keycloak) IssuerURL ¶
IssuerURL returns the OIDC issuer URL for the flightctl realm (e.g. http://host:port/realms/flightctl).
func (*Keycloak) Start ¶
Start starts the Keycloak container and sets URL, Host, Port.
flightctl-realm.json is the single declarative source for the realm, but Keycloak only imports it when it starts with an empty database. The container is shared across runs under a fixed name, so an instance an earlier run left behind keeps the realm it was created with: editing the realm file has no effect on it. After changing the realm file, run "make stop-keycloak" once and let the next run import it afresh. "make clean-aux" does not remove this container.
type MetadataStringValue ¶ added in v1.4.0
type MetadataStringValue struct {
StringValue string `json:"string_value"`
MetadataType string `json:"metadataType"`
}
MetadataStringValue is the Model Registry representation of a string-typed custom property. The metadataType discriminator is what makes the server store it as a string, and what makes "<property>.string_value = '...'" usable in a filterQuery.
func StringProperty ¶ added in v1.4.0
func StringProperty(value string) MetadataStringValue
StringProperty builds a string-typed custom property value.
type ModelArtifact ¶ added in v1.4.0
type ModelArtifact struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
ArtifactType string `json:"artifactType,omitempty"`
URI string `json:"uri,omitempty"`
State string `json:"state,omitempty"`
ModelFormatName string `json:"modelFormatName,omitempty"`
ModelFormatVersion string `json:"modelFormatVersion,omitempty"`
}
ModelArtifact is the subset of the Model Registry ModelArtifact resource the e2e suites create and assert on.
type ModelRegistry ¶ added in v1.4.0
type ModelRegistry struct {
URL string
Host string
Port string
InternalHost string
InternalPort string
// contains filtered or unexported fields
}
ModelRegistry holds connection info and containers for the aux Kubeflow Model Registry service (REST server plus its PostgreSQL database).
The service is not part of AllServices: it is only started on demand by the suites that need it (see StartServices with ServiceModelRegistry).
func (*ModelRegistry) ArchiveModelVersion ¶ added in v1.4.0
func (m *ModelRegistry) ArchiveModelVersion(ctx context.Context, versionID string) error
ArchiveModelVersion moves a model version out of the LIVE selection the collector imports.
func (*ModelRegistry) ArchiveRegisteredModel ¶ added in v1.4.0
func (m *ModelRegistry) ArchiveRegisteredModel(ctx context.Context, modelID string) error
ArchiveRegisteredModel moves a registered model out of the LIVE selection the collector imports. The REST API has no delete, so archiving is how a suite retires the data it seeded.
func (*ModelRegistry) CreateModelArtifact ¶ added in v1.4.0
func (m *ModelRegistry) CreateModelArtifact(ctx context.Context, versionID string, artifact ModelArtifact) (*ModelArtifact, error)
CreateModelArtifact attaches a LIVE model artifact to a model version and returns it with the server-assigned ID.
func (*ModelRegistry) CreateModelVersion ¶ added in v1.4.0
func (m *ModelRegistry) CreateModelVersion(ctx context.Context, modelID string, version ModelVersion) (*ModelVersion, error)
CreateModelVersion creates a LIVE version of a registered model and returns it with the server-assigned ID.
func (*ModelRegistry) CreateRegisteredModel ¶ added in v1.4.0
func (m *ModelRegistry) CreateRegisteredModel(ctx context.Context, model RegisteredModel) (*RegisteredModel, error)
CreateRegisteredModel creates a LIVE registered model and returns it with the server-assigned ID.
func (*ModelRegistry) InternalURL ¶ added in v1.4.0
func (m *ModelRegistry) InternalURL() string
InternalURL returns the URL for container-to-container access.
func (*ModelRegistry) Start ¶ added in v1.4.0
Start starts the Model Registry containers (postgres + REST server).
func (*ModelRegistry) Stop ¶ added in v1.4.0
func (m *ModelRegistry) Stop(ctx context.Context) error
Stop terminates the Model Registry containers and removes the internal network.
func (*ModelRegistry) UpdateRegisteredModel ¶ added in v1.4.0
func (m *ModelRegistry) UpdateRegisteredModel(ctx context.Context, modelID string, update RegisteredModelUpdate) (*RegisteredModel, error)
UpdateRegisteredModel patches the mutable metadata of a registered model and returns the stored result. Fields left nil in update are not sent and keep their current value, including the custom properties used for selection.
type ModelVersion ¶ added in v1.4.0
type ModelVersion struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Author string `json:"author,omitempty"`
RegisteredModelID string `json:"registeredModelId,omitempty"`
State string `json:"state,omitempty"`
}
ModelVersion is the subset of the Model Registry ModelVersion resource the e2e suites create and assert on.
type Prometheus ¶
type Prometheus struct {
URL string
Host string
Port string
// contains filtered or unexported fields
}
Prometheus holds connection info and the container for the aux Prometheus.
type RegisteredModel ¶ added in v1.4.0
type RegisteredModel struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Owner string `json:"owner,omitempty"`
State string `json:"state,omitempty"`
// CustomProperties are server-side filterable properties. Suites use them
// to scope a collector's model selection to the models they seeded, so
// that data seeded by one scenario cannot reach another.
CustomProperties map[string]MetadataStringValue `json:"customProperties,omitempty"`
}
RegisteredModel is the subset of the Model Registry RegisteredModel resource the e2e suites create and assert on.
type RegisteredModelUpdate ¶ added in v1.4.0
type RegisteredModelUpdate struct {
Description *string `json:"description,omitempty"`
Owner *string `json:"owner,omitempty"`
}
RegisteredModelUpdate is the mutable subset of a registered model.
It is deliberately not RegisteredModel: a PATCH built from that type would carry an empty, non-omitted name and rename the model on the server. Every field is a pointer so an unset one is left untouched.
type Registry ¶
type Registry struct {
URL string
Host string
Port string
// Reused is true when reuse=true and registryContainerName is already running (not merely
// present or stopped). Image bundles are still uploaded so manifests match the current bundle.
Reused bool
Authenticated AuthenticatedEndpoint
// contains filtered or unexported fields
}
Registry holds connection info and the container for the aux registry.
type Service ¶
type Service string
Service identifies an aux service that can be started individually.
const ( ServiceRegistry Service = "registry" ServiceGitServer Service = "git-server" ServicePrometheus Service = "prometheus" ServiceTracing Service = "tracing" ServiceKeycloak Service = "keycloak" ServiceTrustify Service = "trustify" ServiceModelRegistry Service = "model-registry" ServiceFileServer Service = "file-server" ServiceTelemetryHTTPCollector Service = "telemetry-http-collector" )
type Services ¶
type Services struct {
Registry *Registry
GitServer *GitServer
Prometheus *Prometheus
Jaeger *Jaeger
Keycloak *Keycloak
Trustify *Trustify
ModelRegistry *ModelRegistry
FileServer *FileServer
TelemetryHTTPCollector *TelemetryHTTPCollector
// contains filtered or unexported fields
}
Services holds the E2E aux services (registry, git, prometheus, jaeger, keycloak, trustify, model registry, file server, telemetry HTTP collector). Same for all deployment types; created once and reused. Each service is nil until started. reuse is kept so Cleanup can no-op when reuse=true (containers stay running for the next run).
func StartServices ¶
StartServices starts only the requested aux services with reuse=true. Image bundles and charts are always uploaded so fixtures match the current checkout, even when the registry was populated by an earlier run.
func (*Services) Cleanup ¶
Cleanup terminates containers when not reusing; with reuse=true containers stay running.
func (*Services) GetGitSSHPrivateKey ¶
func (s *Services) GetGitSSHPrivateKey() (util.SSHPrivateKeyContent, error)
GetGitSSHPrivateKey returns the SSH private key content for git operations.
func (*Services) GetGitSSHPrivateKeyPath ¶
func (s *Services) GetGitSSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)
GetGitSSHPrivateKeyPath returns the path to the SSH private key for git operations. The key is always the one from the aux git server container (Podman); no deployment secrets.
func (*Services) GetRegistrySSHPrivateKeyPath ¶
func (s *Services) GetRegistrySSHPrivateKeyPath() (util.SSHPrivateKeyPath, error)
GetRegistrySSHPrivateKeyPath returns the path to the pre-generated SSH private key in bin/.ssh. For registry use only. Created by create_e2e_certs.sh.
func (*Services) GetRegistrySSHPublicKeyPath ¶
GetRegistrySSHPublicKeyPath returns the path to the pre-generated SSH public key in bin/.ssh. For registry use only. Created by create_e2e_certs.sh.
func (*Services) MirrorExternalTestImages ¶ added in v1.3.0
MirrorExternalTestImages copies each image in externalTestImages from the real quay.io straight into the local registry, in parallel across images. Only called when the registry container was just created (see StartServices) - a reused registry already has these from a previous run.
func (*Services) UploadCharts ¶
UploadCharts uploads helm charts to the registry.
func (*Services) UploadImages ¶
UploadImages uploads all image bundles to the registry.
func (*Services) UploadQuadlets ¶
UploadQuadlets uploads quadlet artifacts to the registry.
type TelemetryGRPCCollector ¶ added in v1.4.0
type TelemetryGRPCCollector struct {
collectormetrics.UnimplementedMetricsServiceServer
Endpoint string
// contains filtered or unexported fields
}
TelemetryGRPCCollector is a real OTLP/gRPC metrics receiver for deployed E2E tests. It uses a local TLS certificate and records bounded request history for assertions.
func StartTelemetryGRPCCollector ¶ added in v1.4.0
func StartTelemetryGRPCCollector(ctx context.Context, timeout time.Duration) (*TelemetryGRPCCollector, error)
StartTelemetryGRPCCollector starts a TLS-enabled OTLP/gRPC metrics receiver. The endpoint is returned as a bare host:port value for gRPC transport selection.
func (*TelemetryGRPCCollector) Export ¶ added in v1.4.0
func (c *TelemetryGRPCCollector) Export(_ context.Context, request *collectormetrics.ExportMetricsServiceRequest) (*collectormetrics.ExportMetricsServiceResponse, error)
Export records an OTLP metrics request for bounded, non-sensitive assertions.
func (*TelemetryGRPCCollector) MetricsContain ¶ added in v1.4.0
MetricsContain reports whether a received metric request contains the value. It checks metric names and string resource/data-point attributes only.
type TelemetryHTTPCollector ¶ added in v1.4.0
type TelemetryHTTPCollector struct {
URL string
Endpoint string
Host string
Port string
// contains filtered or unexported fields
}
TelemetryHTTPCollector is a small OTLP/HTTP test receiver that records request paths, payload size, header hashes, and body marker matches.
func StartTelemetryHTTPCollector ¶ added in v1.4.0
func StartTelemetryHTTPCollector(ctx context.Context, timeout time.Duration) (*TelemetryHTTPCollector, error)
StartTelemetryHTTPCollector removes a stale collector and starts a receiver using the environment's runtime and network, within the supplied timeout.
type Trustify ¶
type Trustify struct {
URL string
Host string
Port string
InternalHost string
InternalPort string
// contains filtered or unexported fields
}
Trustify holds connection info and containers for the aux Trustify service.
func (*Trustify) InternalURL ¶
InternalURL returns the URL for container-to-container access (e.g., from flightctl-periodic).
func (*Trustify) LoadTestData ¶
LoadTestData uploads SBOMs and advisories from the testdata directory to Trustify.