Documentation
¶
Index ¶
- func AllAPIVersions() []string
- func CalculateClusterServiceIDFromExternalAuthResourceID(ctx context.Context, resourcesDBClient database.ResourcesDBClient, ...) (string, error)
- func CalculateClusterServiceIDFromNodePoolResourceID(ctx context.Context, resourcesDBClient database.ResourcesDBClient, ...) (string, error)
- func DefaultLogger(t *testing.T) logr.Logger
- func GenerateRandomClusterClusterServiceHREF() string
- func Get20240610ClientFactory(frontendURL string, subscriptionID string) *hcpsdk20240610preview.ClientFactory
- func JSONOnly(entry fs.DirEntry) bool
- func LoadAllContent(ctx context.Context, contentLoader ContentLoader, createDir fs.FS) error
- func LoadCosmosContent(ctx context.Context, cosmosContainer *azcosmos.ContainerClient, content []byte) error
- func LoadCosmosContentFromFS(ctx context.Context, cosmosContainer *azcosmos.ContainerClient, stepDir fs.FS, ...) error
- func MarkOperationsCompleteForName(ctx context.Context, resourcesDBClient database.ResourcesDBClient, ...) error
- func SetClusterServiceID(ctx context.Context, resourcesDBClient database.ResourcesDBClient, ...) error
- func StampRandomClusterServiceID(ctx context.Context, resourcesDBClient database.ResourcesDBClient, ...) error
- func VerifyNoNewGoLeaks(t *testing.T)
- func WithAndWithoutCosmos(t *testing.T, testFn func(t *testing.T, withMock bool))
- type ClusterServiceMock
- func (s *ClusterServiceMock) AddContent(t *testing.T, initialDataDir fs.FS) error
- func (s *ClusterServiceMock) Cleanup(ctx context.Context)
- func (s *ClusterServiceMock) GetMergedClusters(testName string) ([]map[string]any, error)
- func (s *ClusterServiceMock) GetOrCreateMockData(dataName string) map[string][]any
- type ContentLoader
- type CosmosContentLoader
- type CosmosIntegrationTestInfo
- func (s *CosmosIntegrationTestInfo) BillingDBClient() database.BillingDBClient
- func (s *CosmosIntegrationTestInfo) Cleanup(ctx context.Context)
- func (s *CosmosIntegrationTestInfo) CosmosResourcesContainer() *azcosmos.ContainerClient
- func (s *CosmosIntegrationTestInfo) FleetDBClient() database.FleetDBClient
- func (s *CosmosIntegrationTestInfo) GetArtifactDir() string
- func (s *CosmosIntegrationTestInfo) ListAllDocuments(ctx context.Context) ([]*database.TypedDocument, error)
- func (s *CosmosIntegrationTestInfo) LoadContent(ctx context.Context, content []byte) error
- func (s *CosmosIntegrationTestInfo) ResourcesDBClient() database.ResourcesDBClient
- type DocumentLister
- type FakeOTELClient
- type GenericMutationTest
- func (h *GenericMutationTest) ExpectsResult() bool
- func (h *GenericMutationTest) Initialize(ctx context.Context, testInfo *IntegrationTestInfo) error
- func (h *GenericMutationTest) IsPatchTest() bool
- func (h *GenericMutationTest) IsUpdateTest() bool
- func (h *GenericMutationTest) VerifyActualError(t *testing.T, actualErr error)
- func (h *GenericMutationTest) VerifyActualResult(t *testing.T, actualCreated any)
- type IntegrationTestInfo
- type KubernetesClientSets
- func (k *KubernetesClientSets) Apply(ctx context.Context, data []byte) error
- func (k *KubernetesClientSets) Create(ctx context.Context, data []byte) error
- func (k *KubernetesClientSets) GetTrackedObject(ctx context.Context, expected *unstructured.Unstructured) (*unstructured.Unstructured, error)
- func (k *KubernetesClientSets) Stop()
- type MockCosmosIntegrationTestInfo
- func (m *MockCosmosIntegrationTestInfo) BillingDBClient() database.BillingDBClient
- func (m *MockCosmosIntegrationTestInfo) Cleanup(ctx context.Context)
- func (m *MockCosmosIntegrationTestInfo) FleetDBClient() database.FleetDBClient
- func (m *MockCosmosIntegrationTestInfo) GetArtifactDir() string
- func (m *MockCosmosIntegrationTestInfo) ListAllDocuments(ctx context.Context) ([]*database.TypedDocument, error)
- func (m *MockCosmosIntegrationTestInfo) LoadContent(ctx context.Context, content []byte) error
- func (m *MockCosmosIntegrationTestInfo) ResourcesDBClient() database.ResourcesDBClient
- type StorageIntegrationTestInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllAPIVersions ¶
func AllAPIVersions() []string
AllAPIVersions returns a sorted list of all registered API versions. IMPORTANT: When adding a new API version to frontend/pkg/frontend/frontend.go, also add a RegisterVersion call here.
func CalculateClusterServiceIDFromExternalAuthResourceID ¶
func CalculateClusterServiceIDFromExternalAuthResourceID( ctx context.Context, resourcesDBClient database.ResourcesDBClient, resourceIDString string, ) (string, error)
CalculateClusterServiceIDFromExternalAuthResourceID returns the Cluster Service internal ID for an external auth, derived from the parent cluster's stored ClusterServiceID.
func CalculateClusterServiceIDFromNodePoolResourceID ¶
func CalculateClusterServiceIDFromNodePoolResourceID( ctx context.Context, resourcesDBClient database.ResourcesDBClient, resourceIDString string, ) (string, error)
CalculateClusterServiceIDFromNodePoolResourceID returns the Cluster Service internal ID for a node pool, derived from the parent cluster's stored ClusterServiceID.
func GenerateRandomClusterClusterServiceHREF ¶
func GenerateRandomClusterClusterServiceHREF() string
GenerateRandomClusterClusterServiceHREF returns a Cluster Service cluster HREF with a random 10-character ID, matching the cluster-service mock PostCluster behavior.
func Get20240610ClientFactory ¶
func Get20240610ClientFactory(frontendURL string, subscriptionID string) *hcpsdk20240610preview.ClientFactory
func LoadAllContent ¶
func LoadCosmosContent ¶
func LoadCosmosContentFromFS ¶
func SetClusterServiceID ¶
func SetClusterServiceID( ctx context.Context, resourcesDBClient database.ResourcesDBClient, resourceIDString string, clusterServiceID string, ) error
SetClusterServiceID updates the Cosmos document for a cluster, node pool, or external auth with the given Cluster Service internal ID.
func StampRandomClusterServiceID ¶
func StampRandomClusterServiceID( ctx context.Context, resourcesDBClient database.ResourcesDBClient, clusterResourceIDString string, ) error
StampRandomClusterServiceID assigns a random Cluster Service cluster HREF to the cluster document.
func VerifyNoNewGoLeaks ¶
Types ¶
type ClusterServiceMock ¶
type ClusterServiceMock struct {
ArtifactsDir string
MockClusterServiceClient *ocm.MockClusterServiceClientSpec
// contains filtered or unexported fields
}
func NewClusterServiceMock ¶
func NewClusterServiceMock(t *testing.T, artifactsDir string) *ClusterServiceMock
func (*ClusterServiceMock) AddContent ¶
func (*ClusterServiceMock) Cleanup ¶
func (s *ClusterServiceMock) Cleanup(ctx context.Context)
func (*ClusterServiceMock) GetMergedClusters ¶
func (s *ClusterServiceMock) GetMergedClusters(testName string) ([]map[string]any, error)
GetMergedClusters returns all clusters stored in the mock, each merged from its full mutation history and serialized to a JSON map. The testName should be t.Name() from the test that created the mock.
func (*ClusterServiceMock) GetOrCreateMockData ¶
func (s *ClusterServiceMock) GetOrCreateMockData(dataName string) map[string][]any
type ContentLoader ¶
type ContentLoader interface {
// LoadContent loads a single JSON document into the database.
LoadContent(ctx context.Context, content []byte) error
}
ContentLoader is an interface for loading test content into a database. This abstraction allows tests to run against either a real Cosmos DB or a mock database implementation.
type CosmosContentLoader ¶
type CosmosContentLoader struct {
// contains filtered or unexported fields
}
CosmosContentLoader implements ContentLoader and DocumentLister using a real Cosmos DB container.
func NewCosmosContentLoader ¶
func NewCosmosContentLoader(container *azcosmos.ContainerClient) *CosmosContentLoader
NewCosmosContentLoader creates a new CosmosContentLoader from a Cosmos container.
func (*CosmosContentLoader) ListAllDocuments ¶
func (c *CosmosContentLoader) ListAllDocuments(ctx context.Context) ([]*database.TypedDocument, error)
ListAllDocuments returns all documents in the Cosmos container.
func (*CosmosContentLoader) LoadContent ¶
func (c *CosmosContentLoader) LoadContent(ctx context.Context, content []byte) error
LoadContent loads a single JSON document into Cosmos DB.
type CosmosIntegrationTestInfo ¶
type CosmosIntegrationTestInfo struct {
ArtifactsDir string
CosmosDatabaseClient *azcosmos.DatabaseClient
// contains filtered or unexported fields
}
func (*CosmosIntegrationTestInfo) BillingDBClient ¶
func (s *CosmosIntegrationTestInfo) BillingDBClient() database.BillingDBClient
func (*CosmosIntegrationTestInfo) Cleanup ¶
func (s *CosmosIntegrationTestInfo) Cleanup(ctx context.Context)
func (*CosmosIntegrationTestInfo) CosmosResourcesContainer ¶
func (s *CosmosIntegrationTestInfo) CosmosResourcesContainer() *azcosmos.ContainerClient
func (*CosmosIntegrationTestInfo) FleetDBClient ¶
func (s *CosmosIntegrationTestInfo) FleetDBClient() database.FleetDBClient
func (*CosmosIntegrationTestInfo) GetArtifactDir ¶
func (s *CosmosIntegrationTestInfo) GetArtifactDir() string
func (*CosmosIntegrationTestInfo) ListAllDocuments ¶
func (s *CosmosIntegrationTestInfo) ListAllDocuments(ctx context.Context) ([]*database.TypedDocument, error)
func (*CosmosIntegrationTestInfo) LoadContent ¶
func (s *CosmosIntegrationTestInfo) LoadContent(ctx context.Context, content []byte) error
func (*CosmosIntegrationTestInfo) ResourcesDBClient ¶
func (s *CosmosIntegrationTestInfo) ResourcesDBClient() database.ResourcesDBClient
type DocumentLister ¶
type DocumentLister interface {
// ListAllDocuments returns all documents in the database.
ListAllDocuments(ctx context.Context) ([]*database.TypedDocument, error)
}
DocumentLister is an interface for listing all documents from a database. This is used by the cosmosCompare step to verify database contents.
type FakeOTELClient ¶
type FakeOTELClient struct{}
func (*FakeOTELClient) Send ¶
func (t *FakeOTELClient) Send(ctx context.Context, msg msgs.Msg, options ...base.SendOption) error
type GenericMutationTest ¶
type GenericMutationTest struct {
CreateJSON []byte
UpdateJSON []byte
PatchJSON []byte
// contains filtered or unexported fields
}
func ReadGenericMutationTest ¶
func ReadGenericMutationTest(testDir fs.FS) (*GenericMutationTest, error)
func (*GenericMutationTest) ExpectsResult ¶
func (h *GenericMutationTest) ExpectsResult() bool
func (*GenericMutationTest) Initialize ¶
func (h *GenericMutationTest) Initialize(ctx context.Context, testInfo *IntegrationTestInfo) error
func (*GenericMutationTest) IsPatchTest ¶
func (h *GenericMutationTest) IsPatchTest() bool
func (*GenericMutationTest) IsUpdateTest ¶
func (h *GenericMutationTest) IsUpdateTest() bool
func (*GenericMutationTest) VerifyActualError ¶
func (h *GenericMutationTest) VerifyActualError(t *testing.T, actualErr error)
func (*GenericMutationTest) VerifyActualResult ¶
func (h *GenericMutationTest) VerifyActualResult(t *testing.T, actualCreated any)
type IntegrationTestInfo ¶
type IntegrationTestInfo struct {
StorageIntegrationTestInfo
*ClusterServiceMock
ArtifactsDir string
FrontendURL string
Frontend *frontend.Frontend
AdminURL string
AdminAPI *server.AdminAPI
KubernetesClientSets *KubernetesClientSets
// contains filtered or unexported fields
}
func (*IntegrationTestInfo) Cleanup ¶
func (s *IntegrationTestInfo) Cleanup(ctx context.Context)
type KubernetesClientSets ¶
type KubernetesClientSets struct {
FakeClientSet *fake.Clientset
SessiongateClientset *sessiongatefake.Clientset
CoreInformerFactory kubeinformers.SharedInformerFactory
SessionInformerFactory sessiongateinformers.SharedInformerFactory
// contains filtered or unexported fields
}
KubernetesClientSets provides fake clientsets with informer support for testing.
Uses the pattern from kubernetes/client-go/examples/fake-client to properly synchronize fake clients with informers. The key is waiting for the watcher to start before injecting events. See: https://github.com/kubernetes/client-go/blob/master/examples/fake-client/main_test.go
func NewKubernetesClientSets ¶
func NewKubernetesClientSets(sessionNamespace string) *KubernetesClientSets
NewKubernetesClientSets creates fake clientsets with informer support. Informers are started and synchronized before returning.
func (*KubernetesClientSets) Apply ¶
func (k *KubernetesClientSets) Apply(ctx context.Context, data []byte) error
func (*KubernetesClientSets) Create ¶
func (k *KubernetesClientSets) Create(ctx context.Context, data []byte) error
func (*KubernetesClientSets) GetTrackedObject ¶
func (k *KubernetesClientSets) GetTrackedObject(ctx context.Context, expected *unstructured.Unstructured) (*unstructured.Unstructured, error)
func (*KubernetesClientSets) Stop ¶
func (k *KubernetesClientSets) Stop()
type MockCosmosIntegrationTestInfo ¶
type MockCosmosIntegrationTestInfo struct {
ArtifactsDir string
// contains filtered or unexported fields
}
func (*MockCosmosIntegrationTestInfo) BillingDBClient ¶
func (m *MockCosmosIntegrationTestInfo) BillingDBClient() database.BillingDBClient
func (*MockCosmosIntegrationTestInfo) Cleanup ¶
func (m *MockCosmosIntegrationTestInfo) Cleanup(ctx context.Context)
func (*MockCosmosIntegrationTestInfo) FleetDBClient ¶
func (m *MockCosmosIntegrationTestInfo) FleetDBClient() database.FleetDBClient
func (*MockCosmosIntegrationTestInfo) GetArtifactDir ¶
func (m *MockCosmosIntegrationTestInfo) GetArtifactDir() string
func (*MockCosmosIntegrationTestInfo) ListAllDocuments ¶
func (m *MockCosmosIntegrationTestInfo) ListAllDocuments(ctx context.Context) ([]*database.TypedDocument, error)
func (*MockCosmosIntegrationTestInfo) LoadContent ¶
func (m *MockCosmosIntegrationTestInfo) LoadContent(ctx context.Context, content []byte) error
func (*MockCosmosIntegrationTestInfo) ResourcesDBClient ¶
func (m *MockCosmosIntegrationTestInfo) ResourcesDBClient() database.ResourcesDBClient
type StorageIntegrationTestInfo ¶
type StorageIntegrationTestInfo interface {
ContentLoader
DocumentLister
GetArtifactDir() string
ResourcesDBClient() database.ResourcesDBClient
BillingDBClient() database.BillingDBClient
FleetDBClient() database.FleetDBClient
Cleanup(ctx context.Context)
}