mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-14 02:10:21 +00:00
e2e: add e2e for static PVC without imageFeature parameter
This commit adds e2e to make sure static PVC without imageFeatures parameter fail with proper error event. Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
parent
7fc553a3a7
commit
82a204bfd3
@ -34,7 +34,7 @@ func deployVault(c kubernetes.Interface, deployTimeout int) {
|
|||||||
Expect(err).Should(BeNil())
|
Expect(err).Should(BeNil())
|
||||||
Expect(len(pods.Items)).Should(Equal(1))
|
Expect(len(pods.Items)).Should(Equal(1))
|
||||||
name := pods.Items[0].Name
|
name := pods.Items[0].Name
|
||||||
err = waitForPodInRunningState(name, cephCSINamespace, c, deployTimeout)
|
err = waitForPodInRunningState(name, cephCSINamespace, c, deployTimeout, noError)
|
||||||
Expect(err).Should(BeNil())
|
Expect(err).Should(BeNil())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
25
e2e/pod.go
25
e2e/pod.go
@ -259,10 +259,18 @@ func createApp(c kubernetes.Interface, app *v1.Pod, timeout int) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create app: %w", err)
|
return fmt.Errorf("failed to create app: %w", err)
|
||||||
}
|
}
|
||||||
return waitForPodInRunningState(app.Name, app.Namespace, c, timeout)
|
return waitForPodInRunningState(app.Name, app.Namespace, c, timeout, noError)
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForPodInRunningState(name, ns string, c kubernetes.Interface, t int) error {
|
func createAppErr(c kubernetes.Interface, app *v1.Pod, timeout int, errString string) error {
|
||||||
|
_, err := c.CoreV1().Pods(app.Namespace).Create(context.TODO(), app, metav1.CreateOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return waitForPodInRunningState(app.Name, app.Namespace, c, timeout, errString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func waitForPodInRunningState(name, ns string, c kubernetes.Interface, t int, expectedError string) error {
|
||||||
timeout := time.Duration(t) * time.Minute
|
timeout := time.Duration(t) * time.Minute
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
e2elog.Logf("Waiting up to %v to be in Running state", name)
|
e2elog.Logf("Waiting up to %v to be in Running state", name)
|
||||||
@ -276,6 +284,19 @@ func waitForPodInRunningState(name, ns string, c kubernetes.Interface, t int) er
|
|||||||
return true, nil
|
return true, nil
|
||||||
case v1.PodFailed, v1.PodSucceeded:
|
case v1.PodFailed, v1.PodSucceeded:
|
||||||
return false, conditions.ErrPodCompleted
|
return false, conditions.ErrPodCompleted
|
||||||
|
case v1.PodPending:
|
||||||
|
if expectedError != "" {
|
||||||
|
events, err := c.CoreV1().Events(ns).List(context.TODO(), metav1.ListOptions{
|
||||||
|
FieldSelector: fmt.Sprintf("involvedObject.name=%s", name),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if strings.Contains(events.String(), expectedError) {
|
||||||
|
e2elog.Logf("Expected Error %q found successfully", expectedError)
|
||||||
|
return true, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
e2elog.Logf("%s app is in %s phase expected to be in Running state (%d seconds elapsed)", name, pod.Status.Phase, int(time.Since(start).Seconds()))
|
e2elog.Logf("%s app is in %s phase expected to be in Running state (%d seconds elapsed)", name, pod.Status.Phase, int(time.Since(start).Seconds()))
|
||||||
return false, nil
|
return false, nil
|
||||||
|
13
e2e/rbd.go
13
e2e/rbd.go
@ -1051,7 +1051,7 @@ var _ = Describe("RBD", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("validate RBD static FileSystem PVC", func() {
|
By("validate RBD static FileSystem PVC", func() {
|
||||||
err := validateRBDStaticPV(f, appPath, false)
|
err := validateRBDStaticPV(f, appPath, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to validate rbd static pv with error %v", err)
|
e2elog.Failf("failed to validate rbd static pv with error %v", err)
|
||||||
}
|
}
|
||||||
@ -1060,7 +1060,7 @@ var _ = Describe("RBD", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
By("validate RBD static Block PVC", func() {
|
By("validate RBD static Block PVC", func() {
|
||||||
err := validateRBDStaticPV(f, rawAppPath, true)
|
err := validateRBDStaticPV(f, rawAppPath, true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("failed to validate rbd block pv with error %v", err)
|
e2elog.Failf("failed to validate rbd block pv with error %v", err)
|
||||||
}
|
}
|
||||||
@ -1068,6 +1068,15 @@ var _ = Describe("RBD", func() {
|
|||||||
validateRBDImageCount(f, 0, defaultRBDPool)
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
By("validate failure of RBD static PVC without imageFeatures parameter", func() {
|
||||||
|
err := validateRBDStaticPV(f, rawAppPath, true, true)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("Validation of static PVC without imageFeatures parameter failed with err %v", err)
|
||||||
|
}
|
||||||
|
// validate created backend rbd images
|
||||||
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
||||||
|
})
|
||||||
|
|
||||||
By("validate mount options in app pod", func() {
|
By("validate mount options in app pod", func() {
|
||||||
mountFlags := []string{"discard"}
|
mountFlags := []string{"discard"}
|
||||||
err := checkMountOptions(pvcPath, appPath, f, mountFlags)
|
err := checkMountOptions(pvcPath, appPath, f, mountFlags)
|
||||||
|
@ -113,7 +113,7 @@ func resizePVCAndValidateSize(pvcPath, appPath string, f *framework.Framework) e
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// wait for application pod to come up after resize
|
// wait for application pod to come up after resize
|
||||||
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout, noError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func getStaticPVC(name, pvName, size, ns, sc string, blockPVC bool) *v1.Persiste
|
|||||||
return pvc
|
return pvc
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) error {
|
func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock, checkImgFeat bool) error {
|
||||||
opt := make(map[string]string)
|
opt := make(map[string]string)
|
||||||
var (
|
var (
|
||||||
rbdImageName = "test-static-pv"
|
rbdImageName = "test-static-pv"
|
||||||
@ -112,7 +112,9 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e
|
|||||||
return fmt.Errorf("failed to create rbd image %s", e)
|
return fmt.Errorf("failed to create rbd image %s", e)
|
||||||
}
|
}
|
||||||
opt["clusterID"] = fsID
|
opt["clusterID"] = fsID
|
||||||
|
if !checkImgFeat {
|
||||||
opt["imageFeatures"] = "layering"
|
opt["imageFeatures"] = "layering"
|
||||||
|
}
|
||||||
opt["pool"] = defaultRBDPool
|
opt["pool"] = defaultRBDPool
|
||||||
opt["staticVolume"] = "true"
|
opt["staticVolume"] = "true"
|
||||||
if radosNamespace != "" {
|
if radosNamespace != "" {
|
||||||
@ -140,7 +142,11 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e
|
|||||||
|
|
||||||
app.Namespace = namespace
|
app.Namespace = namespace
|
||||||
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcName
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcName
|
||||||
|
if checkImgFeat {
|
||||||
|
err = createAppErr(f.ClientSet, app, deployTimeout, "missing required parameter imageFeatures")
|
||||||
|
} else {
|
||||||
err = createApp(f.ClientSet, app, deployTimeout)
|
err = createApp(f.ClientSet, app, deployTimeout)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ var _ = Describe("CephFS Upgrade Testing", func() {
|
|||||||
e2elog.Failf("failed to expand pvc with error %v", err)
|
e2elog.Failf("failed to expand pvc with error %v", err)
|
||||||
}
|
}
|
||||||
// wait for application pod to come up after resize
|
// wait for application pod to come up after resize
|
||||||
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout, noError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("timeout waiting for pod to be in running state with error %v", err)
|
e2elog.Failf("timeout waiting for pod to be in running state with error %v", err)
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ var _ = Describe("RBD Upgrade Testing", func() {
|
|||||||
e2elog.Failf("failed to expand pvc with error %v", err)
|
e2elog.Failf("failed to expand pvc with error %v", err)
|
||||||
}
|
}
|
||||||
// wait for application pod to come up after resize
|
// wait for application pod to come up after resize
|
||||||
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout, noError)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Failf("timeout waiting for pod to be in running state with error %v", err)
|
e2elog.Failf("timeout waiting for pod to be in running state with error %v", err)
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ const (
|
|||||||
|
|
||||||
// vaultTokens KMS type
|
// vaultTokens KMS type
|
||||||
vaultTokens = "vaulttokens"
|
vaultTokens = "vaulttokens"
|
||||||
|
noError = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user