Documentation
¶
Index ¶
- Constants
- func AssertAddressURL(t *testing.T, server *mcpv1alpha1.MCPServer, port int32)
- func AssertAddressUnset(t *testing.T, server *mcpv1alpha1.MCPServer)
- func AssertConditionStable(ctx context.Context, t *testing.T, r *resources.Resources, ...)
- func Clientset(t *testing.T, cfg *envconf.Config) *kubernetes.Clientset
- func FindPodByLabel(ctx context.Context, t *testing.T, cfg *envconf.Config, ...) *corev1.Pod
- func GetMCPServerCondition(server *mcpv1alpha1.MCPServer, condType string) *metav1.Condition
- func NewMCPServer(name, namespace string, opts ...MCPServerOption) *mcpv1alpha1.MCPServer
- func PodLogs(ctx context.Context, t *testing.T, cfg *envconf.Config, ...) string
- func PrewarmImages(images ...string) env.Func
- func ProfileNames() []string
- func Register(tier Tier, fn LocateFunc)
- func RegisterProfile(p Profile)
- func RegisterProfileFlag()
- func ResolveProfile() map[string][]string
- func ServerFromContext(ctx context.Context) *mcpv1alpha1.MCPServer
- func ServiceProxyHTTPClient(t *testing.T, cfg *envconf.Config, namespace, serviceName string, port int, ...) (*http.Client, string)
- func SetupMCPServer(ctx context.Context, t *testing.T, cfg *envconf.Config, name string, ...) context.Context
- func TeardownMCPServer(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context
- func UpdateWithRetry[T k8s.Object](ctx context.Context, t *testing.T, r *resources.Resources, obj T, ...)
- func WaitForEndpointsReady(ctx context.Context, t *testing.T, cfg *envconf.Config, namespace, name string)
- func WaitForMCPServerCondition(ctx context.Context, t *testing.T, r *resources.Resources, ...)
- func WaitForMCPServerConditionMessageContains(ctx context.Context, t *testing.T, r *resources.Resources, ...)
- func WaitForMCPServerConditionReason(ctx context.Context, t *testing.T, r *resources.Resources, ...)
- func WaitForMCPServerReconciled(ctx context.Context, t *testing.T, r *resources.Resources, ...)
- func WaitForMCPServerReconciledAndReady(ctx context.Context, t *testing.T, r *resources.Resources, ...)
- func WaitForPodPhase(ctx context.Context, t *testing.T, cfg *envconf.Config, pod *corev1.Pod, ...)
- type ContextKey
- type LocateFunc
- type MCPServerOption
- func WithArguments(args ...string) MCPServerOption
- func WithEnvFrom(envFrom ...corev1.EnvFromSource) MCPServerOption
- func WithExtraAnnotations(annotations map[string]string) MCPServerOption
- func WithExtraLabels(labels map[string]string) MCPServerOption
- func WithImage(ref string) MCPServerOption
- func WithPath(path string) MCPServerOption
- func WithPodSecurityContext(psc *corev1.PodSecurityContext) MCPServerOption
- func WithPort(port int32) MCPServerOption
- func WithReplicas(n int32) MCPServerOption
- func WithSecurityContext(sc *corev1.SecurityContext) MCPServerOption
- func WithStorage(storage ...mcpv1alpha1.StorageMount) MCPServerOption
- func WithTransport(transport *mcpv1alpha1.TransportConfig) MCPServerOption
- type OperatorRef
- func DiscoverOperator(ctx context.Context, cfg *envconf.Config) (OperatorRef, error)
- func FromDefaults(_ context.Context, _ *envconf.Config) (OperatorRef, error)
- func FromEnvVars(_ context.Context, _ *envconf.Config) (OperatorRef, error)
- func FromPodLabels(ctx context.Context, cfg *envconf.Config) (OperatorRef, error)
- func MustDiscoverOperatorOnce(ctx context.Context, cfg *envconf.Config, t testing.TB) OperatorRef
- type Profile
- type ProxyOption
- type Registry
- type Tier
Constants ¶
const ( DefaultMCPServerImage = "quay.io/containers/kubernetes_mcp_server@sha256:6d650f4bd6ac303ad82713c997e73a2d001602f9bf17392c9b9a0e30e29c6423" // :v0.0.66 AlternateMCPServerImage = "quay.io/containers/kubernetes_mcp_server@sha256:5df586e2c7ced2a3125f6e78923388d80b69de0a2ad1470325b05318f12725bd" // :v0.0.65 BusyboxImage = "docker.io/library/busybox@sha256:9db7b59979c38555a39def84a31fb98b5296952f9e3afd4f6f11f05b07adfab0" // :1.37 )
const ( DefaultNamespace = "mcp-lifecycle-operator-system" DefaultServiceAccountName = "mcp-lifecycle-operator-controller-manager" DefaultMetricsServiceName = "mcp-lifecycle-operator-controller-manager-metrics-service" )
Variables ¶
This section is empty.
Functions ¶
func AssertAddressURL ¶
func AssertAddressURL(t *testing.T, server *mcpv1alpha1.MCPServer, port int32)
AssertAddressURL verifies the MCPServer's status address URL matches the expected port and path.
func AssertAddressUnset ¶
func AssertAddressUnset(t *testing.T, server *mcpv1alpha1.MCPServer)
AssertAddressUnset verifies status.address.url is not published (issue #302).
func AssertConditionStable ¶
func AssertConditionStable(ctx context.Context, t *testing.T, r *resources.Resources, server *mcpv1alpha1.MCPServer, condType string, status metav1.ConditionStatus, duration ...time.Duration)
AssertConditionStable re-fetches the MCPServer repeatedly for the given duration and fails if the condition ever deviates from the expected status.
func FindPodByLabel ¶
func FindPodByLabel(ctx context.Context, t *testing.T, cfg *envconf.Config, namespace, labelSelector string, timeout ...time.Duration) *corev1.Pod
FindPodByLabel polls until a Running pod matching the label selector is found in the given namespace. An optional timeout can be provided; defaults to 3 minutes.
func GetMCPServerCondition ¶
func GetMCPServerCondition(server *mcpv1alpha1.MCPServer, condType string) *metav1.Condition
GetMCPServerCondition returns a pointer to the named condition, or nil.
func NewMCPServer ¶
func NewMCPServer(name, namespace string, opts ...MCPServerOption) *mcpv1alpha1.MCPServer
NewMCPServer creates an MCPServer with sensible defaults for e2e tests. Defaults: image=DefaultMCPServerImage, port=8080, args=["--port","8080","--read-only"].
func PodLogs ¶
func PodLogs(ctx context.Context, t *testing.T, cfg *envconf.Config, podName, namespace string) string
PodLogs returns the log output of a pod's first container.
func PrewarmImages ¶
PrewarmImages returns an env.Func that pulls the given images on every node before tests start. Uses a DaemonSet per image so multi-node clusters are fully warmed. This prevents parallel tests from thundering-herd the registry with concurrent pulls of the same image.
func Register ¶
func Register(tier Tier, fn LocateFunc)
Register adds a locator to the default registry at the given tier.
func RegisterProfile ¶
func RegisterProfile(p Profile)
RegisterProfile adds a profile to the global registry. If a profile with the same name already exists, the higher priority wins. Equal priority overwrites (last-write-wins).
func RegisterProfileFlag ¶
func RegisterProfileFlag()
RegisterProfileFlag registers the -profile flag. Call before envconf.NewFromFlags().
func ResolveProfile ¶
ResolveProfile returns the labels for the selected profile, or nil if no profile was selected. Exits with an error if the profile is unknown.
func ServerFromContext ¶
func ServerFromContext(ctx context.Context) *mcpv1alpha1.MCPServer
ServerFromContext extracts the MCPServer stored by SetupMCPServer. Returns nil if the server was never stored in context.
func ServiceProxyHTTPClient ¶
func ServiceProxyHTTPClient(t *testing.T, cfg *envconf.Config, namespace, serviceName string, port int, path string, opts ...ProxyOption) (*http.Client, string)
ServiceProxyHTTPClient returns an *http.Client and the full proxy URL for accessing a ClusterIP service via the Kubernetes API server proxy. The returned client is authenticated for the API server; the URL routes through /api/v1/namespaces/{ns}/services/{scheme}:{name}:{port}/proxy/{path}.
func SetupMCPServer ¶
func SetupMCPServer(ctx context.Context, t *testing.T, cfg *envconf.Config, name string, waitForReady bool, opts ...MCPServerOption) context.Context
SetupMCPServer creates an MCPServer, optionally waits for Ready, and stores it in context. Pass waitForReady=true to block until the server reaches Ready=True before returning.
func TeardownMCPServer ¶
TeardownMCPServer deletes the MCPServer from context and waits for owned Deployment and Service to be garbage collected.
func UpdateWithRetry ¶
func UpdateWithRetry[T k8s.Object](ctx context.Context, t *testing.T, r *resources.Resources, obj T, mutate func(T))
UpdateWithRetry performs a read-modify-write loop with automatic retry on conflict. The mutate callback receives the freshly-fetched object so the caller always modifies the latest resourceVersion.
func WaitForEndpointsReady ¶
func WaitForEndpointsReady(ctx context.Context, t *testing.T, cfg *envconf.Config, namespace, name string)
WaitForEndpointsReady waits until the named Service has at least one ready endpoint in its EndpointSlice. The API server proxy returns 503 until endpoints are propagated, so callers that use the proxy should wait first.
func WaitForMCPServerCondition ¶
func WaitForMCPServerCondition(ctx context.Context, t *testing.T, r *resources.Resources, server *mcpv1alpha1.MCPServer, condType string, status metav1.ConditionStatus, timeout ...time.Duration)
WaitForMCPServerCondition polls until the named condition reaches the desired status. An optional timeout can be provided; defaults to 3 minutes.
func WaitForMCPServerConditionMessageContains ¶
func WaitForMCPServerConditionMessageContains(ctx context.Context, t *testing.T, r *resources.Resources, server *mcpv1alpha1.MCPServer, condType string, status metav1.ConditionStatus, reason string, messageSubstring string, timeout ...time.Duration)
WaitForMCPServerConditionMessageContains polls until the named condition reaches the desired status and reason, and its message contains the given substring. An optional timeout can be provided; defaults to 3 minutes.
func WaitForMCPServerConditionReason ¶
func WaitForMCPServerConditionReason(ctx context.Context, t *testing.T, r *resources.Resources, server *mcpv1alpha1.MCPServer, condType string, status metav1.ConditionStatus, reason string, timeout ...time.Duration)
WaitForMCPServerConditionReason polls until the named condition reaches the desired status and reason. An optional timeout can be provided; defaults to 3 minutes.
func WaitForMCPServerReconciled ¶
func WaitForMCPServerReconciled(ctx context.Context, t *testing.T, r *resources.Resources, server *mcpv1alpha1.MCPServer, timeout ...time.Duration)
WaitForMCPServerReconciled polls until the controller has reconciled the current generation (observedGeneration >= generation) without requiring a specific Ready status. Use this after spec mutations where the pod may not become Ready (e.g. port changes when the container image uses a fixed port).
func WaitForMCPServerReconciledAndReady ¶
func WaitForMCPServerReconciledAndReady(ctx context.Context, t *testing.T, r *resources.Resources, server *mcpv1alpha1.MCPServer, timeout ...time.Duration)
WaitForMCPServerReconciledAndReady polls until the controller has reconciled the current generation (observedGeneration >= generation) and Ready=True. Use this after mutating the MCPServer spec to avoid seeing stale Ready from before the update.
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is used to store values in context.
const ( NsKey ContextKey = "namespace" ServerKey ContextKey = "mcpserver" )
type LocateFunc ¶
LocateFunc finds the operator. A non-zero OperatorRef means found (possibly partial). A zero OperatorRef with nil error means not found. A non-nil error is propagated and aborts discovery.
type MCPServerOption ¶
type MCPServerOption func(*mcpv1alpha1.MCPServer)
MCPServerOption configures an MCPServer for testing.
func WithArguments ¶
func WithArguments(args ...string) MCPServerOption
WithArguments sets the MCPServer container arguments.
func WithEnvFrom ¶
func WithEnvFrom(envFrom ...corev1.EnvFromSource) MCPServerOption
WithEnvFrom sets the MCPServer envFrom sources.
func WithExtraAnnotations ¶
func WithExtraAnnotations(annotations map[string]string) MCPServerOption
WithExtraAnnotations sets custom annotations on the MCPServer.
func WithExtraLabels ¶
func WithExtraLabels(labels map[string]string) MCPServerOption
WithExtraLabels sets custom labels on the MCPServer.
func WithPodSecurityContext ¶
func WithPodSecurityContext(psc *corev1.PodSecurityContext) MCPServerOption
WithPodSecurityContext sets the pod-level security context.
func WithReplicas ¶
func WithReplicas(n int32) MCPServerOption
WithReplicas sets the number of pod replicas.
func WithSecurityContext ¶
func WithSecurityContext(sc *corev1.SecurityContext) MCPServerOption
WithSecurityContext sets the container security context.
func WithStorage ¶
func WithStorage(storage ...mcpv1alpha1.StorageMount) MCPServerOption
WithStorage sets the MCPServer storage mounts.
func WithTransport ¶
func WithTransport(transport *mcpv1alpha1.TransportConfig) MCPServerOption
WithTransport sets the MCPServer transport configuration.
type OperatorRef ¶
OperatorRef holds the discovered operator namespace and resource names.
func DiscoverOperator ¶
DiscoverOperator runs the default registry through all tiers.
func FromDefaults ¶
func FromEnvVars ¶
func FromPodLabels ¶
type Profile ¶
Profile is a named label selector for filtering e2e tests. Higher Priority wins when multiple registrations use the same Name. Upstream defaults use priority 0; downstream overrides should use > 0.
func LookupProfile ¶
LookupProfile returns a profile by name.
type ProxyOption ¶
type ProxyOption func(*proxyOptions)
ProxyOption configures optional parameters for ServiceProxyHTTPClient.
func WithScheme ¶
func WithScheme(scheme string) ProxyOption
WithScheme sets the service scheme used in the API server proxy URL. Defaults to "http".
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds tier-keyed locators and caches the discovery result.
func (*Registry) DiscoverOperator ¶
func (*Registry) MustDiscoverOperatorOnce ¶
func (r *Registry) MustDiscoverOperatorOnce(ctx context.Context, cfg *envconf.Config, t testing.TB) OperatorRef
MustDiscoverOperatorOnce runs DiscoverOperator at most once, caches the result, and calls t.Fatalf if discovery fails.
func (*Registry) Register ¶
func (r *Registry) Register(tier Tier, fn LocateFunc)
Register adds a locator at the given tier, replacing any existing one.