Documentation
¶
Index ¶
- Constants
- Variables
- func AddEgressCA(t *testing.T, ctx context.Context, clients *Clients, id string) string
- func CheckEnv(keys ...string) (map[string]string, error)
- func CleanupNamespaces()
- func CollectorHasService(scrape string, services ...string) bool
- func Colorf(format string, a ...any) string
- func ConfigureCredentialProvider(t *testing.T)
- func CreateSubstrateCounterTemplate(ctx context.Context, t *testing.T, clients *Clients, namespace string, ...) *ateapi.ActorTemplate
- func CreateSubstrateTemplateFrom(ctx context.Context, t *testing.T, clients *Clients, namespace string, ...) *ateapi.ActorTemplate
- func DeployProbe(t *testing.T, name string, opts ...ProbeOption) (string, *ateapi.ActorTemplate)
- func DeploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, ...) (string, []*ateapi.ActorTemplate)
- func DescribePodState(pod *corev1.Pod) string
- func EgressAllowAll() []*ateapi.EgressRule
- func EgressAllowHTTP(patterns ...string) *ateapi.EgressRule
- func EgressAllowHTTPS(patterns ...string) *ateapi.EgressRule
- func EgressAllowPassthrough(patterns ...string) *ateapi.EgressRule
- func EgressAllowPassthroughOnPorts(ports []int32, patterns ...string) *ateapi.EgressRule
- func EgressInjectHeader(header, prefix, credentialURI string, patterns ...string) *ateapi.EgressRule
- func EgressInjectHeaderHTTP(header, prefix, credentialURI string, patterns ...string) *ateapi.EgressRule
- func EnsureEgressPolicy(t *testing.T, ctx context.Context, clients *Clients, actor *ateapi.ObjectRef, ...)
- func EnsureEgressTrustBundle(t *testing.T, ctx context.Context, clients *Clients)
- func FColorf(f io.Writer, format string, a ...any) error
- func FColorfln(f io.Writer, format string, a ...any) error
- func FindRepoRoot() (string, error)
- func FixtureName(base string) string
- func GCSRequired() bool
- func IsAgentGateway() bool
- func IsMicroVM() bool
- func KillActorSandbox(ctx context.Context, t *testing.T, clients *Clients, ...)
- func LifecycleEventSeries(scrape string) map[string]map[string]float64
- func MissingPlatformMetrics(scrape string, prefixes []string) []string
- func PreflightChecks() error
- func ReadWorkerProcessStatus(ctx context.Context, t *testing.T, clients *Clients, namespace, podName string, ...) []procstatus.Process
- func RegisterSuiteCleanup(fn func())
- func RenderFixtureManifest(t *testing.T, relPath, name string) string
- func RequireGCSBackend(t testing.TB, backend string)
- func RequirePreview(t testing.TB, gate preview.Gate)
- func RequireShortSnapshotDelays(t testing.TB, ctx context.Context, maxDelay time.Duration)
- func ResolveFixtureImage(t *testing.T, importPath string) string
- func ResourceName(name string) string
- func ResumeActorAwaitCapacity(t *testing.T, ctx context.Context, clients *Clients, ...) (*ateapi.ResumeActorResponse, error)
- func RetainNamespaces()
- func RetryAborted[Req, Resp any](t *testing.T, ctx context.Context, ...) (Resp, error)
- func RouterClientCertificate(t *testing.T, ctx context.Context, serviceAccount string) tls.Certificate
- func RouterClientSPIFFEID(serviceAccount string) string
- func RouterServerName() string
- func RouterTLSConfig(ctx context.Context, clientCert *tls.Certificate) (*tls.Config, error)
- func RunCmd(t *testing.T, name string, args ...string)
- func RunCmdOutput(t *testing.T, env []string, name string, args ...string) []byte
- func RunCmdWithEnv(t *testing.T, env []string, name string, args ...string)
- func RunTestMain(m *testing.M) int
- func SameCertificates(a, b string) bool
- func SandboxClass() string
- func ScrapeAgentGatewayRouterMetrics(ctx context.Context) (string, error)
- func ScrapeCollectorMetrics(ctx context.Context) (string, error)
- func ScrapeEgressEnvoyMetrics(ctx context.Context) (string, error)
- func ServiceDNSTrustBundle(t *testing.T, ctx context.Context, clients *Clients) string
- func SnapshotLocation(t testing.TB, prefix string) string
- func StatesNotAdvanced(before, after map[string]map[string]float64, states []string) []string
- func SystemNamespace() string
- func TargetInfoLabel(scrape, service, label string) string
- func TemplateReadyTimeout(t *testing.T) time.Duration
- func TemplateRef(at *ateapi.ActorTemplate) *ateapi.ObjectRef
- func WaitForPodReady(t *testing.T, ctx context.Context, namespace, name string, ...)
- func WaitForServerEndpoint(t *testing.T, ctx context.Context, spec ServerPod)
- func WaitForSubstrateTemplateReady(ctx context.Context, t *testing.T, clients *Clients, atespace, name string)
- type AtenetDataplane
- type Clients
- type ColorWriter
- type EgressConnectStats
- type Fixture
- type FixtureOption
- type IndentWriter
- type Namespace
- type ParkingObserver
- type ParkingStatusz
- type ProbeOption
- type RouterClient
- func (c *RouterClient) Address() string
- func (c *RouterClient) BaseURL() string
- func (c *RouterClient) Close()
- func (c *RouterClient) Connect(ctx context.Context, actorRef resources.ActorRef, port int) (net.Conn, error)
- func (c *RouterClient) ConnectPortForward(ctx context.Context) (addr string, stop func(), err error)
- func (c *RouterClient) ConnectWithHeaders(ctx context.Context, actorRef resources.ActorRef, port int, header http.Header) (net.Conn, error)
- func (c *RouterClient) Do(ctx context.Context, method string, actorRef resources.ActorRef, path string, ...) (*http.Response, error)
- func (c *RouterClient) DoReq(req *http.Request) (*http.Response, error)
- func (c *RouterClient) Get(ctx context.Context, actorRef resources.ActorRef, path string) (*http.Response, error)
- func (c *RouterClient) PostJSON(ctx context.Context, actorRef resources.ActorRef, path string, body []byte) (*http.Response, error)
- func (c *RouterClient) TLSConfig() *tls.Config
- type Server
- type ServerPod
- type StatuszClient
- type SubstrateFixture
- type SubstrateFixtureManifests
- type SubstrateTemplateOptions
Constants ¶
const ( // CredentialSecretsNamespace holds the fixture Secret and is the only // namespace the credinject fixture's authorization policy allows the probe // atespaces to resolve. CredentialSecretsNamespace = "ate-e2e-credinject-secrets" // CredentialInjectionURI resolves to CredentialInjectionToken through the // k8s-credential-provider, for the atespaces the fixture policy allows. CredentialInjectionURI = "ate-secret://k8s.io/default/" + CredentialSecretsNamespace + "/api-token/token" // CredentialInjectionToken is the fixture Secret's value, what an injected // header carries after any prefix. CredentialInjectionToken = "e2e-cred-inject-token" )
const ( RouterClientNamespace = "ate-e2e-router-client" RouterClientServiceAccount = "router-client" )
The router client's identity.
const AtenetDataplaneEnv = "E2E_ATENET_DATAPLANE"
AtenetDataplaneEnv selects the dataplane exercised by an e2e lane.
const (
EgressTrustBundleName = "egress-mitm.ate.dev"
)
The allowlisted names atelet resolves trust bundles by.
const (
// EgressTrustBundleObjectName is the reconciler-owned ClusterTrustBundle.
EgressTrustBundleObjectName = "egress-mitm.ate.dev:mitm:primary-bundle"
)
Constants of atecontroller's EgressMITMTrustReconciler (#946): the CA pool Secret it watches (the key is what `kubectl-ate admin make-ca-pool` writes) and the ClusterTrustBundle it derives from that pool — the backing object of the allowlisted "egress-mitm.ate.dev" bundle the probe fixture projects.
Suites provision the POOL and let the real reconciler publish the bundle, exercising the whole chain (pool -> reconciler -> bundle -> projection). Writing the bundle directly is not an option: the reconciler watches it and reverts or deletes hand-written contents.
const GCSRequiredEnv = "E2E_REQUIRE_GCS"
GCSRequiredEnv makes a suite that needs GCS fail, rather than skip, on an install that stores snapshots elsewhere. A GCS e2e lane sets it, so a lane misconfigured as S3 cannot pass by running nothing.
const LifecycleEventMetric = "substrate_actor_state_changes"
LifecycleEventMetric is the count connector's view of the actor lifecycle events. Reading it rather than a log store keeps this check on the metrics harness: kind has no place to query log records.
const NamespaceLabel = "ate.dev/e2e"
NamespaceLabel marks the namespaces the suites create, so leftovers from a failed run (which are kept deliberately — see RetainNamespaces) can be found and deleted later: `kubectl delete ns -l ate.dev/e2e`, or hack/cleanup-e2e.sh.
const ProbeName = "probe"
ProbeName is the name of the probe fixture's WorkerPool and ActorTemplate, inside the atespace (and matching k8s namespace) DeployProbe returns.
const ResourcePrefixEnv = "E2E_RESOURCE_PREFIX"
ResourcePrefixEnv is the prefix the install under test puts on substrate's resource names. A packaging layer that renames resources prefixes them, and the harness addresses several of those resources by name.
const SandboxClassMicroVM = "microvm"
SandboxClassMicroVM is the kata + cloud-hypervisor runtime, spelled as the WorkerPool spec.sandboxClasses[].name spells it.
const SystemNamespaceEnv = "E2E_SYSTEM_NAMESPACE"
SystemNamespaceEnv names the namespace the substrate control plane under test was installed into. It mirrors the ate-setup --namespace (ATE_NAMESPACE) the control plane was installed with.
Variables ¶
var ( RunE2E bool KubeConfig string KubeContext string StorageClass string )
var (
NoColor bool
)
noColor() disables colors for tests running in environments without colored output.
var PlatformMetricPrefixes = []string{
"ate_workerpool_workers",
"ate_workerpool_desired_workers",
"ate_workerpool_ready_workers",
"ate_actor_crashes",
"ate_actor_lifecycle_operation_duration",
"ate_scheduler_assignment_duration",
"ate_actor_restore_duration",
"ate_actor_checkpoint_duration",
"atelet_snapshot_size",
"atelet_snapshot_upload_overdue_actors",
"atelet_snapshot_undurable_age_max",
"atenet_router_route_duration",
"ate_filecache_size",
}
PlatformMetricPrefixes are the Prometheus metric-name prefixes (OTLP dots mapped to underscores) the substrate platform must emit. The Collector's prometheus exporter appends unit and type suffixes (e.g. _seconds_bucket, _bytes_count), so matching is by prefix. This slice grows as each metric slice lands and as more components are wired to push to the collector.
Functions ¶
func AddEgressCA ¶
AddEgressCA adds a fresh CA, named id, to the egress CA pool, waits for the reconciler to publish the derived bundle, and returns that bundle: what a trustBundle projection must then deliver, in any order (see SameCertificates). The new CA is trusted but never signs, so every actor keeps trusting the leaves the gateway mints, and suites doing TLS through the gateway can run alongside. The pool is put back as found when the test ends.
func CheckEnv ¶
CheckEnv checks the list of env vars exist and returns their value. If any env var is not set, it returns an error.
func CleanupNamespaces ¶
func CleanupNamespaces()
CleanupNamespaces deletes all registered namespaces using the K8s API. This should be called at the end of RunTestMain.
A backstop rather than the main path: tests release their own namespaces as they finish, so this only picks up ones whose cleanup never ran.
func CollectorHasService ¶
CollectorHasService reports whether any named service has pushed telemetry to the collector. Its prometheus exporter maps each pushed resource's service.name onto the job label, so a service that has exported at least one data point shows up there. Note the exporter never emits a service_name label, and a resource whose instruments have recorded nothing yet produces no series at all.
func Colorf ¶
Colorf renders a formatted string with color directives:
"Example text: <green>this is green</green>".
Unterminated directives will be treated as literals.
func ConfigureCredentialProvider ¶
ConfigureCredentialProvider points the install's k8s-credential-provider at the credinject fixture: the Secret behind CredentialInjectionURI and the authorization policy that lets the probe atespaces resolve it. The provider Deployment is restarted after the policy ConfigMap is applied because it reads the policy once at startup. When the test passes the fixture is removed, the shipped policy put back, and the provider restarted again so it drops the fixture's grants.
A failed test keeps the fixture so the provider's logs can be read against it; the next run re-applies it.
The provider itself and the gateway's side of the connection — the credential-provider configuration — are the install's (ate-setup --credential-provider='{"name":"k8s.io"}'), not something this helper can retrofit: the rollout wait below fails on a cluster installed without them.
func CreateSubstrateCounterTemplate ¶
func CreateSubstrateCounterTemplate(ctx context.Context, t *testing.T, clients *Clients, namespace string, opts SubstrateTemplateOptions) *ateapi.ActorTemplate
CreateSubstrateCounterTemplate creates a per-test WorkerPool CRD plus a substrate ActorTemplate copying the resolved runtime from the substrate counter demo for the sandbox class under test.
func CreateSubstrateTemplateFrom ¶
func CreateSubstrateTemplateFrom(ctx context.Context, t *testing.T, clients *Clients, namespace string, src SubstrateFixture, opts SubstrateTemplateOptions) *ateapi.ActorTemplate
CreateSubstrateTemplateFrom creates a per-test WorkerPool CRD plus a substrate ActorTemplate copying the resolved runtime (worker image, container images, sandbox size) from the installed fixture src. It registers cleanup of the template (which does not ride the k8s namespace GC the CRD templates did) and blocks until the golden snapshot exists.
func DeployProbe ¶
func DeployProbe(t *testing.T, name string, opts ...ProbeOption) (string, *ateapi.ActorTemplate)
DeployProbe builds the probe fixture image and installs the fixture for the sandbox class under test, removing it when the test ends. name distinguishes the caller (by convention its suite name): each suite gets its own copy of the fixture, so no suite's cleanup can delete the fixture out from under another running concurrently. It returns the fixture's atespace (which also names the k8s namespace holding the pool) and the created ActorTemplate, already golden-snapshotted.
func DeploySubstrateFixture ¶
func DeploySubstrateFixture(t *testing.T, ctx context.Context, clients *Clients, manifests SubstrateFixtureManifests, name string, trustBundles []string, opts ...FixtureOption) (string, []*ateapi.ActorTemplate)
DeploySubstrateFixture installs a fixture for the sandbox class under test: it ko-applies the pool manifest, creates the fixture's atespace and ActorTemplates through the ate API (ko-resolving the templates' ko:// image references first), and blocks until every template's golden snapshot exists. name distinguishes the caller (by convention its suite name): each suite gets its own copy of the fixture, so no suite's cleanup can delete it out from under another running concurrently.
Everything is removed when the test ends. The substrate resources need explicit cleanup — unlike the CRD templates they replaced, they do not ride the k8s namespace GC — and a template leaked by an interrupted earlier run is cleared before creating its replacement, since templates are immutable.
trustBundles names the trust bundles a template with a ${TEMPLATE_TRUST_BUNDLE} placeholder projects; nil projects none.
Returns the fixture's atespace (the same string that names the k8s namespace holding the pool) and the created templates.
func DescribePodState ¶
DescribePodState summarizes why a pod is not ready yet, one clause per container, for a timeout message.
func EgressAllowAll ¶
func EgressAllowAll() []*ateapi.EgressRule
EgressAllowAll is what a test that is not about egress policy gives its actor, since the gateway denies an actor with no policy at all: every name and address, as cleartext HTTP on any port and as intercepted HTTPS on 443. TLS forwarded unread is not decided by the gateway yet, and a passthrough rule on every port would tie with the http rule, which the API rejects.
func EgressAllowHTTP ¶
func EgressAllowHTTP(patterns ...string) *ateapi.EgressRule
EgressAllowHTTP is a rule that lets an actor send cleartext HTTP to the hosts matching patterns (exact names, or "*." plus a name for one leftmost label) on port 80.
func EgressAllowHTTPS ¶
func EgressAllowHTTPS(patterns ...string) *ateapi.EgressRule
EgressAllowHTTPS is a rule that lets an actor send HTTPS, intercepted by the gateway, to the hosts matching patterns on port 443.
func EgressAllowPassthrough ¶
func EgressAllowPassthrough(patterns ...string) *ateapi.EgressRule
EgressAllowPassthrough is a rule that lets an actor send TLS to the hosts matching patterns on any port, relayed by the gateway without decryption.
func EgressAllowPassthroughOnPorts ¶
func EgressAllowPassthroughOnPorts(ports []int32, patterns ...string) *ateapi.EgressRule
EgressAllowPassthroughOnPorts is EgressAllowPassthrough confined to the given ports.
func EgressInjectHeader ¶
func EgressInjectHeader(header, prefix, credentialURI string, patterns ...string) *ateapi.EgressRule
EgressInjectHeader is an https rule (see EgressAllowHTTPS) that also carries a replace_headers effect: on a match, the gateway resolves credentialURI through its credential provider and replaces header with prefix plus the credential.
func EgressInjectHeaderHTTP ¶
func EgressInjectHeaderHTTP(header, prefix, credentialURI string, patterns ...string) *ateapi.EgressRule
EgressInjectHeaderHTTP is an http rule (see EgressAllowHTTP) carrying the same credential replacement effect as EgressInjectHeader.
func EnsureEgressPolicy ¶
func EnsureEgressPolicy(t *testing.T, ctx context.Context, clients *Clients, actor *ateapi.ObjectRef, rules ...*ateapi.EgressRule)
EnsureEgressPolicy gives actor an EgressPolicy with exactly rules, replacing any it had. Deleting the actor deletes the policy, so there is no cleanup.
func EnsureEgressTrustBundle ¶
EnsureEgressTrustBundle makes sure the egress trust bundle exists, then waits until the reconciler-published bundle is non-empty. It provisions a pool only when there is none and never replaces one it finds: the pool is cluster-wide, and the egress gateway mounts the one the install created. A suite that needs to know the bundle's exact contents (the identity suite's assertions and live refresh) uses AddEgressCA.
func FColorfln ¶
FColorfln writes a formatted string with color directives to the given writer, followed by a newline.
func FindRepoRoot ¶
FindRepoRoot traverses directories upward starting from the current working directory to locate the repository root containing the go.mod file.
func FixtureName ¶
FixtureName suffixes a fixture's name for the sandbox class under test, so the gVisor and micro-VM lanes never share one. That matters most for the namespaces a suite creates and deletes itself: the two lanes run one after the other, and a namespace still Terminating from the previous one would fail the next one's apply. ${FIXTURE_SUFFIX} does the same job inside the fixture manifests.
func GCSRequired ¶
func GCSRequired() bool
GCSRequired reports whether the lane declared itself a GCS lane.
func IsAgentGateway ¶ added in v1.0.0
func IsAgentGateway() bool
IsAgentGateway reports whether the suites run against the agentgateway lane.
func IsMicroVM ¶
func IsMicroVM() bool
IsMicroVM reports whether the suites are pointed at the micro-VM fixtures. Assertions that only hold for one runtime gate on this.
func KillActorSandbox ¶
func KillActorSandbox(ctx context.Context, t *testing.T, clients *Clients, namespace, podName, actorUID string)
KillActorSandbox kills the actor's sandbox processes on its worker, the way a crash would, from an ephemeral container sharing the worker's PID namespace.
func LifecycleEventSeries ¶
LifecycleEventSeries returns each lifecycle series the collector holds, keyed by ate.actor.state and then by the series' full name and labels. The counter is cumulative and the collector outlives any one test, so compare two reads rather than asserting a state is merely present: a stale count from an earlier run would pass a presence check even with the exporter turned off.
Series are kept apart, one per emitting instance, otherwise a series the exporter expired looks like the count went down.
func MissingPlatformMetrics ¶
MissingPlatformMetrics returns the prefixes with no matching series in the Prometheus exposition text. A metric matches when its name equals a prefix or begins with prefix+"_"; the underscore boundary stops "ate_actor_restore" from matching an unrelated "ate_actor_restored".
func PreflightChecks ¶
func PreflightChecks() error
PreflightChecks checks that the test environment is ready for the test suite.
func ReadWorkerProcessStatus ¶ added in v1.0.0
func ReadWorkerProcessStatus(ctx context.Context, t *testing.T, clients *Clients, namespace, podName string, names ...string) []procstatus.Process
ReadWorkerProcessStatus reports the worker process (PID 1 of the worker container) and every process in its PID namespace whose name, the base name of argv[0], is one of names, as the kernel enforces them. The rendered PodSpec says what was asked for; this says what the container runtime actually granted.
func RegisterSuiteCleanup ¶
func RegisterSuiteCleanup(fn func())
func RenderFixtureManifest ¶
RenderFixtureManifest renders the manifest template at relPath (repo-relative, under internal/e2e/fixtures) for the sandbox class under test, writes it into the test's temp dir and returns that path. Both an apply and a later delete can then consume the same file, with no shell involved.
name distinguishes the caller (by convention its suite name) and is appended to ${FIXTURE_SUFFIX}: suite packages run as concurrent processes, so each caller must get its own copy of a fixture or one suite's cleanup deletes it out from under another.
One template serves both sandbox classes so the two variants of a fixture cannot drift apart. See renderManifest for the placeholder kinds a template can carry.
func RequireGCSBackend ¶
RequireGCSBackend skips t unless backend, the install's snapshot backend as the objectstore-plugin reports it, is GCS. Under GCSRequired it fails instead.
func RequirePreview ¶
RequirePreview skips t unless the install under test enabled gate. Tests of a preview feature call it first, so a run without the gate skips them.
func RequireShortSnapshotDelays ¶ added in v1.0.0
RequireShortSnapshotDelays skips t unless atelet runs with --snapshot-upload-delay and --snapshot-detach-delay of at most maxDelay, so t can wait for atelet to upload or detach a suspended actor's snapshot in the background. In CI it fails instead.
func ResolveFixtureImage ¶ added in v1.0.0
ResolveFixtureImage builds a fixture through the same ko resolver used by fixture manifests and returns its digest-pinned image reference.
func ResourceName ¶
ResourceName returns name as the install under test renders it.
func ResumeActorAwaitCapacity ¶
func ResumeActorAwaitCapacity(t *testing.T, ctx context.Context, clients *Clients, req *ateapi.ResumeActorRequest) (*ateapi.ResumeActorResponse, error)
ResumeActorAwaitCapacity resumes the actor, retrying while its worker pool is saturated. The control plane returns ResourceExhausted when no worker is free and expects callers to wait (the router's parking resumer retries the same condition); suites running concurrently against shared pools make that a normal state in e2e, not a failure. It also retries Aborted, as RetryAborted does. Any other error, or a retried error outlasting the wait budget, is returned to the caller. Each retry is logged so a pass that had to wait stays visible in the test output.
TODO: Add runtime diagnostic output for unscheduled pods/actors. a Pending pod's PodScheduled condition names resources the scheduler cannot satisfy. Reporting this needs no knowledge of devices a sandbox class requires. Deferred because selecting the pods requires a standard label such as the ate.dev/worker-pool label, which currently exists as two unexported constants under cmd/*/internal with different names, plus literals in three binaries. This label should be unified under internal/ first, rather than adding another copy here.
func RetainNamespaces ¶
func RetainNamespaces()
RetainNamespaces leaves the registered namespaces in the cluster and reports them, instead of deleting them. Used when the suite failed: the namespaces' worker pods hold the worker (and, for micro-VM workers, guest) logs a post-mortem needs, and they are deleted long before anyone can read them.
Passing tests have already released theirs, so what is left is the failures' — exactly what a post-mortem wants to look at.
func RetryAborted ¶ added in v1.0.0
func RetryAborted[Req, Resp any](t *testing.T, ctx context.Context, rpc func(context.Context, Req, ...grpc.CallOption) (Resp, error), req Req) (Resp, error)
RetryAborted calls rpc with req, retrying while it fails with Aborted. The control plane returns Aborted while another operation holds the actor's lease, such as applying atelet's report of a background snapshot upload. Tests call an actor's RPCs through it after an asynchronous suspend, since that report can come at any time. Any other result, or Aborted outlasting the wait, is returned to the caller.
func RouterClientCertificate ¶
func RouterClientCertificate(t *testing.T, ctx context.Context, serviceAccount string) tls.Certificate
RouterClientCertificate returns a certificate the podidentity signer issued for serviceAccount in RouterClientNamespace. Each ServiceAccount's certificate is requested once per test process, and lasts longer than any suite.
func RouterClientSPIFFEID ¶
RouterClientSPIFFEID is the SPIFFE ID the podidentity signer issues for serviceAccount in RouterClientNamespace.
func RouterServerName ¶
func RouterServerName() string
RouterServerName is the DNS name on the router's servicedns serving certificate.
func RouterTLSConfig ¶
RouterTLSConfig returns a TLS config for the router's TLS listeners that verifies the router's serving certificate and presents clientCert, which may be nil to present none. The caller sets NextProtos.
func RunCmd ¶
RunCmd executes the given command with arguments, piping stdout and stderr to standard outputs, and fails the test if the command returns an error.
func RunCmdOutput ¶
RunCmdOutput executes the given command with custom environment variables appended to the current process environment, streaming stderr like RunCmd does, and returns the captured stdout. Fails the test if the command returns an error.
func RunCmdWithEnv ¶
RunCmdWithEnv executes the given command with custom environment variables appended to the current process environment, and fails the test if it returns an error.
func RunTestMain ¶
RunTestMain should be used to run your e2e test suite.
func SameCertificates ¶
SameCertificates reports whether two bundles are the same PEM CERTIFICATE blocks and nothing else. Order is ignored: atelet shuffles a bundle's certificates every time it writes one.
func SandboxClass ¶
func SandboxClass() string
SandboxClass returns the sandbox class under test, "" for gVisor. CI sets E2E_SANDBOX_CLASS=microvm for the micro-VM lane and leaves it unset for the gVisor one, so a single knob repoints every suite's fixtures.
func ScrapeAgentGatewayRouterMetrics ¶
ScrapeAgentGatewayRouterMetrics reads the AgentGateway router's native Prometheus stats endpoint. AgentGateway instruments are not OTLP exports.
func ScrapeCollectorMetrics ¶
ScrapeCollectorMetrics port-forwards the kind stack's OTel Collector and reads its Prometheus exporter surface, returning the raw exposition text.
func ScrapeEgressEnvoyMetrics ¶
Port-forward each ready atenet-egress pod's Envoy admin port and read its stats/prometheus endpoint, returning the concatenated Prometheus exposition text.
func ServiceDNSTrustBundle ¶
ServiceDNSTrustBundle returns the service-DNS signer's roots as PEM, for a fetch that has to verify a ServiceDNSTLS server's own certificate rather than a leaf the egress gateway minted.
func SnapshotLocation ¶ added in v1.0.0
SnapshotLocation returns gs://$BUCKET_NAME/prefix/ when the install under test enabled the PerTemplateSnapshotLocation gate, and "" otherwise. Tests set it as a template's storageLocation, which the API rejects without the gate, so the gate-off lane stores snapshots under --snapshot-location.
func StatesNotAdvanced ¶
StatesNotAdvanced returns the states with no series that appeared or changed between the two reads. An empty result means every state was emitted during the window.
A drop counts, since deltatocumulative only restarts a stale stream on a new count. A series that vanished does not, the exporter expires idle series.
func SystemNamespace ¶
func SystemNamespace() string
SystemNamespace returns the namespace the control plane under test runs in, falling back to the canonical install namespace.
func TargetInfoLabel ¶
TargetInfoLabel returns one resource attribute of a service, or "" when it is absent. The Prometheus exporter keeps resource attributes off the series and publishes them once per resource in target_info, keyed by job.
func TemplateReadyTimeout ¶
TemplateReadyTimeout is how long to wait for an ActorTemplate's golden snapshot. A micro-VM golden (a cloud-hypervisor cold boot plus checkpoint, on nested KVM in CI) takes several times what a gVisor one does, so the default follows the class under test. E2E_TEMPLATE_READY_TIMEOUT overrides it.
func TemplateRef ¶
func TemplateRef(at *ateapi.ActorTemplate) *ateapi.ObjectRef
TemplateRef builds the substrate template reference an Actor carries.
func WaitForPodReady ¶
func WaitForPodReady(t *testing.T, ctx context.Context, namespace, name string, timeout time.Duration)
WaitForPodReady blocks until the pod passes its readiness probe, and fails the test with the pod's last observed state if it does not within timeout.
A suite that skipped this and dialed straight away would race the readiness probe, and a fixture that is still pulling its image or crash-looping would then be reported as whatever the code under test does with a refused connection. Reporting the container's own waiting/terminated reason instead is the whole point of the poll: it is the difference between "ImagePullBackOff" and an unexplained timeout.
func WaitForServerEndpoint ¶
WaitForServerEndpoint waits for publication of the current origin Pod as a ready Service backend. It does not perform the protocol exchange under test.
func WaitForSubstrateTemplateReady ¶
func WaitForSubstrateTemplateReady(ctx context.Context, t *testing.T, clients *Clients, atespace, name string)
WaitForSubstrateTemplateReady blocks until the substrate ActorTemplate's golden snapshot exists, returning immediately for a template that opted out of the golden snapshot. The timeout follows the sandbox class under test (see TemplateReadyTimeout).
Types ¶
type AtenetDataplane ¶
type AtenetDataplane interface {
NewParkingObserver(context.Context) (ParkingObserver, error)
IsRetryableParkingBudgetExhaustion(status int, body string) bool
ParkingBudgetStatus() int
IsEgressPolicyDenied(status int, body string) bool
PlatformMetricPrefixes([]string) []string
RouteDurationSeen(context.Context, string) (bool, error)
EgressCollectorTelemetrySeen(string) bool
ScrapeMetrics(context.Context) (string, error)
EgressConnectStats(before, after string) EgressConnectStats
}
AtenetDataplane captures the observable differences between the supported atenet dataplanes. Suites use these operations rather than branching on the selected implementation.
func CurrentAtenetDataplane ¶
func CurrentAtenetDataplane() AtenetDataplane
CurrentAtenetDataplane returns the implementation selected for this test process. Envoy remains the default to match installation defaults.
type Clients ¶
type Clients struct {
K8s *kubernetes.Clientset
CRD *apiextensionsclientset.Clientset
SubstrateK8s *versioned.Clientset
SubstrateAPI *ateclient.Client
}
func GetClients ¶
func GetClients() *Clients
GetClients returns the shared E2E clients. It panics if the clients have not been initialized.
type ColorWriter ¶
ColorWriter wraps an io.Writer and forces all writes to be colored with the given ANSI code. It respects noColor().
type EgressConnectStats ¶
EgressConnectStats holds the delta of egress CONNECT connections and requests observed between two metric scrapes. A value of -1 indicates that the dataplane does not report the counter.
type Fixture ¶
type Fixture struct {
Namespace string
Name string
// DeployWith is the ate-setup command that creates the fixture, so a
// missing one reports how to fix it rather than just failing.
DeployWith string
}
Fixture identifies an installed WorkerPool + ActorTemplate pair (both carry the same name) that suites either create Actors from directly or copy the resolved runtime — sandbox class, worker image, container images — out of.
func EgressFixture ¶
func EgressFixture() Fixture
EgressFixture returns the egress demo for the sandbox class under test. Its actors trust the CA the egress gateway mints its leaves from.
type FixtureOption ¶ added in v1.0.0
type FixtureOption func(*fixtureConfig)
FixtureOption adjusts what DeploySubstrateFixture installs.
func WithImageUser ¶ added in v1.0.0
func WithImageUser(user string) FixtureOption
WithImageUser sets user as the USER of the images ko builds for the fixture's ActorTemplates, as a Dockerfile USER line would.
func WithTemplateValue ¶ added in v1.0.0
func WithTemplateValue(name, value string) FixtureOption
WithTemplateValue replaces the inline placeholder ${name} in the fixture's ActorTemplate manifest with value.
type IndentWriter ¶
IndentWriter wraps an io.Writer and indents each line of output.
func NewIndentWriter ¶
func NewIndentWriter(w io.Writer, indent string) *IndentWriter
NewIndentWriter creates a new IndentWriter.
type Namespace ¶
type Namespace struct {
Name string
}
func CreateNamespace ¶
CreateNamespace creates a new namespace with a randomized name using the K8s API. The namespace is deleted when the test finishes, unless it failed — see the cleanup registered below.
type ParkingObserver ¶
type ParkingObserver interface {
WaitForCount(context.Context, func(int) bool) (int, error)
Close()
}
ParkingObserver waits for the dataplane's active parked-request gauge.
type ParkingStatusz ¶
type ParkingStatusz struct {
Enabled bool `json:"enabled"`
Active int `json:"active"`
MaxParked int `json:"max_parked"`
MaxWait string `json:"max_wait"`
}
ParkingStatusz mirrors the "parking" section of /statusz?format=json.
type ProbeOption ¶
type ProbeOption func(*probeConfig)
ProbeOption adjusts what DeployProbe installs.
func WithSystemRoots ¶
func WithSystemRoots() ProbeOption
WithSystemRoots adds the WebPKI roots atelet ships to the probe's projected trust file, as the egress demo's template combines them with the egress trust bundle.
func WithTrustBundle ¶
func WithTrustBundle() ProbeOption
WithTrustBundle projects the egress trust bundle into the probe's system-info volume, ensuring the cluster-scoped bundle exists first.
Only suites that test the bundle should ask for it. An actor whose template includes the bundle won't start if the bundle is missing, so a suite that just needs a probe shouldn't depend on it.
type RouterClient ¶
type RouterClient struct {
// contains filtered or unexported fields
}
RouterClient sends HTTP requests to actors through the ingress atenet-router, the same way real traffic arrives (so the request is routed and, if needed, the actor is resumed). It port-forwards the router Service, mirroring the approach in internal/ateclient.
The client presents the certificate the podidentity signer issued to RouterClientServiceAccount, which the router allowlists.
func NewRouterClient ¶
NewRouterClient establishes a port-forward to the ingress atenet-router. Call Close to tear it down.
func (*RouterClient) Address ¶
func (c *RouterClient) Address() string
Address returns the local router port-forward's host:port, for a caller that has to control the protocol it speaks to the router itself.
func (*RouterClient) BaseURL ¶
func (c *RouterClient) BaseURL() string
BaseURL returns the local router port-forward address as an https:// URL.
func (*RouterClient) Connect ¶
func (c *RouterClient) Connect(ctx context.Context, actorRef resources.ActorRef, port int) (net.Conn, error)
Connect opens a CONNECT tunnel through the router to port on actorRef, exercising atenet-router's arbitrary-port ingress support: the target port travels in the CONNECT authority (e.g. "my-actor.team-a...:9090"), the same way a real client reaches a port other than an actor's primary one. On a non-2xx response the returned error carries the status and body, mirroring egress.Client.DialContext's handling of the same failure mode on the egress side. The caller owns the returned connection and must Close it; closing it also tears down its port-forward.
func (*RouterClient) ConnectPortForward ¶ added in v1.0.0
func (c *RouterClient) ConnectPortForward(ctx context.Context) (addr string, stop func(), err error)
ConnectPortForward opens a new port-forward to the router's CONNECT listener and returns its local host:port, for a caller that has to control the protocol it speaks to the router itself. The caller must call stop.
func (*RouterClient) ConnectWithHeaders ¶
func (c *RouterClient) ConnectWithHeaders(ctx context.Context, actorRef resources.ActorRef, port int, header http.Header) (net.Conn, error)
ConnectWithHeaders is like Connect but allows specifying custom headers on the outer CONNECT request (e.g. testing repeated or missing headers).
func (*RouterClient) Do ¶
func (c *RouterClient) Do(ctx context.Context, method string, actorRef resources.ActorRef, path string, body io.Reader) (*http.Response, error)
Do issues a method request for path to actorRef through the router. The caller must close the response body.
func (*RouterClient) Get ¶
func (c *RouterClient) Get(ctx context.Context, actorRef resources.ActorRef, path string) (*http.Response, error)
Get issues GET path to actor through the router. The caller must close the body.
func (*RouterClient) PostJSON ¶
func (c *RouterClient) PostJSON(ctx context.Context, actorRef resources.ActorRef, path string, body []byte) (*http.Response, error)
PostJSON issues a POST with a JSON body to an Actor through the router. The caller must close the response body.
func (*RouterClient) TLSConfig ¶
func (c *RouterClient) TLSConfig() *tls.Config
TLSConfig returns a copy of the TLS config the client dials the router with.
type Server ¶
type Server struct {
// Name is the Service's name, which is also the Pod's.
Name string
// Namespace is the namespace the server was deployed into, for a suite that
// wants to port-forward to it or read its logs on failure.
Namespace string
// ClusterIP is the Service's address. Address dials it rather than a DNS
// name: an IP keeps a caller inside a sandbox off that sandbox's resolver,
// and makes the authority in a gateway's access log exactly what the test
// deployed. A TLS client needs the name its certificate covers instead; see
// SvcName.
ClusterIP string
Port int
// TLSPort is ServerPod.TLSPort: where the Service publishes HTTPS, or 0.
TLSPort int
}
Server is a deployed ServerPod, as the address a caller dials it at.
func CreateServerService ¶
CreateServerService reserves the origin address before its Pod starts, so callers can issue a certificate for that IP. Namespace must already exist. DeployServerPod subsequently applies the same Service without replacing it.
func DeployServerPod ¶
DeployServerPod builds spec's image, applies the shared server manifest, waits for readiness and returns the address to dial.
It registers no cleanup: everything the manifest creates is namespaced, so it goes with the namespace CreateNamespace made — and, on failure, is retained with it for `kubectl logs`.
func (Server) SvcName ¶
SvcName is the Service's <name>.<namespace>.svc, the one name a ServiceDNSTLS server's certificate covers. It resolves through the search path cluster DNS gives every pod, an actor's sandbox and the egress gateway included.
func (Server) TLSAddress ¶
TLSAddress is the host:port to dial the server's HTTPS listener at.
type ServerPod ¶
type ServerPod struct {
// Name names the Pod, its container and the Service alike, and is what
// appears in kubectl output when a test fails.
Name string
// ImportPath is the server binary's package, as a ko:// reference. The
// template's contract is that the binary takes --listen=:<port>, which is
// how one manifest serves fixtures that share nothing else.
ImportPath string
// Args are passed to the binary ahead of --listen=:<port>, which the
// template always appends. One image (internal/e2e/fixtures/testserver)
// backs every server, so this is where a caller names the subcommand that
// picks its behavior -- []string{"grpc"}, say.
Args []string
// Port is what the Service publishes, so an address a suite grafts into an
// assertion — a CONNECT authority in a gateway's access log, say — is this
// number.
Port int
// TargetPort is what the binary listens on, defaulting to Port. Set it to
// publish a port the container -- uid 65532, every capability dropped --
// cannot bind, such as 80; the Service maps Port down to it.
TargetPort int
// TLSPort, when set, publishes the HTTPS listener testserver's http and
// websocket subcommands open on container port 8443 when given a
// certificate, beside the cleartext one on Port. The readiness probe then
// checks HTTPS, the listener that needs the certificate.
TLSPort int
// Namespace deploys into an existing namespace instead of a fresh one, for
// a suite that has to populate that namespace first: credentials the pod
// mounts have to exist before it is scheduled, and DeployServerPod cannot
// hand back a namespace it has not created yet.
Namespace string
// GRPCProbe asks kubelet to probe with the gRPC health protocol instead of
// an HTTP GET. A gRPC server answers an HTTP request with a protocol error,
// so a server speaking grpc must set this and register the health service.
GRPCProbe bool
// HealthPath is the HTTP readiness path, defaulting to /healthz. Ignored
// when GRPCProbe is set.
HealthPath string
// Volumes and VolumeMounts carry whatever credentials the server needs.
// Typed, rather than more YAML in the template, so the Secret names here
// sit beside the code that creates them instead of drifting from it.
Volumes []corev1.Volume
VolumeMounts []corev1.VolumeMount
}
ServerPod describes a plain server to stand up beside the code under test: the origin an Actor's egress lands on, or the probe that dials a gateway. Everything those have in common — the pod shape, the Service, the security context — lives in the shared template, so a suite only names what differs.
func ServiceDNSTLS ¶
ServiceDNSTLS returns spec serving HTTPS as well as HTTP, with a certificate from the cluster's service-DNS signer that covers only Server.SvcName. Unless spec sets them, HTTP is on port 80 and HTTPS on 443. The server must be testserver's http or websocket subcommand.
type StatuszClient ¶
type StatuszClient struct {
// contains filtered or unexported fields
}
StatuszClient reads the atenet router's /statusz page over a port-forward, for suites that assert on router-internal state (e.g. the request-parking gauge) without going through the metrics pipeline.
func NewStatuszClient ¶
func NewStatuszClient(ctx context.Context) (*StatuszClient, error)
NewStatuszClient establishes a port-forward to the router's status port. Call Close to tear it down.
func (*StatuszClient) Parking ¶
func (c *StatuszClient) Parking(ctx context.Context) (*ParkingStatusz, error)
Parking fetches the current request-parking snapshot.
func (*StatuszClient) WaitForCount ¶
WaitForCount polls the request-parking gauge until cond holds.
type SubstrateFixture ¶
type SubstrateFixture struct {
// Atespace and Name locate the ActorTemplate for GetActorTemplate.
Atespace string
Name string
// PoolNamespace and PoolName locate the WorkerPool CRD.
PoolNamespace string
PoolName string
// DeployWith is the ate-setup command that creates the fixture, so a
// missing one reports how to fix it rather than just failing.
DeployWith string
}
SubstrateFixture identifies an installed substrate ActorTemplate (the proto resource created through the ate API, not the CRD) plus the CRD WorkerPool backing it. Suites copy the resolved runtime — container images, sandbox size — out of the template, and the worker image and sandbox class out of the pool.
func SubstrateCounterFixture ¶
func SubstrateCounterFixture() SubstrateFixture
SubstrateCounterFixture returns the substrate-resource counter demo for the sandbox class under test. E2E_SUBSTRATE_TEMPLATE_ATESPACE / E2E_SUBSTRATE_TEMPLATE_NAME / E2E_SUBSTRATE_POOL_NAMESPACE / E2E_SUBSTRATE_POOL_NAME override it, for a cluster that installs the fixture somewhere else.
type SubstrateFixtureManifests ¶
type SubstrateFixtureManifests struct {
// Pool declares the k8s side: a Namespace plus the WorkerPool CRD.
Pool string
// Template declares one or more protojson-shaped ActorTemplate
// documents, separated by ---.
Template string
}
SubstrateFixtureManifests names the two manifest templates a substrate fixture is built from (both repo-relative, under internal/e2e/fixtures).
type SubstrateTemplateOptions ¶
type SubstrateTemplateOptions struct {
// Atespace and Name locate the new template. The atespace is created if
// missing; Name must be unique within it (atespaces are shared across a
// suite's tests, unlike the k8s namespaces the CRD templates lived in).
Atespace string
Name string
// PoolName and PoolReplicas shape the WorkerPool CRD created in the test's
// k8s namespace.
PoolName string
PoolReplicas int32
// PoolTemplate configures the worker pods before the golden actor starts.
PoolTemplate *atev1.WorkerPoolPodTemplate
// SandboxConfigName, when set, pins the pool's sandbox class to that
// SandboxConfig via configRef instead of following the class default.
SandboxConfigName string
// Labels tie the template's workerSelector to the pool, keeping this
// pool's workers invisible to other namespaces' actors.
Labels map[string]string
// SnapshotConfig for the new template. nil copies the source's, with its
// own SnapshotLocation.
SnapshotConfig *ateapi.SnapshotConfig
// Modify, when set, edits the template before it is created.
Modify func(*ateapi.ActorTemplate)
}
SubstrateTemplateOptions shapes CreateSubstrateTemplateFrom.
Source Files
¶
- atenet_dataplane.go
- backend.go
- clients.go
- collector_metrics.go
- credprovider.go
- egresspolicy.go
- env.go
- fixture.go
- ingressauth.go
- manifest.go
- namespace.go
- pod.go
- preflight.go
- pretty.go
- preview.go
- probe.go
- resume.go
- retry.go
- router_client.go
- run.go
- sandbox.go
- sandboxkill.go
- serverpod.go
- snapshotdelays.go
- statusz.go
- template.go
- testmain.go
- trustbundle.go
Directories
¶
| Path | Synopsis |
|---|---|
|
fixtures
|
|
|
probe
command
Command probe is a minimal introspection actor used by the e2e suites.
|
Command probe is a minimal introspection actor used by the e2e suites. |
|
probe/nonroot
command
Command nonroot is the probe for an image with a non-root USER and a WORKDIR that user owns.
|
Command nonroot is the probe for an image with a non-root USER and a WORKDIR that user owns. |
|
testserver
command
Command testserver is the one binary behind every plain helper pod the egress e2e suites stand up.
|
Command testserver is the one binary behind every plain helper pod the egress e2e suites stand up. |
|
Package procstatus holds what the e2e testserver's procstatus subcommand prints: the kernel's view of processes on a worker, read from /proc.
|
Package procstatus holds what the e2e testserver's procstatus subcommand prints: the kernel's view of processes on a worker, read from /proc. |