framework

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GiteaAdminUser     = "e2eadmin"
	GiteaAdminPassword = "e2eAdmin12345!"
	GiteaAdminEmail    = "e2eadmin@e2e.local"
	GiteaImage         = "gitea/gitea:1.22.6"
)

Gitea credentials used by InstallGitea and the API helpers below. The values are intentionally fixed and only meaningful inside the e2e cluster — no secrets cross the cluster boundary.

View Source
const (
	ObserverNamespace = "openchoreo-observability-plane"
	ObserverService   = "observer"
	ObserverPort      = 8080

	// IngestionBudget is the upper bound the observability specs poll within
	// for backend ingestion lag (logs/metrics/traces queries) — OpenObserve
	// for logs, OpenSearch for traces. Centralised here so a CI tuning bump
	// only changes one place.
	IngestionBudget = 3 * time.Minute
)

Observer service coordinates inside the e2e cluster. Set by `_e2e.install-op` in make/e2e.mk — keep these names in sync.

View Source
const (
	Tier3GiteaNamespace          = "e2e-gitea"
	Tier3UpstreamSampleWorkloads = "https://github.com/openchoreo/sample-workloads.git"
	Tier3SampleWorkloadsRepo     = "sample-workloads"
	Tier3NoWorkloadRepo          = "no-workload-sample"
	Tier3PaketoNodeRepo          = "paketo-node-sample"
)
View Source
const (
	DefaultTimeout = 3 * time.Minute
	DefaultPolling = 2 * time.Second
)
View Source
const FluxNamespace = "flux-system"

FluxNamespace is the namespace Flux's controllers live in after InstallFlux.

View Source
const WebhookReceiverApp = "webhook-receiver"

WebhookReceiverApp is the label/app value of the in-cluster webhook receiver pod. Exposed so suites can target it with `kubectl exec`.

Variables

This section is empty.

Functions

func AcquireObserverToken added in v1.2.0

func AcquireObserverToken(q ObserverQueryFrom) (string, error)

AcquireObserverToken does a client_credentials grant against Thunder from a pod inside the cluster and returns the access token. Cached per (caller- chosen) tester pod so successive query calls in one Eventually loop don't each hammer the IdP. Tokens have a 1h validity in the e2e bootstrap, which dwarfs a Ginkgo It-block.

func ApplyGitRepository added in v1.2.0

func ApplyGitRepository(kubeContext, namespace, name, repoURL, branch string) error

ApplyGitRepository applies a Flux GitRepository pointing at the given URL. Branch defaults to "main" when empty. The poll interval is intentionally short (15s) so e2e specs don't burn time waiting for Flux to notice an edit.

func ApplyKustomization added in v1.2.0

func ApplyKustomization(kubeContext, namespace, name, sourceName, path, targetNamespace string) error

ApplyKustomization applies a Flux Kustomization that reconciles `path` (relative to the GitRepository root) into `targetNamespace`. Setting targetNamespace empty leaves each object's own metadata.namespace untouched — required when the git tree contains both CP-namespaced and other resources.

func AssertAllPodsRunning

func AssertAllPodsRunning(g gomega.Gomega, kubeContext, namespace string)

AssertAllPodsRunning checks every non-completed pod in the namespace is Running. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertClusterResourceExists added in v1.0.0

func AssertClusterResourceExists(g gomega.Gomega, kubeContext, resource, name string)

AssertClusterResourceExists checks that a cluster-scoped resource exists. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertComponentReleasePresent added in v1.2.0

func AssertComponentReleasePresent(g gomega.Gomega, kubeContext, namespace, component string)

AssertComponentReleasePresent checks that at least one ComponentRelease in the namespace has spec.owner.componentName == component. ComponentRelease has no Ready status (and no labels), so existence is the meaningful signal that the build pipeline produced a release artifact. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertHTTPRouteAccepted added in v1.2.0

func AssertHTTPRouteAccepted(g gomega.Gomega, kubeContext, namespace, name string)

AssertHTTPRouteAccepted asserts that the named HTTPRoute has at least one parent reporting Accepted=True in status.parents[].conditions.

func AssertJsonpathEquals

func AssertJsonpathEquals(g gomega.Gomega, kubeContext, namespace, resource, name, jsonpath, expected string)

AssertJsonpathEquals checks that a jsonpath value on a resource matches the expected string. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertNamespaceGone added in v1.2.0

func AssertNamespaceGone(g gomega.Gomega, kubeContext, namespace string)

AssertNamespaceGone checks that a namespace does not exist. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertPodsRunning added in v1.2.0

func AssertPodsRunning(g gomega.Gomega, kubeContext, namespace, labelSelector string)

AssertPodsRunning checks that at least one pod matches the label selector in the namespace and that every non-completed pod for that selector is in phase Running. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertReleaseBindingReady added in v1.2.0

func AssertReleaseBindingReady(g gomega.Gomega, kubeContext, namespace, name string)

AssertReleaseBindingReady checks that a ReleaseBinding has condition Ready=True. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertResourceExists

func AssertResourceExists(g gomega.Gomega, kubeContext, namespace, resource, name string)

AssertResourceExists checks that a named resource exists in the namespace. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertResourceGone added in v1.2.0

func AssertResourceGone(g gomega.Gomega, kubeContext, namespace, resource, name string)

AssertResourceGone checks that a named resource does not exist in the namespace. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertRolloutComplete added in v1.2.0

func AssertRolloutComplete(g gomega.Gomega, kubeContext, namespace, labelSelector, timeout string)

AssertRolloutComplete discovers a Deployment by label selector and waits for its rollout to finish. Returns immediately if the rollout is already complete. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertWorkflowRunCompleted added in v1.2.0

func AssertWorkflowRunCompleted(g gomega.Gomega, kubeContext, namespace, name string)

AssertWorkflowRunCompleted checks the WorkflowRun reports status.conditions[type==WorkflowCompleted].status == True. Use this when a spec wants to wait for the run to finish but does not care whether it succeeded — e.g., when a deliberately failing build is being asserted. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertWorkflowRunSucceeded added in v1.2.0

func AssertWorkflowRunSucceeded(g gomega.Gomega, kubeContext, namespace, name string)

AssertWorkflowRunSucceeded checks the WorkflowRun's status.conditions[type==WorkflowSucceeded].status == True. The controller sets this once the underlying Argo Workflow reports success. Designed for use inside Eventually(func(g Gomega) { ... }).

func AssertWorkflowTaskSucceeded added in v1.2.0

func AssertWorkflowTaskSucceeded(g gomega.Gomega, kubeContext, namespace, workflowRunName, taskName string)

AssertWorkflowTaskSucceeded checks that a named task in the WorkflowRun's status.tasks[] reached phase "Succeeded". taskName matches WorkflowTask.Name, which the controller populates from the Argo node displayName (the step name in the WorkflowTemplate, e.g. "checkout-source"). This reads OpenChoreo's own WorkflowRun surface rather than the underlying Argo Workflow, so it asserts an individual build stage without reaching into the workflow-plane namespace. Designed for use inside Eventually(func(g Gomega) { ... }).

func CallMCPTool added in v1.2.0

func CallMCPTool(session *mcp.ClientSession, toolName string, args map[string]any) (*mcp.CallToolResult, error)

CallMCPTool calls a named tool with the given arguments and returns the result. Returns an error if the tool call fails or the tool itself returns an error.

func CallMCPToolExpectDenied added in v1.2.0

func CallMCPToolExpectDenied(session *mcp.ClientSession, toolName string, args map[string]any, wantSubstring string) error

CallMCPToolExpectDenied calls the tool and asserts the call fails with an error containing wantSubstring. It returns the error for further inspection. Covers both denial surfaces: the JSON-RPC method error from the CP tool-filter middleware (pkg/mcp/tools/filter.go:174), and the IsError tool result when the service layer denies — CallMCPTool surfaces both as a non-nil error whose message contains the denial text.

func CallMCPToolJSON added in v1.2.0

func CallMCPToolJSON(session *mcp.ClientSession, toolName string, args map[string]any, dest any) error

CallMCPToolJSON calls a named tool and unmarshals the first text content into dest.

func CheckTCPReachableFromPodByLabel added in v1.2.0

func CheckTCPReachableFromPodByLabel(kubeContext, namespace, labelSelector, container, host, port string, timeoutSeconds int) (string, error)

CheckTCPReachableFromPodByLabel resolves a Running pod by label selector and runs `nc -z -w <seconds> <host> <port>` from the given container. Returns the combined output and the exec error. nc exits 0 if the TCP port is reachable, non-zero otherwise. Use this when the workload may respond with any HTTP status (e.g. 404 on /) and you only care about TCP reachability.

func ClusterAuthzRoleBindingYAML added in v1.2.0

func ClusterAuthzRoleBindingYAML(name, labelKey, labelValue, roleName, subject, effect string) string

ClusterAuthzRoleBindingYAML renders a ClusterAuthzRoleBinding mapping the entitlement claim `sub` == subject to the named ClusterAuthzRole. effect is "allow" or "deny".

func ClusterAuthzRoleYAML added in v1.2.0

func ClusterAuthzRoleYAML(name, labelKey, labelValue string, actions []string) string

ClusterAuthzRoleYAML renders a ClusterAuthzRole with the given actions and an arbitrary label (key/value) for cleanup selectors.

func CountHTTPRoutesByLabel added in v1.2.0

func CountHTTPRoutesByLabel(kubeContext, namespace, labelSelector string) (int, error)

CountHTTPRoutesByLabel returns the number of HTTPRoutes matching a label selector.

func DeleteClusterAuthzRoleBindingAndWaitForRevocation added in v1.2.0

func DeleteClusterAuthzRoleBindingAndWaitForRevocation(kubeContext, name string, probe func() bool)

DeleteClusterAuthzRoleBindingAndWaitForRevocation deletes the binding and polls probe() (which must return true once the subject is denied again) until the Casbin PDP has observed the revocation. Mirrors test/e2e/suites/authz/authz_test.go:23-32.

func DeniedProbe added in v1.2.0

func DeniedProbe(session *mcp.ClientSession, toolName string, args map[string]any, wantSubstring string, onUnexpectedSuccess func()) func() bool

DeniedProbe builds a probe for DeleteClusterAuthzRoleBindingAndWaitForRevocation: it calls toolName and returns true once the resulting error contains wantSubstring (i.e. the subject is denied again). If the call unexpectedly succeeds (still authorized), it runs onUnexpectedSuccess — pass nil for read-only tools that create nothing — and returns false to keep waiting. Centralizing the cleanup-on-success branch keeps a stray probe resource from colliding on the next poll.

func DeployWebhookReceiver added in v1.2.0

func DeployWebhookReceiver(kubeContext, namespace string) error

DeployWebhookReceiver applies the receiver manifest into the given namespace and waits for the pod to be Ready. The receiver listens on `:8080` inside its pod; the in-cluster URL is `http://webhook-receiver.<namespace>.svc.cluster.local:8080`.

func EnsureGiteaRepo added in v1.2.0

func EnsureGiteaRepo(kubeContext, giteaNamespace, repoName string) error

EnsureGiteaRepo creates an empty repo under the admin user if it does not exist. It accepts a 409 conflict response (repo already exists) as success.

func EnsureTier3BuildSources added in v1.2.0

func EnsureTier3BuildSources(kubeContext string) error

EnsureTier3BuildSources extends EnsureTier3SampleWorkloads with the local build fixture repositories used by the Tier 3 build matrix.

func EnsureTier3SampleWorkloads added in v1.2.0

func EnsureTier3SampleWorkloads(kubeContext string) error

EnsureTier3SampleWorkloads ensures the shared Tier 3 Gitea install and sample-workloads mirror exist in the current e2e cluster. The fixture is intentionally scoped to one k3d cluster/job; it never crosses CI tiers.

func FetchClientCredentialsToken added in v1.2.0

func FetchClientCredentialsToken(tokenEndpoint, clientID, clientSecret string) (string, error)

FetchClientCredentialsToken obtains an access token via the OAuth2 client_credentials grant from the given token endpoint.

func FetchOAuth2Token added in v1.2.0

func FetchOAuth2Token(tokenURL, clientID, clientSecret string) (string, error)

FetchOAuth2Token requests an access token from the Thunder IdP using client_credentials grant with HTTP Basic auth (client_secret_basic).

func GenerateHTTPTraffic added in v1.2.0

func GenerateHTTPTraffic(kubeContext, namespace, podLabel, container, targetURL, marker string, rps, durationSec int) (string, error)

GenerateHTTPTraffic runs a fire-and-forget request loop from a Running pod to a target URL. It blocks for roughly `durationSec * rps` requests (modulo sleep granularity) so the caller knows when traffic generation has settled.

Implementation: a single `kubectl exec` runs a tiny `sh -c` loop in the tester pod. We use busybox-compatible `sleep` with float seconds (`0.05`) because the Alpine sh in our usual tester images accepts it. The loop emits a per-request log line with a known marker token so the logs-queryable spec can search for it.

func GetDPNamespace added in v0.17.0

func GetDPNamespace(kubeContext, cpNamespace, project, environment string) (string, error)

GetDPNamespace discovers a data plane namespace by its control plane labels. DP namespace names include a hash suffix and cannot be predicted, so we query by label selectors instead.

func GetHTTPRouteNames added in v1.2.0

func GetHTTPRouteNames(kubeContext, namespace, labelSelector string) ([]string, error)

GetHTTPRouteNames returns the names of HTTPRoutes matching a label selector.

func GiteaInClusterURL added in v1.2.0

func GiteaInClusterURL(namespace string) string

GiteaInClusterURL returns the http:// URL the builder pods use to reach the Gitea HTTP service from inside the cluster.

func GiteaRepoCloneURL added in v1.2.0

func GiteaRepoCloneURL(namespace, repoName string) string

GiteaRepoCloneURL returns the clone URL for a repo owned by the e2e admin user in the in-cluster Gitea. Suitable for ClusterWorkflow `repository.url`.

func InstallFlux added in v1.2.0

func InstallFlux(kubeContext string) error

InstallFlux applies the upstream Flux v2 install bundle (CRDs + source + kustomize controllers) and waits for the core deployments to reach Available. We do not need the helm/notification controllers for the gitops suite, but applying the bundle is the path of least resistance.

func InstallGitea added in v1.2.0

func InstallGitea(kubeContext, namespace string) error

InstallGitea applies a minimal single-replica Gitea Deployment + Service into the given namespace, waits for it to come up, and creates the admin user used by the rest of the helper API. Idempotent — re-running is a no-op once the deployment is Ready and the admin user exists.

func IntPtr added in v1.2.0

func IntPtr(i int) *int

IntPtr mirrors StringPtr for int-valued query fields.

func InvokeFromPodByLabel added in v1.2.0

func InvokeFromPodByLabel(kubeContext, namespace, labelSelector, container, url string, timeoutSeconds int) (string, error)

InvokeFromPodByLabel resolves a Running pod by label selector and runs `wget -q -O /dev/null -T <seconds> <url>` from the given container. Returns the combined wget output (empty on success) and the exec error. BusyBox-compatible (uses `-T` not `--timeout`). Treats non-2xx HTTP responses as failures, so this is suitable when callers expect 2xx. Use CheckTCPReachableFromPodByLabel for plain TCP reachability checks.

func Kubectl

func Kubectl(kubeContext string, args ...string) (string, error)

Kubectl executes an arbitrary kubectl command with the given context. Returns trimmed combined output (stdout+stderr) and any error.

func KubectlApplyLiteral added in v0.17.0

func KubectlApplyLiteral(kubeContext, yamlContent string) (string, error)

KubectlApplyLiteral pipes yamlContent to: kubectl apply -f -

func KubectlDeleteLiteral added in v0.17.0

func KubectlDeleteLiteral(kubeContext, yamlContent string) (string, error)

KubectlDeleteLiteral pipes yamlContent to: kubectl delete --ignore-not-found -f -

func KubectlExec added in v0.17.0

func KubectlExec(kubeContext, namespace, pod, container string, command ...string) (string, error)

KubectlExec runs: kubectl exec <pod> -n <namespace> [-c <container>] -- <command...>

func KubectlExecByLabel added in v0.17.0

func KubectlExecByLabel(kubeContext, namespace, labelSelector, container string, command ...string) (string, error)

KubectlExecByLabel finds a Running pod by label selector and execs a command in it. This is useful for OC-managed pods whose names are generated by Deployments.

func KubectlGet

func KubectlGet(kubeContext, namespace, resource string, extraArgs ...string) (string, error)

KubectlGet runs: kubectl get <resource> -n <namespace> [extraArgs...]

func KubectlGetJsonpath

func KubectlGetJsonpath(kubeContext, namespace, resource, name, jsonpath string) (string, error)

KubectlGetJsonpath runs: kubectl get <resource> <name> -n <namespace> -o jsonpath=<expr>

func KubectlLogs

func KubectlLogs(kubeContext, namespace, labelSelector string, tail int) (string, error)

KubectlLogs runs: kubectl logs -n <namespace> -l <labelSelector> --tail=<tail>

func KubectlRolloutRestart added in v0.17.0

func KubectlRolloutRestart(kubeContext, namespace, resource string) error

KubectlRolloutRestart runs: kubectl rollout restart <resource> -n <namespace> and then waits for the rollout to complete.

func KubectlRolloutStatus added in v1.2.0

func KubectlRolloutStatus(kubeContext, namespace, resource, timeout string) error

KubectlRolloutStatus runs: kubectl rollout status <resource> -n <namespace> --timeout=<timeout> Returns nil immediately if the rollout is already complete.

func ListMCPToolNames added in v1.2.0

func ListMCPToolNames(session *mcp.ClientSession) ([]string, error)

ListMCPToolNames lists tools and returns just the tool names.

func LoadGenMarker added in v1.2.0

func LoadGenMarker(prefix string) string

LoadGenMarker returns a unique marker token suitable for both shell loops and observability backend search phrases (OpenObserve logs, OpenSearch traces). Suites should call this once per spec and keep the value for the polling assertion.

func MCPRawPOST added in v1.2.0

func MCPRawPOST(endpoint string) (int, http.Header, error)

MCPRawPOST sends a raw HTTP POST to the MCP endpoint without any token. Useful for testing unauthenticated access (401 response).

func MigrateRepo added in v1.2.0

func MigrateRepo(kubeContext, giteaNamespace, repoName, cloneAddr string) error

MigrateRepo asks Gitea to clone an upstream HTTPS git URL into the admin user's namespace. Suitable for mirroring openchoreo/sample-workloads into the in-cluster Gitea so the build matrix is self-contained.

func NewMCPSession added in v1.2.0

func NewMCPSession(ctx context.Context, cfg MCPClientConfig) (*mcp.ClientSession, error)

NewMCPSession creates an MCP client session connected to the given endpoint. The caller must close the returned session when done.

func PushFile added in v1.2.0

func PushFile(kubeContext, giteaNamespace, repoName, branch, relPath string, content []byte, commitMessage string) error

PushFile upserts a single file in a Gitea repo on the given branch. content is the raw file body (no base64 needed — the helper handles that). When `commitMessage` is empty a default is used.

func PushTree added in v1.2.0

func PushTree(kubeContext, giteaNamespace, repoName, branch, sourceDir string) error

PushTree walks sourceDir on the local filesystem and pushes every regular file under it into repoName at the same relative path on `branch`. Skips .git and any dotfiles at the top level. Files are pushed sequentially to keep individual API calls small and predictable; a multi-file tree of a handful of YAMLs takes a few seconds.

func RandSuffix added in v1.2.0

func RandSuffix(n int) string

RandSuffix returns a lowercase hex string of the requested length. Used by the observability and alerts suites to mint marker tokens that won't collide with anything else in the observability backend (OpenObserve logs, OpenSearch traces).

func ReceivedNotifications added in v1.2.0

func ReceivedNotifications(kubeContext, namespace string) ([]string, error)

ReceivedNotifications returns all webhook request bodies the receiver has observed since startup, oldest first. mendhak/http-https-echo emits one JSON line per request to stdout; this helper greps for those lines and extracts the `body` field. The framework returns the body as a string so callers can either treat it as opaque or unmarshal it themselves.

func RepoRoot added in v1.2.0

func RepoRoot() (string, error)

RepoRoot returns the absolute path of the OpenChoreo checkout by walking up from this file's location until it finds a `go.mod`. Suites use this to apply files under `samples/` regardless of where `go test` was invoked.

func ScopedClusterAuthzRoleBindingYAML added in v1.2.0

func ScopedClusterAuthzRoleBindingYAML(name, labelKey, labelValue, roleName, subject, effect, scopeNamespace string) string

ScopedClusterAuthzRoleBindingYAML is ClusterAuthzRoleBindingYAML with a `scope.namespace` restriction on the role mapping.

func StringPtr added in v1.2.0

func StringPtr(s string) *string

StringPtr is a tiny convenience to avoid scattering `s := "x"; &s` patterns at the call sites of the query helpers.

func WaitForHTTP added in v1.2.0

func WaitForHTTP(targetURL string, timeout time.Duration)

WaitForHTTP polls a URL until it returns HTTP 200 or the timeout expires. Use this to verify that a service is reachable through the external gateway before running tests that depend on it.

func WaitForKustomizationReady added in v1.2.0

func WaitForKustomizationReady(kubeContext, namespace, name string, timeout time.Duration) error

WaitForKustomizationReady polls until the Flux Kustomization reports the Ready=True condition and returns an error if it does not become ready before the timeout.

func WaitForReleaseBindingReady added in v1.2.0

func WaitForReleaseBindingReady(kubeContext, namespace, name string)

WaitForReleaseBindingReady polls until the named ReleaseBinding has condition Ready=True.

func WebhookReceiverURL added in v1.2.0

func WebhookReceiverURL(namespace string) string

WebhookReceiverURL returns the in-cluster URL alert notification channels should target.

func WorkflowRunReference added in v1.2.0

func WorkflowRunReference(kubeContext, namespace, workflowRunName string) (kind, name, ns string, err error)

WorkflowRunReference returns the rendered workflow's Kind/Name/Namespace pointer copied from WorkflowRun.status.runReference. Returns ("", "", "") (all empty) when the controller has not populated runReference yet.

Types

type ComponentSearchScope added in v1.2.0

type ComponentSearchScope struct {
	Namespace   string  `json:"namespace"`
	Project     *string `json:"project,omitempty"`
	Component   *string `json:"component,omitempty"`
	Environment *string `json:"environment,omitempty"`
}

ComponentSearchScope scopes a logs/metrics/traces query to a component. Namespace is the openchoreo control-plane namespace the Component lives in (not the data-plane namespace).

type LogsQueryRequest added in v1.2.0

type LogsQueryRequest struct {
	StartTime    time.Time `json:"startTime"`
	EndTime      time.Time `json:"endTime"`
	SearchScope  any       `json:"searchScope"`
	SearchPhrase *string   `json:"searchPhrase,omitempty"`
	Limit        *int      `json:"limit,omitempty"`
	SortOrder    *string   `json:"sortOrder,omitempty"`
}

LogsQueryRequest mirrors the observer's OpenAPI request body for POST /api/v1/logs/query. Only the fields the e2e suites need are modeled. SearchScope is `any` so callers can pass either ComponentSearchScope or WorkflowSearchScope without us re-declaring oneOf logic.

type LogsQueryResponse added in v1.2.0

type LogsQueryResponse struct {
	Logs  []map[string]any `json:"logs,omitempty"`
	Total *int             `json:"total,omitempty"`
}

LogsQueryResponse models the parts of the observer's logs response the e2e suites assert on.

func QueryLogs added in v1.2.0

QueryLogs POSTs to /api/v1/logs/query and returns the parsed response. Pass a bearer token acquired via AcquireObserverToken. Errors include the HTTP body so flakes are diagnosable from CI logs.

type MCPClientConfig added in v1.2.0

type MCPClientConfig struct {
	Endpoint               string
	Token                  string
	Toolsets               []string
	FilterByAuthz          *bool
	IncludeDeprecatedTools *bool
}

MCPClientConfig holds configuration for creating an MCP client session.

type MetricsQueryRequest added in v1.2.0

type MetricsQueryRequest struct {
	StartTime   time.Time            `json:"startTime"`
	EndTime     time.Time            `json:"endTime"`
	Metric      string               `json:"metric"`
	SearchScope ComponentSearchScope `json:"searchScope"`
	Step        *string              `json:"step,omitempty"`
}

MetricsQueryRequest mirrors POST /api/v1/metrics/query. Metric is observer-defined ("resource" / "http"); Step is a Prometheus-style duration like "1m".

type MetricsQueryResponse added in v1.2.0

type MetricsQueryResponse map[string]any

MetricsQueryResponse is intentionally loose — the observer returns one of several shapes depending on `metric` (http vs resource), and we only need to inspect series counts at this layer.

func QueryMetrics added in v1.2.0

QueryMetrics POSTs to /api/v1/metrics/query.

type OCCRunner added in v1.2.0

type OCCRunner struct {
	BinaryPath string   // Path to compiled occ binary
	HomeDir    string   // Isolated $HOME directory for occ config files
	APIServer  string   // Base URL of the openchoreo-api (e.g., "http://localhost:12345")
	Env        []string // Additional environment variables (KEY=VALUE format)
}

func NewOCCRunner added in v1.2.0

func NewOCCRunner(apiServer string) (*OCCRunner, error)

NewOCCRunner creates an isolated occ runner for e2e tests.

func (*OCCRunner) Build added in v1.2.0

func (r *OCCRunner) Build() error

Build compiles the occ CLI binary into the runner's temp directory.

func (*OCCRunner) Cleanup added in v1.2.0

func (r *OCCRunner) Cleanup()

Cleanup removes the runner's temp directory containing the binary and HOME.

func (*OCCRunner) Run added in v1.2.0

func (r *OCCRunner) Run(args ...string) (stdout string, stderr string, err error)

Run executes occ with an isolated HOME and returns trimmed stdout and stderr.

func (*OCCRunner) RunWithEnv added in v1.2.0

func (r *OCCRunner) RunWithEnv(extraEnv []string, args ...string) (stdout string, stderr string, err error)

RunWithEnv executes occ with additional per-call environment variables. Extra env vars are appended last so they can override inherited values.

func (*OCCRunner) SeedConfig added in v1.2.0

func (r *OCCRunner) SeedConfig(token string) error

SeedConfig writes an occ config file into the runner's isolated HOME.

func (*OCCRunner) WriteFixtureFile added in v1.2.0

func (r *OCCRunner) WriteFixtureFile(content string) (string, error)

WriteFixtureFile writes YAML content to a unique fixture file for occ apply.

type ObserverQueryFrom added in v1.2.0

type ObserverQueryFrom struct {
	KubeContext string
	Namespace   string
	PodLabel    string // selector, e.g. "app=gitea"
	Container   string // container name; "" picks the first

	// ThunderTokenURL overrides the in-cluster Thunder token endpoint.
	// Set this when the exec pod cannot reach thunder-service.thunder.svc
	// via cluster DNS (e.g. multi-cluster e2e where Thunder is in a different
	// k3d cluster). Empty falls back to the default in-cluster URL.
	ThunderTokenURL string

	// ObserverURL overrides the in-cluster observer service base URL.
	// Set this when the exec pod cannot reach
	// observer.openchoreo-observability-plane.svc via cluster DNS (e.g.
	// multi-cluster e2e where the observer is in a different k3d cluster).
	// Must not include a trailing slash. Empty falls back to the default
	// in-cluster URL.
	ObserverURL string
}

ObserverQueryFrom resolves a Running pod that has curl available and runs observer queries through it. The Gitea pod used by the build/gitops suites is a natural fit (it ships curl); suites that don't install Gitea should call `framework.DeployCurlPod` to get one.

In a single-cluster setup the pod reaches Thunder and the observer via in-cluster DNS. In a multi-cluster setup set ThunderTokenURL and ObserverURL to the externally reachable URLs so the pod can cross cluster boundaries.

type PodStatus

type PodStatus struct {
	Name     string
	Phase    string
	Restarts string
}

PodStatus holds parsed pod information.

func GetPodStatuses

func GetPodStatuses(kubeContext, namespace string) ([]PodStatus, error)

GetPodStatuses returns the status of all non-completed pods in a namespace. Completed pods (Succeeded/Failed) are filtered out via field-selector so Job pods like the CA-extractor don't cause false failures.

type PortForward added in v1.2.0

type PortForward struct {
	KubeContext string
	Namespace   string
	Service     string
	LocalPort   int
	RemotePort  int
	// contains filtered or unexported fields
}

PortForward manages a kubectl port-forward background process.

func (*PortForward) LocalAddress added in v1.2.0

func (pf *PortForward) LocalAddress() string

LocalAddress returns "localhost:<LocalPort>".

func (*PortForward) Start added in v1.2.0

func (pf *PortForward) Start() error

Start begins port-forwarding in the background and waits until the port is accepting connections (or 15 s elapse).

func (*PortForward) Stop added in v1.2.0

func (pf *PortForward) Stop()

Stop terminates the port-forward process.

type TracesQueryRequest added in v1.2.0

type TracesQueryRequest struct {
	StartTime   time.Time            `json:"startTime"`
	EndTime     time.Time            `json:"endTime"`
	SearchScope ComponentSearchScope `json:"searchScope"`
	Limit       *int                 `json:"limit,omitempty"`
	SortOrder   *string              `json:"sortOrder,omitempty"`
}

TracesQueryRequest mirrors POST /api/v1alpha1/traces/query.

type TracesQueryResponse added in v1.2.0

type TracesQueryResponse struct {
	Traces []map[string]any `json:"traces,omitempty"`
	Total  *int             `json:"total,omitempty"`
}

TracesQueryResponse keeps the helper independent of the full observer types.

func QueryTraces added in v1.2.0

QueryTraces POSTs to /api/v1alpha1/traces/query.

type WorkflowSearchScope added in v1.2.0

type WorkflowSearchScope struct {
	Namespace       string  `json:"namespace"`
	WorkflowRunName *string `json:"workflowRunName,omitempty"`
	TaskName        *string `json:"taskName,omitempty"`
}

WorkflowSearchScope scopes a logs query to a WorkflowRun's logs. Used by `build-logs-after-deletion` to prove logs survive the CR's deletion.

Jump to

Keyboard shortcuts

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