Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions pkg/ddc/alluxio/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,35 @@ func TestGetDataSetFileNum(t *testing.T) {
}
}

// TestGetRuntime tests the AlluxioEngine.getRuntime() method to verify it correctly retrieves
// the AlluxioRuntime custom resource from the Kubernetes cluster.
//
// Test Structure:
// - Defines a test table with multiple test cases (though currently only one example exists).
// - Each test case specifies:
// * Input fields: Simulated AlluxioEngine instance configuration.
// * Expected output: The AlluxioRuntime object that should be returned.
// * Error expectation: Whether an error is expected during retrieval.
//
// Key Testing Components:
// - Uses Kubernetes client-go testing utilities (fake client, scheme registration) to mock
// API server interactions, avoiding real cluster dependencies.
// - Validates both successful retrieval and error conditions.
// - Checks deep equality between retrieved and expected objects to ensure metadata accuracy.
//
// Test Workflow for Each Case:
// 1. Register required Kubernetes resource types (AlluxioRuntime, core v1) into the scheme.
// 2. Initialize a fake client preloaded with the expected AlluxioRuntime object.
// 3. Instantiate the AlluxioEngine with test-specific configurations and the fake client.
// 4. Execute getRuntime() and validate:
// - Error behavior matches expectations
// - Retrieved object matches the expected object structure exactly
//
// Edge Cases Covered (via additional test cases in TODO):
// - Non-existent runtime
// - Invalid namespace/name configurations
// - API version/kind mismatches
// - Cluster connection failures (simulated via client misconfiguration)
func TestGetRuntime(t *testing.T) {
type fields struct {
runtime *datav1alpha1.AlluxioRuntime
Expand Down
Loading