Skip to content

Commit 83db17d

Browse files
Add Notation to TestGetRuntime in pkg/ddc/alluxio/utils_test.go. (#4745)
Signed-off-by: WHZ <221220145@smail.nju.edu.cn>
1 parent ff33347 commit 83db17d

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

pkg/ddc/alluxio/utils_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,35 @@ func TestGetDataSetFileNum(t *testing.T) {
368368
}
369369
}
370370

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

0 commit comments

Comments
 (0)