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
27 changes: 27 additions & 0 deletions pkg/ddc/jindo/delete_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,33 @@ func doTestCases(testCases []TestCase, t *testing.T) {
}
}

// TestJindoEngine_DeleteVolume tests the DeleteVolume method of JindoEngine under various scenarios.
//
// Parameters:
// - t *testing.T : Go testing framework context for test assertions and logging
//
// Test Strategy:
// 1. Setup test environment with mocked Kubernetes resources:
// - PVs with 'CreatedBy=fluid' annotation to simulate Fluid-managed persistent volumes
// - PVCs with different configurations (normal vs error cases)
// 2. Create 3 test scenarios using parameterized test pattern:
// Case 1: Normal deletion (JindoEngineCommon)
// - Input: Valid PV/PVC without conflicting annotations
// - Expected: Successful deletion (isDeleted=true, isErr=false)
// Case 2: Protected PVC deletion (JindoEngineErr)
// - Input: PVC with 'CreatedBy=fluid' annotation (protected resource)
// - Expected: Failed deletion (isErr=true)
// Case 3: Missing runtime scenario (JindoEngineNoRunTime)
// - Input: Engine with runtime=false configuration
// - Expected: Failed deletion (isErr=true)
// 3. Verification: Uses doTestCases() helper to validate deletion outcomes against expectations
//
// Test Resources:
// - fake.NewFakeClientWithScheme: Simulates Kubernetes API server with predefined resources
// - testScheme: Runtime scheme for Kubernetes API objects
// - testPVInputs/testPVCInputs: Predefined PersistentVolume and PersistentVolumeClaim configurations
//
// Note: This test focuses on edge cases for PVC/PV cleanup workflow in Fluid orchestration system.
func TestJindoEngine_DeleteVolume(t *testing.T) {
testPVInputs := []*v1.PersistentVolume{
{
Expand Down
Loading