Documentation
¶
Overview ¶
Package rt is the regression-test framework core: runtime, fixture engine, suite registry, and the concrete fixtures (namespace, manager, workload, connection, local service) suites build on.
Index ¶
- Constants
- func CleanAll(ctx context.Context) error
- func ComboName(combo map[string]string) string
- func Get[T any](t testing.TB, f *Fixture[T]) T
- func KubeConfigCopy(e Env, mutate func(*api.Config)) (string, error)
- func Main(m *testing.M)
- func ManagerClient(e Env, ns string) (manager.ManagerClient, func(), error)
- func MountRoot(a *Attach) (string, bool)
- func Mutate[T any](t testing.TB, f *Fixture[T]) T
- func Pairwise(axes []Axis, exclude func(combo map[string]string) bool) []map[string]string
- func PrivateNamespace(e Env, prefix string) string
- func PrivateUnmanagedNamespace(e Env, prefix string) string
- func ProbeUsageCollectorReachable(e Env, ns string, c *UsageCollector) (addr string, ok bool, reason string)
- func Register(s TestingSuite, opts ...RegOption)
- func RestartManager(e Env) error
- func RoutedToCluster(t testing.TB, url string, opts ...check.ReqOpt)
- func RoutedToClusterAndTapped(t testing.TB, url string, ls *LocalService, timeout time.Duration, ...)
- func RoutedToLocal(t testing.TB, url string, ls *LocalService, opts ...check.ReqOpt)
- func RunArea(t *testing.T, area string)
- func ToLocal(ls *LocalService, remote string) cli.InterceptOpt
- func WithKubeConfigExtension(e Env, ext map[string]any) (string, error)
- type Attach
- type Axis
- type Capability
- type Conn
- func (c *Conn) Disconnect(t testing.TB)
- func (c *Conn) Ingest(t testing.TB, wl *Workload, opts ...cli.InterceptOpt) *Attach
- func (c *Conn) Intercept(t testing.TB, wl *Workload, opts ...cli.InterceptOpt) *Attach
- func (c *Conn) InterceptNamed(t testing.TB, name string, wl *Workload, opts ...cli.InterceptOpt) *Attach
- func (c *Conn) List(t testing.TB) []cli.ListEntry
- func (c *Conn) ListNamespace(t testing.TB, ns string) []cli.ListEntry
- func (c *Conn) Name() string
- func (c *Conn) Replace(t testing.TB, wl *Workload, opts ...cli.InterceptOpt) *Attach
- func (c *Conn) Status(t testing.TB) *cli.Status
- func (c *Conn) Wiretap(t testing.TB, wl *Workload, opts ...cli.InterceptOpt) *Attach
- type ConnOpt
- type Env
- type Fixture
- type FixtureResult
- type Label
- type LocalService
- type ManagerHandle
- type Manifest
- type RegOption
- type Runtime
- func (r *Runtime) ArtifactDir(sub ...string) string
- func (r *Runtime) CLI() *cli.TP
- func (r *Runtime) CLIWithEnv(overrides map[string]string) *cli.TP
- func (r *Runtime) Exe() string
- func (r *Runtime) Infof(format string, args ...any)
- func (r *Runtime) IsCI() bool
- func (r *Runtime) KeepResources() bool
- func (r *Runtime) Kubectl(ctx context.Context, ns string, args ...string) (string, error)
- func (r *Runtime) KubectlJSON(ctx context.Context, ns string, out any, args ...string) error
- func (r *Runtime) ManagerVersion() semver.Version
- func (r *Runtime) Registry() string
- func (r *Runtime) UserCacheDir() string
- func (r *Runtime) Version() semver.Version
- type Suite
- func (s *Suite) AppNamespace() string
- func (s *Suite) CLI() *cli.TP
- func (s *Suite) Connect(opts ...ConnOpt) *Conn
- func (s *Suite) Ctx() context.Context
- func (s *Suite) LocalEcho() *LocalService
- func (s *Suite) Manager() *ManagerHandle
- func (s *Suite) R() *Runtime
- func (s *Suite) SetupTest()
- func (s *Suite) TearDownTest()
- func (s *Suite) Workload(tpl workloads.Template) *Workload
- type TestResult
- type TestingSuite
- type UsageCollector
- func (c *UsageCollector) Addr() string
- func (c *UsageCollector) Close()
- func (c *UsageCollector) LocalAddr() string
- func (c *UsageCollector) Port() int
- func (c *UsageCollector) Report(_ context.Context, r *usg.UsageReport) (*emptypb.Empty, error)
- func (c *UsageCollector) ReportBatch(_ context.Context, b *usg.UsageReportBatch) (*emptypb.Empty, error)
- func (c *UsageCollector) Reports() []*usg.UsageReport
- type Workload
Constants ¶
const AppNamespace = "rtest-app"
AppNamespace is the shared namespace suites use for application workloads.
Variables ¶
This section is empty.
Functions ¶
func CleanAll ¶
CleanAll deletes every resource labeled purpose=tp-rtest, uninstalls the rtest-manager helm release, and quits any running rtest daemons. It is invoked via `go run ./regression_test/framework/rtclean` (make rtest-clean). It builds a minimal Runtime directly rather than going through newRuntime/Main, since cleanup needs neither version detection nor a fresh per-run artifact directory.
func ComboName ¶
ComboName renders combo as a deterministic subtest name: keys sorted, joined "key=value,key=value,...". Both matrix consumers (golden chart rendering, live pairwise suites) use it so subtest names are stable across runs and safe to pass to `go test -run`.
func Get ¶
Get returns the memoized value for f, provisioning (or, in dev mode, adopting) it on first use under the calling test's t. A fixture that failed to provision earlier causes an immediate Skip rather than a retry.
func KubeConfigCopy ¶
KubeConfigCopy loads the run's kubeconfig, applies mutate to an in-memory copy of it, writes the result under ArtifactDir("kubeconfig"), and returns its path. Callers pass the path to ConnWithKubeconfig; connect has no --kubeconfig flag, so pointing a connection at a derived kubeconfig is done through that connection's KUBECONFIG env var instead.
func Main ¶
Main is the framework's TestMain entry point: it builds the process-global Runtime, runs the tests, tears down fixtures when due, and writes the run manifest.
func ManagerClient ¶
func ManagerClient(e Env, ns string) (manager.ManagerClient, func(), error)
ManagerClient dials the traffic-manager Service in ns (typically managers.ManagerNamespace, or a SecondaryManager's own namespace) over a port-forward, using the run's kubeconfig/context (RTEST_KUBECONFIG/ RTEST_CONTEXT via Runtime), and returns a raw manager.ManagerClient plus a close func that tears down the underlying gRPC connection. It talks to the traffic-manager directly, independent of any `telepresence connect` session -- suites use it to assert on manager RPCs (WatchWorkloads, GetClusterInfo, ...) a status/list CLI call can't observe directly, or (M4 compat work) to drive a session against a manager the CLI under test can't talk to.
Modeled on integration_test/itest/traffic_manager.go's dialTrafficManager: it resolves the traffic-manager Service to a backing pod (portforward.ResolveSvcToPod) and dials it through the k8spf:// resolver scheme (portforward.NewResolver/Dialer), which port-forwards under the hood rather than requiring the Service to be otherwise reachable.
func MountRoot ¶
MountRoot returns the local mount root path recorded in a's captured info (whichever of Intercept/Replace/Wiretap/Ingest is set): the TELEPRESENCE_ROOT entry the CLI adds to the attach's environment before printing it (pkg/client/cli/intercept/state.go's create(): s.env["TELEPRESENCE_ROOT"] = intercept.ClientMountPoint; pkg/client/cli/ingest/state.go's run(): env["TELEPRESENCE_ROOT"] = s.info.ClientMountPoint). It is the same directory `--mount` names or telepresence auto-picks, and matches os.Getenv("TELEPRESENCE_ROOT") in a `--run`/`--run-shell` child.
ok is false when a carries no captured info, or its Environment is nil. For intercept/replace/wiretap specifically, a nil Environment is possible even though TELEPRESENCE_ROOT was set: state.go aliases s.env onto the intercepted container's own (manager-reported) environment map before mutating it (s.env = intercept.Environment; s.env["TELEPRESENCE_ROOT"] = ...), so the addition only lands in the JSON output's "environment" field (pkg/client/cli/intercept/info.go's Info.Environment) when that map was already non-nil, i.e. the intercepted container itself reported at least one env var. Ingest has no such gap: ingest/state.go reassigns the map back onto Info.Environment even when it started nil, so TELEPRESENCE_ROOT is always present there.
func Mutate ¶
Mutate is like Get, but registers a t.Cleanup that invalidates the memo entry when the calling test ends, so the next Get re-provisions. A fixture's ProvisionFn must converge from any prior state (helm install-or-upgrade, apply + rollout wait, reconnect) since Mutate does not imply a fresh start.
func Pairwise ¶
Pairwise generates a deterministic, seedless set of combinations covering every pair of values across every two axes at least once -- a standard greedy all-pairs construction -- skipping any combination for which exclude returns true. exclude may be nil.
The generator enumerates the full cross product of axes (small by construction: pairwise testing only pays off for a handful of low-cardinality axes, which is what every caller in this framework uses it for), drops combinations exclude rejects, then greedily picks, at each step, the remaining combination that covers the most still-uncovered pairs. Ties are broken by cross-product order, so two calls with identical inputs return identical output (same combinations, same order). A pair that no surviving combination can satisfy (every combination containing it was excluded) is simply left uncovered; the loop still terminates because it stops as soon as no remaining combination covers anything new.
func PrivateNamespace ¶
PrivateNamespace provisions a namespace named rtest-<prefix>-<4hex>, carrying the same managed label as AppNamespace/the manager namespace, so a namespaceSelector matching that label picks it up. Unlike those shared namespaces, it is never shared across suites or adopted across runs: each call creates a fresh one, and it is always destroyed at run end, even in dev keep mode (AlwaysDestroy).
func PrivateUnmanagedNamespace ¶
PrivateUnmanagedNamespace is PrivateNamespace without the rtest.telepresence.io/managed label, for a namespace that must stay unmanaged by the shared manager (e.g. one about to get its own SecondaryManager, whose namespaceSelector would otherwise conflict with the shared manager's over that label). Same lifecycle: fresh every call, always destroyed at run end (AlwaysDestroy).
func ProbeUsageCollectorReachable ¶
func ProbeUsageCollectorReachable(e Env, ns string, c *UsageCollector) (addr string, ok bool, reason string)
ProbeUsageCollectorReachable determines whether the cluster can reach c the way a real workstation would appear to it: via host.docker.internal. It mirrors usage_reporting_test.go's skip probe exactly -- resolveHostFromCluster's nslookup, then a reachability check against c's actual port -- so a suite can self-skip on environments (e.g. non-Docker Linux container runtimes) where that address doesn't exist, exactly as the superseded suite did, rather than fail. Both probe pods run in ns (typically managers.ManagerNamespace, matching the old suite).
On success it returns the address the traffic-manager should be pointed at (managers.UsageTo) -- host.docker.internal's cluster-resolved IP, combined with c's port -- and ok=true. On failure ok is false and reason explains why, suitable for t.Skipf(reason).
func Register ¶
func Register(s TestingSuite, opts ...RegOption)
Register adds a suite to the process-wide registry. Call from an init() function in the suite's package.
func RestartManager ¶
RestartManager restarts the shared manager's Deployment and waits for the rollout to finish. A newly created or newly labeled namespace only enters the manager's namespaceSelector-managed set once its pod restarts and re-lists namespaces; there is no live pickup (product gap #4 in docs/plans/regression-test-framework/findings.md). Callers that create or label a namespace after the manager is already running must call this before anything that depends on the manager seeing it.
func RoutedToCluster ¶
RoutedToCluster asserts that url is NOT served by a LocalService: the response is a 200 whose body carries no local-service marker.
func RoutedToClusterAndTapped ¶
func RoutedToClusterAndTapped(t testing.TB, url string, ls *LocalService, timeout time.Duration, opts ...check.ReqOpt)
RoutedToClusterAndTapped asserts that url keeps being served by the cluster while a wiretap copies it to ls, by probing until one response satisfies RoutedToCluster's condition and ls has observed at least one copy.
Both halves have to be polled together. Attaching evicts the workload's pod so the webhook can inject the traffic-agent, and a Deployment's replacement pod becomes ready while the original -- which has no agent, and so copies nothing -- is still serving, so a probe answered during that window produces no copy at all. The copy is also async and lossy: the agent sends it on a background goroutine independent of the real request and response (see cmd/traffic/cmd/agent/fwd/http.go's handleHTTPRequest), so it can lag the response that triggered it.
func RoutedToLocal ¶
RoutedToLocal asserts that url is served by ls: the response carries ls's marker.
func RunArea ¶
RunArea runs every registered suite in area: filters by label env vars, sorts deterministically by (manager spec hash, suite name) to group identical manager specs, then for each suite checks its platform/ capability constraints (self-skipping with the unmet one named) before handing it to testify's suite.Run.
func ToLocal ¶
func ToLocal(ls *LocalService, remote string) cli.InterceptOpt
ToLocal builds an InterceptOpt that routes the intercept/ingest to ls's local port, matching remote (a service port name or number, as required by cli.Port).
func WithKubeConfigExtension ¶
WithKubeConfigExtension is KubeConfigCopy with mutate adding ext as the "telepresence.io" extension object on the current context's cluster entry: the client accepts also-proxy, never-proxy, dns.include-suffixes/ exclude-suffixes, and manager.namespace keys there (see pkg/client/k8s/config.go's kubeconfigExtension), mirroring the extension integration_test/itest/cluster.go:1207 used to write.
Types ¶
type Attach ¶
type Attach struct {
Intercept *cli.InterceptInfo
Ingest *cli.IngestInfo
Replace *cli.InterceptInfo
Wiretap *cli.InterceptInfo
// contains filtered or unexported fields
}
Attach is a live intercept, ingest, replace, or wiretap.
type Axis ¶
Axis is one dimension of a pairwise matrix: a name (used as the combo's map key) and the values it can take.
type Capability ¶
type Capability string
Capability names an optional host capability a suite or test may require.
const ( // Docker means `docker info` succeeds. Docker Capability = "docker" // Sudo means passwordless sudo is available. Sudo Capability = "sudo" // FUSE means a FUSE mount helper is present. FUSE Capability = "fuse" // Veth means the host can create veth pairs (Linux + Sudo). Veth Capability = "veth" )
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a live `telepresence connect` session.
func Reconnect ¶
Reconnect issues a raw, unmemoized `connect` to ns and returns the resulting *Conn. Unlike Mutate(ConnectionFixture(ns)), it always runs the connect command: a fixture only reprovisions after the test that Mutated it ends, so a second Mutate on the same (ns, no-opts) hash within one test would just return the already-memoized Conn (see docs/plans/regression-test-framework/plan.md's "Mutate is single-shot per test" note). Callers typically call this right after Mutate(ConnectionFixture(ns)).Disconnect(t) to free whatever was previously connected.
func (*Conn) Disconnect ¶
Disconnect quits this connection: all local daemons for the default connection, just the named session otherwise (quit -s stops every daemon and ignores --use).
func (*Conn) InterceptNamed ¶
func (c *Conn) InterceptNamed(t testing.TB, name string, wl *Workload, opts ...cli.InterceptOpt) *Attach
InterceptNamed attaches an intercept named name to wl, instead of the workload's own name Conn.Intercept always reuses as the intercept's positional name: for two intercepts sharing one workload, each needs a name distinct from the other and from the workload, so --workload takes over identifying the target.
func (*Conn) ListNamespace ¶
ListNamespace is List scoped to ns (`list -n <ns>`), for a workload outside the connection's default namespace: e.g. one of several namespaces a StaticNamespaces-scoped manager manages.
func (*Conn) Name ¶
Name returns the connection's --name, or "" for the default, unnamed connection.
func (*Conn) Replace ¶
Replace attaches a replace to wl: the traffic-agent replaces the application container instead of running alongside it.
type ConnOpt ¶
type ConnOpt func(*connSpec)
ConnOpt configures a connection beyond the base `telepresence connect` invocation: extra command-line arguments, environment overrides for that invocation, and metadata (name, docker mode, config dir) the fixture and the resulting Conn need afterwards. Every option that changes connection identity also extends the fixture hash, so distinct configurations never share a memoized connection.
func ConnDocker ¶
func ConnDocker() ConnOpt
ConnDocker sets --docker: the connection runs through a containerized daemon, independent of the host daemon (and of other docker connections).
func ConnExtraArgs ¶
ConnExtraArgs appends args verbatim to the connect invocation, folded into the fixture hash so a connection using them is never adopted from, or memo-shared with, a plain or differently configured connect. Use it for connect flags the framework has no dedicated ConnOpt for (e.g. --proxy-via, --allow-conflicting-subnets, --mapped-namespaces).
func ConnManagerNamespace ¶
ConnManagerNamespace overrides --manager-namespace on the connect invocation, so the connection targets a manager release living in ns instead of the shared one in managers.ManagerNamespace: a SecondaryManager (fixture_manager2.go), whose release lives in the namespace it manages rather than the shared manager's namespace. Every subsequent CLI call against the resulting Conn (list, intercept, ...) needs no equivalent override: --manager-namespace only matters at connect time, and the daemon keeps talking to whichever manager it connected to.
func ConnNamed ¶
ConnNamed sets --name on the connect invocation. The resulting Conn carries the name and passes --use <name> on every subsequent per-connection CLI call, so it (and only it) is addressed even when other connections are live.
func ConnWithConfig ¶
ConnWithConfig runs the connection's daemon under a client config variant: the run's baseline config (Runtime.baselineConfig) with delta applied on top. The resulting config's content fingerprints the fixture hash. Only one such daemon runs on the host at a time: provisioning a connection whose config dir differs from the currently running host daemon's quits that daemon first (see ensureHostConfigDir); docker-mode connections are unaffected, since each runs its own containerized daemon.
func ConnWithKubeconfig ¶
ConnWithKubeconfig sets KUBECONFIG=path for this connect invocation only. `connect` has no --kubeconfig flag; the daemon reads KUBECONFIG from its environment instead. Build path with KubeConfigCopy/WithKubeConfigExtension.
type Fixture ¶
type Fixture[T any] struct { Name string Hash string ProvisionFn func(Env) (T, error) AdoptFn func(Env) (T, bool) DestroyFn func(Env, T) error // AlwaysDestroy marks a fixture whose DestroyFn runs at the end of every // run, even in dev mode where KeepResources() would otherwise leave it // for adoption. Used for per-test ephemera (PrivateNamespace, // SecondaryManager) that must never accumulate across runs since they // are never adopted anyway. AlwaysDestroy bool }
Fixture describes one memoized resource, identified by Hash (a canonical spec hash). ProvisionFn creates it; AdoptFn (dev mode only, best-effort) reuses one left by a previous run; DestroyFn tears it down and must be idempotent.
func ConnectionFixture ¶
ConnectionFixture is a `telepresence connect` session to ns, keyed by (namespace, opts). Owns quit-on-teardown.
func ManagerFixture ¶
func ManagerFixture(spec managers.Spec) *Fixture[*ManagerHandle]
ManagerFixture is the shared rtest-manager traffic-manager release for spec. All manager specs share ONE release; switching specs is an in-place helm upgrade, so consecutive suites declaring the same spec are free.
func SecondaryManager ¶
func SecondaryManager(spec managers.Spec, ns string) *Fixture[*ManagerHandle]
SecondaryManager is a full traffic-manager release in ns (a namespace of its own, typically from PrivateNamespace), independent of the single shared release ManagerFixture owns. Used where a suite needs two managers at once (connect/Multi) or, in wave 2, a Helm-lifecycle target.
It is scoped to manage only ns (namespaceSelector matches ns by name, via the built-in kubernetes.io/metadata.name label), so it never contends with the shared manager over AppNamespace or any other labeled namespace. The client identity every connection authenticates as (connectAs) is granted cluster-wide by ManagerFixture's RBAC; this fixture ensures that RBAC exists too, in case a suite reaches for a SecondaryManager before ever provisioning the shared one.
Kept simple: always provisioned fresh, never adopted across runs, and destroyed at run end unconditionally (AlwaysDestroy), like PrivateNamespace.
func WorkloadFixture ¶
WorkloadFixture renders tpl in ns, applies it, and waits for the rollout. Keyed by (namespace, template), so two suites requesting the identical workload share it. Exported so a suite needing a workload outside the shared AppNamespace (a PrivateNamespace, or a SecondaryManager's) can call rt.Get(t, rt.WorkloadFixture(ns, tpl)) directly; Suite.Workload only covers AppNamespace, so no separate arbitrary-namespace accessor exists.
type FixtureResult ¶
type FixtureResult struct {
Name string `json:"name"`
Hash string `json:"hash"`
Action string `json:"action"` // "provisioned", "adopted", or "failed"
DurationMs int64 `json:"duration_ms"`
}
FixtureResult is one fixture action in the manifest.
type Label ¶
type Label string
Label selects subsets of tests independently of area, via RTEST_LABELS / RTEST_SKIP_LABELS (ANY-match).
type LocalService ¶
type LocalService struct {
// contains filtered or unexported fields
}
LocalService is an in-process HTTP server bound to 127.0.0.1:0. It responds to every request with a body carrying a marker unique to this instance, which RoutedToLocal asserts on. It is never memoized or adopted: every call to Suite.LocalEcho starts a fresh listener.
func (*LocalService) Marker ¶
func (ls *LocalService) Marker() string
Marker returns the response body this service always returns.
func (*LocalService) Port ¶
func (ls *LocalService) Port() int
Port returns the local TCP port the service is bound to.
func (*LocalService) Requests ¶
func (ls *LocalService) Requests() []string
Requests returns the "METHOD path" of every request this service has received since it started (or since the last ResetRequests), oldest first, capped at maxObservedRequests. Used to observe traffic a wiretap copies to this service, which RoutedToLocal/RoutedToCluster's status/body assertions can't: a wiretap is a passive copy, not something the request that triggered it waits on.
func (*LocalService) ResetRequests ¶
func (ls *LocalService) ResetRequests()
ResetRequests clears the request log.
type ManagerHandle ¶
ManagerHandle is the live traffic-manager release for the spec a suite declared via NeedsManager.
type Manifest ¶
type Manifest struct {
Run string `json:"run"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Tests []TestResult `json:"tests"`
Fixtures []FixtureResult `json:"fixtures"`
}
Manifest is the run's machine-readable summary, written to ArtifactDir()/manifest.json at the end of Main.
type RegOption ¶
type RegOption func(*registration)
RegOption configures a suite registration; pass to Register.
func NeedsManager ¶
NeedsManager declares the suite's primary manager spec. RunArea sorts suites by (spec hash, name) to minimize helm upgrades across a run.
func Requires ¶
func Requires(caps ...Capability) RegOption
Requires declares host capabilities the suite needs; unmet capabilities cause a self-skip with the missing capability named in the skip message.
func WithLabels ¶
WithLabels attaches labels used by RTEST_LABELS / RTEST_SKIP_LABELS filtering.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime is the single process-global handle to the run's configuration, directories, and logging. Obtain it via R() once rt.Main has started.
func (*Runtime) ArtifactDir ¶
ArtifactDir returns build-output/rtest/logs/<runid>/<sub...>, creating it if necessary.
func (*Runtime) CLI ¶
CLI returns a cli.TP bound to this run's binary, environment, and working directory.
func (*Runtime) CLIWithEnv ¶
CLIWithEnv is like CLI, but applies overrides (KEY -> value) on top of the run's base child environment for this one *cli.TP. Used by connection options (ConnWithConfig, ConnWithKubeconfig) that need a different KUBECONFIG or config dir for a single `connect` invocation.
func (*Runtime) Exe ¶
Exe returns the path to the telepresence binary under test: the built binary, or a downloaded release when RTEST_CLIENT_VERSION names a different version.
func (*Runtime) KeepResources ¶
KeepResources reports whether provisioned resources should be left in place at the end of the run for cross-run adoption (dev mode, unless RTEST_TEARDOWN=1 or CI forces teardown).
func (*Runtime) Kubectl ¶
Kubectl runs kubectl with the run's context and (when ns is non-empty) namespace, returning combined stdout. Stderr is included in the returned error on failure.
func (*Runtime) KubectlJSON ¶
KubectlJSON runs Kubectl with an appended `-o json` and unmarshals stdout into out.
func (*Runtime) ManagerVersion ¶
ManagerVersion returns the effective semver of the traffic-manager chart/images under test (RTEST_MANAGER_VERSION, or the built binary's own version). Independent of Version: RTEST_CLIENT_VERSION alone does not change which manager gets installed.
func (*Runtime) UserCacheDir ¶
UserCacheDir returns the directory a CLI-under-test child process resolves as its user cache (pkg/filelocation.AppUserCacheDir), given the env childEnv actually passes it: HOME (and, on windows, LOCALAPPDATA/ USERPROFILE) pass through unchanged, but no cache-dir override is set the way DEV_TELEPRESENCE_CONFIG_DIR/DEV_TELEPRESENCE_LOG_DIR pin the config and log dirs, so every daemon this run starts writes cache state -- including apply/delete's handler records, pkg/client/cli/manifest/handler.go's handlers/<daemon-info>/<name>.json -- to the host's normal telepresence cache location rather than under build-output/rtest/home. Consumed by the state area's Handler test (integration_test/state_manifest_test.go's Test_ApplyHandlerCommand) to read a handler's recorded pid/argv without importing client internals.
type Suite ¶
Suite is the base type concrete suites embed. Its accessors are lazy: each calls Get on first use, so a -run-filtered suite that never touches an accessor costs nothing. SetupSuite in suites must not provision resources directly; provisioning belongs in the accessors, called from test methods.
func (*Suite) AppNamespace ¶
AppNamespace returns the shared application namespace, creating it on first use.
func (*Suite) CLI ¶
CLI returns a cli.TP bound to this run's binary, environment, and working directory.
func (*Suite) Connect ¶
Connect returns a live connection to the suite's manager, in the app namespace, provisioning both on first use.
func (*Suite) LocalEcho ¶
func (s *Suite) LocalEcho() *LocalService
LocalEcho starts an in-process echo server on 127.0.0.1:0 for this test. It is never memoized or adopted: every call starts a fresh listener, stopped via t.Cleanup.
func (*Suite) Manager ¶
func (s *Suite) Manager() *ManagerHandle
Manager returns the handle for the suite's declared manager spec (NeedsManager at Register time), provisioning or adopting it on first use.
func (*Suite) SetupTest ¶
func (s *Suite) SetupTest()
SetupTest records the test's start time for the manifest and guarantees the suite's declared manager spec is the one installed: an earlier suite may have Mutated the shared release to a different spec, and a suite that never touches Manager()/Connect() would otherwise run against it.
func (*Suite) TearDownTest ¶
func (s *Suite) TearDownTest()
TearDownTest records the test's outcome and duration for the manifest, and on failure dumps abnormal events for namespaces this suite has touched plus daemon log tails into ArtifactDir(<test>).
type TestResult ¶
type TestResult struct {
Name string `json:"name"`
Outcome string `json:"outcome"` // "pass", "fail", or "skip"
DurationMs int64 `json:"duration_ms"`
Labels []string `json:"labels,omitempty"`
Artifacts string `json:"artifacts,omitempty"`
}
TestResult is one test's outcome in the manifest.
type TestingSuite ¶
type TestingSuite = suite.TestingSuite
TestingSuite is testify's suite interface. Concrete suites embed rt.Suite (which embeds suite.Suite), so they satisfy it automatically.
type UsageCollector ¶
type UsageCollector struct {
usg.UnimplementedUsgServer
// contains filtered or unexported fields
}
UsageCollector is an in-process gRPC server implementing the usg (rpc/v2/usg) service's Report/ReportBatch RPCs. It is the local stand-in for the real usage-reporting collector: point a manager spec's usage.collectorAddress at it (managers.UsageTo) and a client config's Usage().CollectorAddress at LocalAddr, then assert on Reports.
It listens on all interfaces (not just loopback): the traffic-manager runs inside the cluster and reaches the collector via the cluster's view of the host (see ProbeUsageCollectorReachable), which requires the listening socket to accept connections arriving from outside the host, not just 127.0.0.1. A same-host client (the CLI under test) can still dial it over loopback via LocalAddr.
func NewUsageCollector ¶
func NewUsageCollector() (*UsageCollector, error)
NewUsageCollector starts the collector and returns it; stop it with Close. Every Report/ReportBatch call the resulting server receives, including ones that race Close, is captured before the listener is torn down.
func (*UsageCollector) Addr ¶
func (c *UsageCollector) Addr() string
Addr returns the address the collector listens on: 0.0.0.0:<port>. Build a cluster-facing address around c.Port() instead (see ProbeUsageCollectorReachable); use LocalAddr for a same-host client.
func (*UsageCollector) Close ¶
func (c *UsageCollector) Close()
Close stops the collector, waiting for in-flight RPCs to complete.
func (*UsageCollector) LocalAddr ¶
func (c *UsageCollector) LocalAddr() string
LocalAddr returns the host:port a client running on this same host should dial: 127.0.0.1:<port>.
func (*UsageCollector) Port ¶
func (c *UsageCollector) Port() int
Port returns the port component of Addr.
func (*UsageCollector) Report ¶
func (c *UsageCollector) Report(_ context.Context, r *usg.UsageReport) (*emptypb.Empty, error)
Report implements usg.UsgServer.
func (*UsageCollector) ReportBatch ¶
func (c *UsageCollector) ReportBatch(_ context.Context, b *usg.UsageReportBatch) (*emptypb.Empty, error)
ReportBatch implements usg.UsgServer.
func (*UsageCollector) Reports ¶
func (c *UsageCollector) Reports() []*usg.UsageReport
Reports returns a snapshot of every report received so far (individually, or as part of a batch), in receive order.
type Workload ¶
type Workload struct {
Name string
Namespace string
Kind string
Port int
SvcName string
// ExtraPorts are the workload's named ports beyond Port ("http"), set
// for EchoMultiPort templates; nil otherwise.
ExtraPorts []workloads.NamedPort
}
Workload is the value a Workload fixture provides: enough to build a service URL, target it in an intercept/ingest, or address it with kubectl.
func (*Workload) ServiceURL ¶
ServiceURL is the cluster-DNS URL of the workload's service, reachable while connected: http://<service>.<namespace>:<port>.