Documentation
¶
Overview ¶
Package testtools provides comprehensive testing utilities for controller-runtime based controllers. Fixed version for Nephoran Intent Operator integration tests
Index ¶
- func GetScenarioConfigs() map[string]TestScenarioConfig
- func GetUniqueName(prefix string) string
- func GetUniqueNamespace(prefix string) string
- func IsRunningInCI() bool
- type BenchmarkConfig
- type CleanupPolicy
- type CoverageConfig
- type E2NodeSetTestConfig
- type EdgeControllerTestConfig
- type EnvtestBinaryManager
- func (ebm *EnvtestBinaryManager) EnsureBinariesInstalled(ctx context.Context) error
- func (ebm *EnvtestBinaryManager) GetBinaryDirectory() string
- func (ebm *EnvtestBinaryManager) GetBinaryPath(binary string) string
- func (ebm *EnvtestBinaryManager) SetupEnvironment()
- func (ebm *EnvtestBinaryManager) ValidateInstallation(ctx context.Context) error
- type NetworkIntentTestConfig
- type OranControllerTestConfig
- type TestConfig
- type TestEnvironment
- func SetupTestEnvironment() (*TestEnvironment, error)
- func SetupTestEnvironmentForCI() (*TestEnvironment, error)
- func SetupTestEnvironmentForDevelopment() (*TestEnvironment, error)
- func SetupTestEnvironmentWithBinaryCheck(options TestEnvironmentOptions) (*TestEnvironment, error)
- func SetupTestEnvironmentWithOptions(options TestEnvironmentOptions) (*TestEnvironment, error)
- func (te *TestEnvironment) AddCleanupFunc(f func() error)
- func (te *TestEnvironment) CleanupNamespace(namespace string) error
- func (te *TestEnvironment) CleanupNamespaceWithTimeout(namespace string, timeout time.Duration) error
- func (te *TestEnvironment) Consistently(f func() bool, msgAndArgs ...interface{}) AsyncAssertion
- func (te *TestEnvironment) CreateManager() (ctrl.Manager, error)
- func (te *TestEnvironment) CreateManagerWithOptions(opts ctrl.Options) (ctrl.Manager, error)
- func (te *TestEnvironment) CreateNamespace(name string) error
- func (te *TestEnvironment) CreateNamespaceWithLabels(name string, labels map[string]string) error
- func (te *TestEnvironment) CreateTestE2NodeSet(name, namespace string, replicas int32) (*nephoranv1.E2NodeSet, error)
- func (te *TestEnvironment) CreateTestManagedElement(name, namespace string) (*nephoranv1.ManagedElement, error)
- func (te *TestEnvironment) CreateTestNetworkIntent(name, namespace, intent string) (*nephoranv1.NetworkIntent, error)
- func (te *TestEnvironment) CreateTestObject(obj client.Object) error
- func (te *TestEnvironment) DeleteNamespace(name string) error
- func (te *TestEnvironment) DeleteTestObject(obj client.Object) error
- func (te *TestEnvironment) Eventually(f func() bool, msgAndArgs ...interface{}) AsyncAssertion
- func (te *TestEnvironment) GetContext() context.Context
- func (te *TestEnvironment) GetContextWithDeadline(deadline time.Time) (context.Context, context.CancelFunc)
- func (te *TestEnvironment) GetContextWithTimeout(timeout time.Duration) (context.Context, context.CancelFunc)
- func (te *TestEnvironment) GetDefaultInterval() time.Duration
- func (te *TestEnvironment) GetDefaultTimeout() time.Duration
- func (te *TestEnvironment) GetDiscoveryClient() discovery.DiscoveryInterface
- func (te *TestEnvironment) GetEventRecorder() record.EventRecorder
- func (te *TestEnvironment) GetOptions() TestEnvironmentOptions
- func (te *TestEnvironment) GetScheme() *runtime.Scheme
- func (te *TestEnvironment) GetTestObject(key types.NamespacedName, obj client.Object) error
- func (te *TestEnvironment) InstallCRDs(crdPaths ...string) error
- func (te *TestEnvironment) IsStarted() bool
- func (te *TestEnvironment) ListTestObjects(list client.ObjectList, opts ...client.ListOption) error
- func (te *TestEnvironment) NamespaceExists(name string) bool
- func (te *TestEnvironment) StartManager() error
- func (te *TestEnvironment) StopManager()
- func (te *TestEnvironment) TeardownTestEnvironment()
- func (te *TestEnvironment) UpdateTestObject(obj client.Object) error
- func (te *TestEnvironment) VerifyCRDInstallation() error
- func (te *TestEnvironment) WaitForCacheSync(mgr ctrl.Manager) error
- func (te *TestEnvironment) WaitForCacheSyncWithTimeout(mgr ctrl.Manager, timeout time.Duration) error
- func (te *TestEnvironment) WaitForE2NodeSetReady(namespacedName types.NamespacedName, expectedReplicas int32) error
- func (te *TestEnvironment) WaitForManagedElementReady(namespacedName types.NamespacedName) error
- func (te *TestEnvironment) WaitForManagerReady() error
- func (te *TestEnvironment) WaitForNetworkIntentReady(namespacedName types.NamespacedName) error
- func (te *TestEnvironment) WaitForResourceReady(obj client.Object, timeout time.Duration) error
- type TestEnvironmentOptions
- func CITestEnvironmentOptions() TestEnvironmentOptions
- func DefaultTestEnvironmentOptions() TestEnvironmentOptions
- func DevelopmentTestEnvironmentOptions() TestEnvironmentOptions
- func DisasterRecoveryTestEnvironmentOptions() TestEnvironmentOptions
- func EnhancedTestEnvironmentOptions() TestEnvironmentOptions
- func GetRecommendedOptions() TestEnvironmentOptions
- type TestScenarioConfig
- type TrafficControllerTestConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetScenarioConfigs ¶
func GetScenarioConfigs() map[string]TestScenarioConfig
func GetUniqueName ¶
func GetUniqueNamespace ¶
func IsRunningInCI ¶
func IsRunningInCI() bool
Types ¶
type BenchmarkConfig ¶
type BenchmarkConfig struct {
Enabled bool
Duration time.Duration
MemProfile bool
CPUProfile bool
OutputPath string
}
func GetBenchmarkConfig ¶
func GetBenchmarkConfig() *BenchmarkConfig
type CleanupPolicy ¶
type CleanupPolicy string
CleanupPolicy defines how resources should be cleaned up.
const ( CleanupPolicyDelete CleanupPolicy = "delete" CleanupPolicyRetain CleanupPolicy = "retain" CleanupPolicyOrphan CleanupPolicy = "orphan" )
const ( CleanupPolicyDelete CleanupPolicy = "delete" CleanupPolicyRetain CleanupPolicy = "retain" CleanupPolicyOrphan CleanupPolicy = "orphan" )
type CoverageConfig ¶
type CoverageConfig struct {
Enabled bool
MinimumThreshold float64
OutputFormat string
OutputPath string
IncludePatterns []string
ExcludePatterns []string
}
func GetCoverageConfig ¶
func GetCoverageConfig() *CoverageConfig
type E2NodeSetTestConfig ¶
type EnvtestBinaryManager ¶
type EnvtestBinaryManager struct {
// contains filtered or unexported fields
}
func NewEnvtestBinaryManager ¶
func NewEnvtestBinaryManager() *EnvtestBinaryManager
func (*EnvtestBinaryManager) EnsureBinariesInstalled ¶
func (ebm *EnvtestBinaryManager) EnsureBinariesInstalled(ctx context.Context) error
func (*EnvtestBinaryManager) GetBinaryDirectory ¶
func (ebm *EnvtestBinaryManager) GetBinaryDirectory() string
func (*EnvtestBinaryManager) GetBinaryPath ¶
func (ebm *EnvtestBinaryManager) GetBinaryPath(binary string) string
func (*EnvtestBinaryManager) SetupEnvironment ¶
func (ebm *EnvtestBinaryManager) SetupEnvironment()
func (*EnvtestBinaryManager) ValidateInstallation ¶
func (ebm *EnvtestBinaryManager) ValidateInstallation(ctx context.Context) error
type NetworkIntentTestConfig ¶
type TestConfig ¶
type TestConfig struct {
DefaultTimeout time.Duration
ReconcileTimeout time.Duration
EventuallyTimeout time.Duration
ConsistentlyDuration time.Duration
DefaultInterval time.Duration
ReconcileInterval time.Duration
E2NodeSetConfig E2NodeSetTestConfig
NetworkIntentConfig NetworkIntentTestConfig
OranControllerConfig OranControllerTestConfig
EdgeControllerConfig EdgeControllerTestConfig
TrafficControllerConfig TrafficControllerTestConfig
}
func GetCITestConfig ¶
func GetCITestConfig() *TestConfig
func GetDefaultTestConfig ¶
func GetDefaultTestConfig() *TestConfig
func GetDevelopmentTestConfig ¶
func GetDevelopmentTestConfig() *TestConfig
type TestEnvironment ¶
type TestEnvironment struct {
// Core Components
Cfg *rest.Config
K8sClient client.Client
K8sClientSet *kubernetes.Clientset
TestEnv *envtest.Environment
Scheme *runtime.Scheme
// Manager and Controllers
Manager ctrl.Manager
ManagerCtx context.Context
ManagerCancel context.CancelFunc
ManagerOnce sync.Once
// contains filtered or unexported fields
}
TestEnvironment provides a comprehensive test environment for controller testing.
func SetupTestEnvironment ¶
func SetupTestEnvironment() (*TestEnvironment, error)
SetupTestEnvironment creates and starts a comprehensive test environment.
func SetupTestEnvironmentForCI ¶
func SetupTestEnvironmentForCI() (*TestEnvironment, error)
func SetupTestEnvironmentForDevelopment ¶
func SetupTestEnvironmentForDevelopment() (*TestEnvironment, error)
func SetupTestEnvironmentWithBinaryCheck ¶
func SetupTestEnvironmentWithBinaryCheck(options TestEnvironmentOptions) (*TestEnvironment, error)
func SetupTestEnvironmentWithOptions ¶
func SetupTestEnvironmentWithOptions(options TestEnvironmentOptions) (*TestEnvironment, error)
SetupTestEnvironmentWithOptions creates and starts a test environment with custom options.
func (*TestEnvironment) AddCleanupFunc ¶
func (te *TestEnvironment) AddCleanupFunc(f func() error)
func (*TestEnvironment) CleanupNamespace ¶
func (*TestEnvironment) CleanupNamespaceWithTimeout ¶
func (*TestEnvironment) Consistently ¶
func (te *TestEnvironment) Consistently(f func() bool, msgAndArgs ...interface{}) AsyncAssertion
func (*TestEnvironment) CreateManager ¶
func (*TestEnvironment) CreateManagerWithOptions ¶
func (*TestEnvironment) CreateNamespace ¶
func (te *TestEnvironment) CreateNamespace(name string) error
CreateNamespace creates a namespace for testing.
func (*TestEnvironment) CreateNamespaceWithLabels ¶
func (*TestEnvironment) CreateTestE2NodeSet ¶
func (*TestEnvironment) CreateTestManagedElement ¶
func (*TestEnvironment) CreateTestNetworkIntent ¶
func (*TestEnvironment) CreateTestObject ¶
func (*TestEnvironment) DeleteNamespace ¶
func (*TestEnvironment) DeleteTestObject ¶
func (*TestEnvironment) Eventually ¶
func (te *TestEnvironment) Eventually(f func() bool, msgAndArgs ...interface{}) AsyncAssertion
func (*TestEnvironment) GetContext ¶
func (*TestEnvironment) GetContextWithDeadline ¶
func (*TestEnvironment) GetContextWithTimeout ¶
func (*TestEnvironment) GetDefaultInterval ¶
func (*TestEnvironment) GetDefaultTimeout ¶
func (*TestEnvironment) GetDiscoveryClient ¶
func (te *TestEnvironment) GetDiscoveryClient() discovery.DiscoveryInterface
func (*TestEnvironment) GetEventRecorder ¶
func (te *TestEnvironment) GetEventRecorder() record.EventRecorder
func (*TestEnvironment) GetOptions ¶
func (te *TestEnvironment) GetOptions() TestEnvironmentOptions
func (*TestEnvironment) GetScheme ¶
func (te *TestEnvironment) GetScheme() *runtime.Scheme
GetScheme returns the runtime scheme.
func (*TestEnvironment) GetTestObject ¶
func (te *TestEnvironment) GetTestObject(key types.NamespacedName, obj client.Object) error
func (*TestEnvironment) InstallCRDs ¶
func (*TestEnvironment) ListTestObjects ¶
func (te *TestEnvironment) ListTestObjects(list client.ObjectList, opts ...client.ListOption) error
func (*TestEnvironment) NamespaceExists ¶
func (*TestEnvironment) StartManager ¶
func (te *TestEnvironment) StartManager() error
func (*TestEnvironment) StopManager ¶
func (te *TestEnvironment) StopManager()
func (*TestEnvironment) TeardownTestEnvironment ¶
func (te *TestEnvironment) TeardownTestEnvironment()
TeardownTestEnvironment stops and cleans up the test environment.
func (*TestEnvironment) UpdateTestObject ¶
func (*TestEnvironment) VerifyCRDInstallation ¶
func (te *TestEnvironment) VerifyCRDInstallation() error
VerifyCRDInstallation verifies that all expected CRDs are installed and ready.
func (*TestEnvironment) WaitForCacheSync ¶
func (*TestEnvironment) WaitForCacheSyncWithTimeout ¶
func (*TestEnvironment) WaitForE2NodeSetReady ¶
func (te *TestEnvironment) WaitForE2NodeSetReady(namespacedName types.NamespacedName, expectedReplicas int32) error
func (*TestEnvironment) WaitForManagedElementReady ¶
func (te *TestEnvironment) WaitForManagedElementReady(namespacedName types.NamespacedName) error
func (*TestEnvironment) WaitForManagerReady ¶
func (te *TestEnvironment) WaitForManagerReady() error
func (*TestEnvironment) WaitForNetworkIntentReady ¶
func (te *TestEnvironment) WaitForNetworkIntentReady(namespacedName types.NamespacedName) error
func (*TestEnvironment) WaitForResourceReady ¶
WaitForResourceReady waits for a specific resource to be ready.
type TestEnvironmentOptions ¶
type TestEnvironmentOptions struct {
// CRD and Webhook Configuration
CRDDirectoryPaths []string
WebhookInstallOptions envtest.WebhookInstallOptions
AttachControlPlaneOutput bool
UseExistingCluster *bool
// Environment Variables
EnvironmentVariables map[string]string
// Binary Assets
BinaryAssetsDirectory string
// Timeouts and Intervals
ControlPlaneStartTimeout time.Duration
ControlPlaneStopTimeout time.Duration
APIServerReadyTimeout time.Duration
// Test Configuration
EnableWebhooks bool
EnableMetrics bool
EnableHealthChecks bool
EnableLeaderElection bool
EnableProfiling bool
// Namespace Configuration
DefaultNamespace string
CreateDefaultNamespace bool
NamespaceCleanupPolicy CleanupPolicy
// Scheme Configuration
SchemeBuilders []func(*runtime.Scheme) error
// Resource Limits
MemoryLimit string
CPULimit string
// CI/Development Mode
CIMode bool
DevelopmentMode bool
VerboseLogging bool
}
TestEnvironmentOptions configures the test environment setup.
func CITestEnvironmentOptions ¶
func CITestEnvironmentOptions() TestEnvironmentOptions
func DefaultTestEnvironmentOptions ¶
func DefaultTestEnvironmentOptions() TestEnvironmentOptions
DefaultTestEnvironmentOptions returns sensible defaults for test environment setup.
func DevelopmentTestEnvironmentOptions ¶
func DevelopmentTestEnvironmentOptions() TestEnvironmentOptions
func DisasterRecoveryTestEnvironmentOptions ¶
func DisasterRecoveryTestEnvironmentOptions() TestEnvironmentOptions
func EnhancedTestEnvironmentOptions ¶
func EnhancedTestEnvironmentOptions() TestEnvironmentOptions
func GetRecommendedOptions ¶
func GetRecommendedOptions() TestEnvironmentOptions