Update common controller tests after split controller
Signed-off-by: Grant Griffiths <grant@portworx.com>
This commit is contained in:
@@ -22,46 +22,60 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// Test single call to ensurePVCFinalizer and checkandRemovePVCFinalizer,
|
||||
// expecting PVCFinalizer to be added or removed
|
||||
func TestPVCFinalizer(t *testing.T) {
|
||||
// Test single call to ensurePVCFinalizer, checkandRemovePVCFinalizer, addSnapshotFinalizer, removeSnapshotFinalizer
|
||||
// expecting finalizers to be added or removed
|
||||
func TestSnapshotFinalizer(t *testing.T) {
|
||||
|
||||
tests := []controllerTest{
|
||||
{
|
||||
name: "1-1 - successful add PVC finalizer",
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false),
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false, true),
|
||||
initialClaims: newClaimArray("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty),
|
||||
test: testAddPVCFinalizer,
|
||||
expectSuccess: true,
|
||||
},
|
||||
{
|
||||
name: "1-2 - won't add PVC finalizer; already added",
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false),
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false, true),
|
||||
initialClaims: newClaimArrayFinalizer("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty),
|
||||
test: testAddPVCFinalizer,
|
||||
expectSuccess: false,
|
||||
},
|
||||
{
|
||||
name: "1-3 - successful remove PVC finalizer",
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false),
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false, true),
|
||||
initialClaims: newClaimArrayFinalizer("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty),
|
||||
test: testRemovePVCFinalizer,
|
||||
expectSuccess: true,
|
||||
},
|
||||
{
|
||||
name: "1-4 - won't remove PVC finalizer; already removed",
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false),
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false, true),
|
||||
initialClaims: newClaimArray("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty),
|
||||
test: testRemovePVCFinalizer,
|
||||
expectSuccess: false,
|
||||
},
|
||||
{
|
||||
name: "1-5 - won't remove PVC finalizer; PVC in-use",
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false),
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false, true),
|
||||
initialClaims: newClaimArray("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty),
|
||||
test: testRemovePVCFinalizer,
|
||||
expectSuccess: false,
|
||||
},
|
||||
{
|
||||
name: "2-1 - successful add Snapshot finalizer",
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false, false),
|
||||
initialClaims: newClaimArray("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty),
|
||||
test: testAddSnapshotFinalizer,
|
||||
expectSuccess: true,
|
||||
},
|
||||
{
|
||||
name: "2-1 - successful remove Snapshot finalizer",
|
||||
initialSnapshots: newSnapshotArray("snap6-2", "snapuid6-2", "claim6-2", "", classSilver, "", &False, nil, nil, nil, false, true),
|
||||
initialClaims: newClaimArray("claim6-2", "pvc-uid6-2", "1Gi", "volume6-2", v1.ClaimBound, &classEmpty),
|
||||
test: testRemoveSnapshotFinalizer,
|
||||
expectSuccess: true,
|
||||
},
|
||||
}
|
||||
runPVCFinalizerTests(t, tests, snapshotClasses)
|
||||
runFinalizerTests(t, tests, snapshotClasses)
|
||||
}
|
||||
|
Reference in New Issue
Block a user