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 QueryPrometheus(prometheusURL, query string) (*http.Response, error)
- func RegisterContainer(c testcontainers.Container)
- func ReloadPrometheusConfig(prometheusURL string) error
- func ShutdownAll(ctx context.Context)
- func StopServices(services []Service) error
- func StopTrustifyContainers()
- type AuthenticatedEndpoint
- type ContainerRequestOption
- type FileServer
- type GitServer
- type Jaeger
- type Keycloak
- type Prometheus
- 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 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 )
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).
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; start on-demand.
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 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 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).
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 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); auxiliary.Get skips artifact upload when Reused (see containers.ContainerRunningByName).
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.
type Services ¶
type Services struct {
Registry *Registry
GitServer *GitServer
Prometheus *Prometheus
Jaeger *Jaeger
Keycloak *Keycloak
Trustify *Trustify
FileServer *FileServer
// contains filtered or unexported fields
}
Services holds the E2E aux services (registry, git, prometheus, jaeger, keycloak, trustify, file server). 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. For registry, image bundles are uploaded when the container is freshly created (not reused).
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 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.