Documentation
¶
Overview ¶
Package framework provides the E2E test framework for cloudflare-operator. It manages Kind cluster lifecycle, mock server, and test utilities.
Index ¶
- Constants
- type Framework
- func (*Framework) BuildMockServerImage() error
- func (f *Framework) Cleanup()
- func (f *Framework) CleanupTestNamespace(name string) error
- func (f *Framework) Context() context.Context
- func (f *Framework) CreateCloudflareCredentials(name string, apiToken string, accountID string, isDefault bool) error
- func (f *Framework) CreateSecret(namespace, name string, data map[string]string) error
- func (f *Framework) CreateTestService(namespace, name string, port int32) error
- func (f *Framework) DeleteResource(obj client.Object) error
- func (f *Framework) DeleteResourceAndWait(obj client.Object, timeout time.Duration) error
- func (f *Framework) DeployMockServerToCluster() error
- func (f *Framework) EnsureNamespaceExists(name string) error
- func (f *Framework) GetResource(obj client.Object, name, namespace string) error
- func (*Framework) InClusterMockServerURL() string
- func (*Framework) LoadMockServerImageToKind() error
- func (f *Framework) MockServerURL() string
- func (f *Framework) PatchOperatorWithMockServerURL() error
- func (f *Framework) ResetMockServer()
- func (f *Framework) SetupMockServerInCluster() error
- func (f *Framework) SetupTestNamespace(name string) error
- func (f *Framework) WaitForCondition(obj client.Object, conditionType string, expectedStatus metav1.ConditionStatus, ...) error
- func (f *Framework) WaitForDeletion(obj client.Object, timeout time.Duration) error
- func (f *Framework) WaitForMockServerReady(timeout time.Duration) error
- func (f *Framework) WaitForOperatorReady(timeout time.Duration) error
- func (f *Framework) WaitForStatusField(obj client.Object, fieldChecker func(client.Object) bool, ...) error
- type Options
Constants ¶
const ( // DefaultTimeout is the default timeout for operations DefaultTimeout = 5 * time.Minute // DefaultInterval is the default polling interval DefaultInterval = 2 * time.Second // KindClusterName is the name of the Kind cluster KindClusterName = "cloudflare-operator-e2e" // OperatorNamespace is the namespace where the operator is deployed OperatorNamespace = "cloudflare-operator-system" // TestNamespace is the default namespace for E2E tests TestNamespace = "e2e-test" // MockServerNamespace is the namespace where the mock server is deployed MockServerNamespace = "cloudflare-mock" // MockServerName is the name of the mock server deployment/service MockServerName = "mockserver" // MockServerImage is the Docker image for the mock server MockServerImage = "cloudflare-mockserver:e2e-test" // MockServerPort is the port the mock server listens on MockServerPort = 8787 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Framework ¶
type Framework struct {
Client client.Client
MockServer *mockserver.Server
KubeconfigPath string
ClusterCreated bool
// contains filtered or unexported fields
}
Framework provides utilities for E2E testing
func (*Framework) BuildMockServerImage ¶
BuildMockServerImage builds the mock server Docker image
func (*Framework) Cleanup ¶
func (f *Framework) Cleanup()
Cleanup cleans up the test framework resources
func (*Framework) CleanupTestNamespace ¶
CleanupTestNamespace deletes a test namespace
func (*Framework) CreateCloudflareCredentials ¶
func (f *Framework) CreateCloudflareCredentials(name string, apiToken string, accountID string, isDefault bool) error
CreateCloudflareCredentials creates a CloudflareCredentials resource and its secret
func (*Framework) CreateSecret ¶
CreateSecret creates a secret in the specified namespace
func (*Framework) CreateTestService ¶
CreateTestService creates a test deployment and service for TunnelBinding tests
func (*Framework) DeleteResource ¶
DeleteResource deletes a resource without waiting
func (*Framework) DeleteResourceAndWait ¶
DeleteResourceAndWait deletes a resource and waits for deletion to complete
func (*Framework) DeployMockServerToCluster ¶
DeployMockServerToCluster deploys the mock server as a Kubernetes deployment
func (*Framework) EnsureNamespaceExists ¶
EnsureNamespaceExists creates a namespace if it doesn't exist
func (*Framework) GetResource ¶
GetResource fetches a resource by name and namespace
func (*Framework) InClusterMockServerURL ¶
InClusterMockServerURL returns the in-cluster URL for the mock server
func (*Framework) LoadMockServerImageToKind ¶
LoadMockServerImageToKind loads the mock server image into Kind
func (*Framework) MockServerURL ¶
MockServerURL returns the mock server URL
func (*Framework) PatchOperatorWithMockServerURL ¶
PatchOperatorWithMockServerURL patches the operator deployment to use the mock server URL
func (*Framework) ResetMockServer ¶
func (f *Framework) ResetMockServer()
ResetMockServer resets the mock server state
func (*Framework) SetupMockServerInCluster ¶
SetupMockServerInCluster builds, loads, and deploys the mock server to the cluster
func (*Framework) SetupTestNamespace ¶
SetupTestNamespace creates a test namespace
func (*Framework) WaitForCondition ¶
func (f *Framework) WaitForCondition( obj client.Object, conditionType string, expectedStatus metav1.ConditionStatus, timeout time.Duration, ) error
WaitForCondition waits for a condition to be true on a resource
func (*Framework) WaitForDeletion ¶
WaitForDeletion waits for a resource to be deleted
func (*Framework) WaitForMockServerReady ¶
WaitForMockServerReady waits for the mock server deployment to be available
func (*Framework) WaitForOperatorReady ¶
WaitForOperatorReady waits for the operator deployment to be available
type Options ¶
type Options struct {
// UseExistingCluster uses an existing cluster instead of creating a Kind cluster
UseExistingCluster bool
// KubeconfigPath is the path to the kubeconfig file
KubeconfigPath string
// MockServerPort is the port for the mock Cloudflare API server (deprecated, use in-cluster mock)
MockServerPort int
// SkipMockServer skips starting the mock server (deprecated, use UseInClusterMockServer)
SkipMockServer bool
// UseInClusterMockServer deploys mock server to cluster instead of running locally
UseInClusterMockServer bool
// SkipMockServerSetup skips all mock server setup (for tests using real API)
SkipMockServerSetup bool
}
Options configures the test framework
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns default framework options