auxiliary

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 40 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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
)
View Source
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.

View Source
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).

View Source
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

AllServices is the default set of shared aux services (started by Get(ctx)). Does not include ServiceTracing, ServiceFileServer, ServiceKeycloak, ServiceTrustify, ServiceModelRegistry; start on-demand.

View Source
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.

View Source
var WithHostAccess = containers.WithHostAccess

WithHostAccess adds host.containers.internal for Podman.

View Source
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

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

func HeaderSHA256(value string) string

HeaderSHA256 returns the collector log value for a received header without exposing the raw header value.

func QueryPrometheus

func QueryPrometheus(prometheusURL, query string) (*http.Response, error)

QueryPrometheus runs a PromQL query.

func RegisterContainer

func RegisterContainer(c testcontainers.Container)

RegisterContainer adds a container to the cleanup registry.

func ReloadPrometheusConfig

func ReloadPrometheusConfig(prometheusURL string) error

ReloadPrometheusConfig triggers a config reload via the lifecycle API.

func ShutdownAll

func ShutdownAll(ctx context.Context)

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

func StopServices(services []Service) error

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

type AuthenticatedEndpoint struct {
	HostPort string
	Port     string
	Username string
	Password string
}

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.

func (*FileServer) Start

func (f *FileServer) Start(ctx context.Context, network string, reuse bool) error

Start starts the file server container and sets URL, Host, Port, DataDir.

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.

func (*GitServer) Start

func (g *GitServer) Start(ctx context.Context, network string, reuse bool) error

Start starts the git server container and sets URL, Host, Port, etc.

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.

func (*Jaeger) Start

func (j *Jaeger) Start(ctx context.Context, network string, reuse bool) error

Start starts the Jaeger container and sets URL, Host, Port, OTLPEndpoint.

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

func (k *Keycloak) IssuerURL() string

IssuerURL returns the OIDC issuer URL for the flightctl realm (e.g. http://host:port/realms/flightctl).

func (*Keycloak) Start

func (k *Keycloak) Start(ctx context.Context, network string, reuse bool) error

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.

func (*Keycloak) TokenURL added in v1.4.0

func (k *Keycloak) TokenURL() string

TokenURL returns the OIDC token endpoint for the flightctl realm.

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

func (m *ModelRegistry) Start(ctx context.Context, network string, reuse bool) error

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.

func (*Prometheus) Start

func (p *Prometheus) Start(ctx context.Context, network string, reuse bool) error

Start starts the Prometheus container and sets URL, Host, Port.

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.

func (*Registry) Start

func (r *Registry) Start(ctx context.Context, network string, reuse bool) error

Start starts the TLS registry container, then the authenticated (nginx + basic auth) endpoint, and sets URL, Host, Port, Reused, Authenticated.

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 Get

func Get(ctx context.Context) *Services

Get returns the aux services, starting all of them if needed (singleton).

func StartServices

func StartServices(ctx context.Context, services []Service) (*Services, error)

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

func (s *Services) Cleanup(ctx context.Context)

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

func (s *Services) GetRegistrySSHPublicKeyPath() (string, error)

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

func (s *Services) MirrorExternalTestImages(ctx context.Context) error

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

func (s *Services) UploadCharts() error

UploadCharts uploads helm charts to the registry.

func (*Services) UploadImages

func (s *Services) UploadImages(ctx context.Context) error

UploadImages uploads all image bundles to the registry.

func (*Services) UploadQuadlets

func (s *Services) UploadQuadlets() error

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

Export records an OTLP metrics request for bounded, non-sensitive assertions.

func (*TelemetryGRPCCollector) MetricsContain added in v1.4.0

func (c *TelemetryGRPCCollector) MetricsContain(ctx context.Context, value string) (bool, error)

MetricsContain reports whether a received metric request contains the value. It checks metric names and string resource/data-point attributes only.

func (*TelemetryGRPCCollector) Stop added in v1.4.0

Stop shuts down the receiver and releases its listening socket.

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.

func (*TelemetryHTTPCollector) Logs added in v1.4.0

func (c *TelemetryHTTPCollector) Logs(ctx context.Context) (logs string, err error)

Logs returns the current collector stdout/stderr output.

func (*TelemetryHTTPCollector) Start added in v1.4.0

func (c *TelemetryHTTPCollector) Start(ctx context.Context, network string, reuse bool) error

Start starts the OTLP/HTTP collector container and sets the host-reachable endpoint used by Flight Control services.

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

func (t *Trustify) InternalURL() string

InternalURL returns the URL for container-to-container access (e.g., from flightctl-periodic).

func (*Trustify) LoadTestData

func (t *Trustify) LoadTestData(ctx context.Context) error

LoadTestData uploads SBOMs and advisories from the testdata directory to Trustify.

func (*Trustify) Start

func (t *Trustify) Start(ctx context.Context, network string, reuse bool) error

Start starts the Trustify containers (postgres + api + importer) with an internal network.

func (*Trustify) Stop

func (t *Trustify) Stop(ctx context.Context) error

Stop terminates the Trustify containers and removes the internal network.

Jump to

Keyboard shortcuts

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