mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-22 21:10:22 +00:00
e2e: add rwop validation helper function in pod.go
This commit adds the rwop validation helper for rbd and cephfs tests. Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
parent
8f7016229a
commit
375e9c8a51
32
e2e/pod.go
32
e2e/pod.go
@ -33,6 +33,8 @@ import (
|
||||
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
||||
)
|
||||
|
||||
const errRWOPConflict = "node has pod using PersistentVolumeClaim with the same name and ReadWriteOncePod access mode."
|
||||
|
||||
// getDaemonSetLabelSelector returns labels of daemonset given name and namespace dynamically,
|
||||
// needed since labels are not same for helm and non-helm deployments.
|
||||
func getDaemonSetLabelSelector(f *framework.Framework, ns, daemonSetName string) (string, error) {
|
||||
@ -414,3 +416,33 @@ func recreateCSIPods(f *framework.Framework, podLabels, daemonsetName, deploymen
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateRWOPPodCreation validates the second pod creation failure scenario with RWOP pvc.
|
||||
func validateRWOPPodCreation(
|
||||
f *framework.Framework,
|
||||
pvc *v1.PersistentVolumeClaim,
|
||||
app *v1.Pod,
|
||||
baseAppName string) error {
|
||||
var err error
|
||||
// create one more app with same PVC
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, deployTimeout)
|
||||
app.Name = name
|
||||
|
||||
err = createAppErr(f.ClientSet, app, deployTimeout, errRWOPConflict)
|
||||
if err != nil {
|
||||
return fmt.Errorf("application should not go to running state due to RWOP access mode: %w", err)
|
||||
}
|
||||
|
||||
err = deletePod(name, app.Namespace, f.ClientSet, deployTimeout)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete application: %w", err)
|
||||
}
|
||||
|
||||
app.Name = baseAppName
|
||||
err = deletePVCAndApp("", f, pvc, app)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete PVC and application: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user