Documentation
¶
Overview ¶
Package operator_test provides end-to-end tests for the ToolHive operator controllers. This package tests MCPRegistry and other operator functionality using Ginkgo and Kubernetes APIs.
Index ¶
- Constants
- type ConfigMapBuilder
- type ConfigMapTestHelper
- func (h *ConfigMapTestHelper) CleanupConfigMaps() error
- func (h *ConfigMapTestHelper) CreateSampleToolHiveRegistry(name string) *corev1.ConfigMap
- func (h *ConfigMapTestHelper) DeleteConfigMap(name string) error
- func (h *ConfigMapTestHelper) ListConfigMaps() (*corev1.ConfigMapList, error)
- func (h *ConfigMapTestHelper) NewConfigMapBuilder(name string) *ConfigMapBuilder
- type K8sResourceTestHelper
- type MCPRegistryTestHelper
- func (h *MCPRegistryTestHelper) CleanupRegistries() error
- func (h *MCPRegistryTestHelper) DeleteRegistry(name string) error
- func (h *MCPRegistryTestHelper) GetRegistry(name string) (*mcpv1beta1.MCPRegistry, error)
- func (h *MCPRegistryTestHelper) ListRegistries() (*mcpv1beta1.MCPRegistryList, error)
- func (h *MCPRegistryTestHelper) NewRegistryBuilder(name string) *RegistryBuilder
- func (h *MCPRegistryTestHelper) UpdateRegistry(registry *mcpv1beta1.MCPRegistry) error
- func (h *MCPRegistryTestHelper) WaitForRegistryInitialization(registryName string, timingHelper *TimingTestHelper, ...)
- type RegistryBuilder
- func (rb *RegistryBuilder) Build() *mcpv1beta1.MCPRegistry
- func (rb *RegistryBuilder) Create(h *MCPRegistryTestHelper) *mcpv1beta1.MCPRegistry
- func (rb *RegistryBuilder) WithAPISource(endpoint string) *RegistryBuilder
- func (rb *RegistryBuilder) WithAnnotation(key, value string) *RegistryBuilder
- func (rb *RegistryBuilder) WithConfigMapSource(configMapName, key string) *RegistryBuilder
- func (rb *RegistryBuilder) WithGitSource(repository, branch, path string) *RegistryBuilder
- func (rb *RegistryBuilder) WithLabel(key, value string) *RegistryBuilder
- func (rb *RegistryBuilder) WithSyncPolicy(interval string) *RegistryBuilder
- type RegistryServer
- type StatusTestHelper
- type TimingTestHelper
- type ToolHiveRegistryData
Constants ¶
const ( // QuickTimeout for operations that should complete quickly (e.g., resource creation) QuickTimeout = 10 * time.Second // MediumTimeout for operations that may take some time (e.g., controller reconciliation) MediumTimeout = 30 * time.Second // LongTimeout for operations that may take a while (e.g., sync operations) LongTimeout = 2 * time.Minute // ExtraLongTimeout for operations that may take very long (e.g., complex e2e scenarios) ExtraLongTimeout = 5 * time.Minute // DefaultPollingInterval for Eventually/Consistently checks DefaultPollingInterval = 1 * time.Second // FastPollingInterval for operations that need frequent checks FastPollingInterval = 200 * time.Millisecond // SlowPollingInterval for operations that don't need frequent checks SlowPollingInterval = 5 * time.Second )
Common timeout values for different types of operations
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigMapBuilder ¶
type ConfigMapBuilder struct {
// contains filtered or unexported fields
}
ConfigMapBuilder provides a fluent interface for building ConfigMaps
func (*ConfigMapBuilder) Build ¶
func (cb *ConfigMapBuilder) Build() *corev1.ConfigMap
Build returns the constructed ConfigMap
func (*ConfigMapBuilder) Create ¶
func (cb *ConfigMapBuilder) Create(h *ConfigMapTestHelper) *corev1.ConfigMap
Create builds and creates the ConfigMap in the cluster
func (*ConfigMapBuilder) WithToolHiveRegistry ¶
func (cb *ConfigMapBuilder) WithToolHiveRegistry(key string, servers []RegistryServer) *ConfigMapBuilder
WithToolHiveRegistry adds ToolHive format registry data
type ConfigMapTestHelper ¶
ConfigMapTestHelper provides utilities for ConfigMap testing and validation
func NewConfigMapTestHelper ¶
func NewConfigMapTestHelper(ctx context.Context, k8sClient client.Client, namespace string) *ConfigMapTestHelper
NewConfigMapTestHelper creates a new test helper for ConfigMap operations
func (*ConfigMapTestHelper) CleanupConfigMaps ¶
func (h *ConfigMapTestHelper) CleanupConfigMaps() error
CleanupConfigMaps deletes all test ConfigMaps in the namespace
func (*ConfigMapTestHelper) CreateSampleToolHiveRegistry ¶
func (h *ConfigMapTestHelper) CreateSampleToolHiveRegistry(name string) *corev1.ConfigMap
CreateSampleToolHiveRegistry creates a ConfigMap with sample ToolHive registry data
func (*ConfigMapTestHelper) DeleteConfigMap ¶
func (h *ConfigMapTestHelper) DeleteConfigMap(name string) error
DeleteConfigMap deletes a ConfigMap by name
func (*ConfigMapTestHelper) ListConfigMaps ¶
func (h *ConfigMapTestHelper) ListConfigMaps() (*corev1.ConfigMapList, error)
ListConfigMaps returns all ConfigMaps in the namespace
func (*ConfigMapTestHelper) NewConfigMapBuilder ¶
func (h *ConfigMapTestHelper) NewConfigMapBuilder(name string) *ConfigMapBuilder
NewConfigMapBuilder creates a new ConfigMap builder
type K8sResourceTestHelper ¶
type K8sResourceTestHelper struct {
// contains filtered or unexported fields
}
K8sResourceTestHelper provides utilities for testing Kubernetes resources
func NewK8sResourceTestHelper ¶
func NewK8sResourceTestHelper(ctx context.Context, k8sClient client.Client, namespace string) *K8sResourceTestHelper
NewK8sResourceTestHelper creates a new test helper for Kubernetes resources
func (*K8sResourceTestHelper) DeploymentExists ¶
func (h *K8sResourceTestHelper) DeploymentExists(name string) bool
DeploymentExists checks if a deployment exists
func (*K8sResourceTestHelper) GetDeployment ¶
func (h *K8sResourceTestHelper) GetDeployment(name string) (*appsv1.Deployment, error)
GetDeployment retrieves a deployment by name
func (*K8sResourceTestHelper) GetService ¶
func (h *K8sResourceTestHelper) GetService(name string) (*corev1.Service, error)
GetService retrieves a service by name
func (*K8sResourceTestHelper) ServiceExists ¶
func (h *K8sResourceTestHelper) ServiceExists(name string) bool
ServiceExists checks if a service exists
type MCPRegistryTestHelper ¶
MCPRegistryTestHelper provides specialized utilities for MCPRegistry testing
func NewMCPRegistryTestHelper ¶
func NewMCPRegistryTestHelper(ctx context.Context, k8sClient client.Client, namespace string) *MCPRegistryTestHelper
NewMCPRegistryTestHelper creates a new test helper for MCPRegistry operations
func (*MCPRegistryTestHelper) CleanupRegistries ¶
func (h *MCPRegistryTestHelper) CleanupRegistries() error
CleanupRegistries deletes all MCPRegistries in the namespace
func (*MCPRegistryTestHelper) DeleteRegistry ¶
func (h *MCPRegistryTestHelper) DeleteRegistry(name string) error
DeleteRegistry deletes an MCPRegistry by name
func (*MCPRegistryTestHelper) GetRegistry ¶
func (h *MCPRegistryTestHelper) GetRegistry(name string) (*mcpv1beta1.MCPRegistry, error)
GetRegistry retrieves an MCPRegistry by name
func (*MCPRegistryTestHelper) ListRegistries ¶
func (h *MCPRegistryTestHelper) ListRegistries() (*mcpv1beta1.MCPRegistryList, error)
ListRegistries returns all MCPRegistries in the namespace
func (*MCPRegistryTestHelper) NewRegistryBuilder ¶
func (h *MCPRegistryTestHelper) NewRegistryBuilder(name string) *RegistryBuilder
NewRegistryBuilder creates a new MCPRegistry builder
func (*MCPRegistryTestHelper) UpdateRegistry ¶
func (h *MCPRegistryTestHelper) UpdateRegistry(registry *mcpv1beta1.MCPRegistry) error
UpdateRegistry updates an existing MCPRegistry
func (*MCPRegistryTestHelper) WaitForRegistryInitialization ¶
func (h *MCPRegistryTestHelper) WaitForRegistryInitialization(registryName string, timingHelper *TimingTestHelper, statusHelper *StatusTestHelper)
WaitForRegistryInitialization waits for common initialization steps after registry creation: 1. Wait for finalizer to be added 2. Wait for controller to process the registry into an acceptable initial phase
type RegistryBuilder ¶
type RegistryBuilder struct {
// contains filtered or unexported fields
}
RegistryBuilder provides a fluent interface for building MCPRegistry objects
func (*RegistryBuilder) Build ¶
func (rb *RegistryBuilder) Build() *mcpv1beta1.MCPRegistry
Build returns the constructed MCPRegistry with configYAML generated from the builder config.
func (*RegistryBuilder) Create ¶
func (rb *RegistryBuilder) Create(h *MCPRegistryTestHelper) *mcpv1beta1.MCPRegistry
Create builds and creates the MCPRegistry in the cluster
func (*RegistryBuilder) WithAPISource ¶ added in v0.6.6
func (rb *RegistryBuilder) WithAPISource(endpoint string) *RegistryBuilder
WithAPISource configures the registry with an API source
func (*RegistryBuilder) WithAnnotation ¶
func (rb *RegistryBuilder) WithAnnotation(key, value string) *RegistryBuilder
WithAnnotation adds an annotation to the registry
func (*RegistryBuilder) WithConfigMapSource ¶
func (rb *RegistryBuilder) WithConfigMapSource(configMapName, key string) *RegistryBuilder
WithConfigMapSource configures the registry with a ConfigMap-backed file source. It sets source type to file and records ConfigMap details for volume/mount generation.
func (*RegistryBuilder) WithGitSource ¶ added in v0.6.6
func (rb *RegistryBuilder) WithGitSource(repository, branch, path string) *RegistryBuilder
WithGitSource configures the registry with a Git source
func (*RegistryBuilder) WithLabel ¶
func (rb *RegistryBuilder) WithLabel(key, value string) *RegistryBuilder
WithLabel adds a label to the registry
func (*RegistryBuilder) WithSyncPolicy ¶
func (rb *RegistryBuilder) WithSyncPolicy(interval string) *RegistryBuilder
WithSyncPolicy configures the sync policy interval for the source
type RegistryServer ¶
type RegistryServer struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Tier string `json:"tier"`
Status string `json:"status"`
Transport string `json:"transport"`
Tools []string `json:"tools"`
Image string `json:"image"`
Tags []string `json:"tags,omitempty"`
}
RegistryServer represents a server definition in the registry
type StatusTestHelper ¶
type StatusTestHelper struct {
// contains filtered or unexported fields
}
StatusTestHelper provides utilities for MCPRegistry status testing and validation
func NewStatusTestHelper ¶
func NewStatusTestHelper(ctx context.Context, k8sClient client.Client, namespace string) *StatusTestHelper
NewStatusTestHelper creates a new test helper for status operations
func (*StatusTestHelper) WaitForPhase ¶
func (h *StatusTestHelper) WaitForPhase(registryName string, expectedPhase mcpv1beta1.MCPRegistryPhase, timeout time.Duration)
WaitForPhase waits for an MCPRegistry to reach the specified phase
func (*StatusTestHelper) WaitForPhaseAny ¶
func (h *StatusTestHelper) WaitForPhaseAny(registryName string, expectedPhases []mcpv1beta1.MCPRegistryPhase, timeout time.Duration)
WaitForPhaseAny waits for an MCPRegistry to reach any of the specified phases
type TimingTestHelper ¶
TimingTestHelper provides utilities for timing and synchronization in async operations
func NewTimingTestHelper ¶
func NewTimingTestHelper(ctx context.Context, k8sClient client.Client) *TimingTestHelper
NewTimingTestHelper creates a new test helper for timing operations
func (*TimingTestHelper) WaitForControllerReconciliation ¶
func (*TimingTestHelper) WaitForControllerReconciliation(assertion func() interface{}) gomega.AsyncAssertion
WaitForControllerReconciliation waits for controller to reconcile changes
type ToolHiveRegistryData ¶
type ToolHiveRegistryData struct {
Version string `json:"version"`
LastUpdated string `json:"last_updated"`
Servers map[string]RegistryServer `json:"servers"`
RemoteServers map[string]RegistryServer `json:"remoteServers"`
}
ToolHiveRegistryData represents the ToolHive registry format