2021-12-21 14:23:26 +00:00
|
|
|
/*
|
|
|
|
Copyright 2021 The Ceph-CSI Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-07-25 16:40:28 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-09-30 13:28:18 +00:00
|
|
|
"fmt"
|
2020-07-25 16:40:28 +00:00
|
|
|
"os"
|
2020-09-30 13:28:18 +00:00
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
2020-07-25 16:40:28 +00:00
|
|
|
|
2022-04-21 05:27:48 +00:00
|
|
|
. "github.com/onsi/ginkgo/v2" // nolint
|
2020-07-25 16:40:28 +00:00
|
|
|
v1 "k8s.io/api/core/v1"
|
|
|
|
"k8s.io/apimachinery/pkg/api/resource"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
clientset "k8s.io/client-go/kubernetes"
|
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
|
|
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("RBD Upgrade Testing", func() {
|
|
|
|
f := framework.NewDefaultFramework("upgrade-test-rbd")
|
|
|
|
var (
|
|
|
|
// cwd stores the initial working directory.
|
|
|
|
cwd string
|
|
|
|
c clientset.Interface
|
|
|
|
pvc *v1.PersistentVolumeClaim
|
|
|
|
app *v1.Pod
|
2020-09-30 13:28:18 +00:00
|
|
|
// checkSum stores the md5sum of a file to verify uniqueness.
|
|
|
|
checkSum string
|
|
|
|
)
|
|
|
|
const (
|
|
|
|
pvcSize = "2Gi"
|
|
|
|
appKey = "app"
|
|
|
|
appLabel = "rbd-upgrade-testing"
|
2020-07-25 16:40:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// deploy rbd CSI
|
|
|
|
BeforeEach(func() {
|
|
|
|
if !upgradeTesting || !testRBD {
|
|
|
|
Skip("Skipping RBD Upgrade Testing")
|
|
|
|
}
|
|
|
|
c = f.ClientSet
|
|
|
|
if cephCSINamespace != defaultNs {
|
|
|
|
err := createNamespace(c, cephCSINamespace)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create namespace: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// fetch current working directory to switch back
|
|
|
|
// when we are done upgrading.
|
|
|
|
var err error
|
|
|
|
cwd, err = os.Getwd()
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to do getwd: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
deployVault(f.ClientSet, deployTimeout)
|
|
|
|
err = upgradeAndDeployCSI(upgradeVersion, "rbd")
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to upgrade and deploy CSI: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = createConfigMap(rbdDirPath, f.ClientSet, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create configmap: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-02-22 11:13:40 +00:00
|
|
|
// create rbd provisioner secret
|
|
|
|
key, err := createCephUser(f, keyringRBDProvisionerUsername, rbdProvisionerCaps("", ""))
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create user %s: %v", keyringRBDProvisionerUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
err = createRBDSecret(f, rbdProvisionerSecretName, keyringRBDProvisionerUsername, key)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create provisioner secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
// create rbd plugin secret
|
|
|
|
key, err = createCephUser(f, keyringRBDNodePluginUsername, rbdNodePluginCaps("", ""))
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create user %s: %v", keyringRBDNodePluginUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
err = createRBDSecret(f, rbdNodePluginSecretName, keyringRBDNodePluginUsername, key)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create node secret: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-09-30 13:28:18 +00:00
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create snapshotclass: %v", err)
|
2020-09-30 13:28:18 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
|
|
|
|
err = createNodeLabel(f, nodeRegionLabel, regionValue)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = createNodeLabel(f, nodeZoneLabel, zoneValue)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create node label: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
AfterEach(func() {
|
|
|
|
if !testRBD || !upgradeTesting {
|
|
|
|
Skip("Skipping RBD Upgrade Testing")
|
|
|
|
}
|
|
|
|
if CurrentGinkgoTestDescription().Failed {
|
|
|
|
// log pods created by helm chart
|
|
|
|
logsCSIPods("app=ceph-csi-rbd", c)
|
|
|
|
// log provisoner
|
|
|
|
logsCSIPods("app=csi-rbdplugin-provisioner", c)
|
|
|
|
// log node plugin
|
|
|
|
logsCSIPods("app=csi-rbdplugin", c)
|
2020-12-03 11:00:22 +00:00
|
|
|
|
|
|
|
// log all details from the namespace where Ceph-CSI is deployed
|
|
|
|
framework.DumpAllNamespaceInfo(c, cephCSINamespace)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteConfigMap(rbdDirPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete configmap: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-06-25 13:07:12 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), rbdProvisionerSecretName, metav1.DeleteOptions{})
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete provisioner secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2021-06-25 13:07:12 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), rbdNodePluginSecretName, metav1.DeleteOptions{})
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete node secret: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-09-30 13:28:18 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "snapshotclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete snapshotclass: %v", err)
|
2020-09-30 13:28:18 +00:00
|
|
|
}
|
2020-07-25 16:40:28 +00:00
|
|
|
deleteVault()
|
|
|
|
if deployRBD {
|
|
|
|
deleteRBDPlugin()
|
|
|
|
if cephCSINamespace != defaultNs {
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteNamespace(c, cephCSINamespace)
|
2020-07-25 16:40:28 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete namespace: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteNodeLabel(c, nodeRegionLabel)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = deleteNodeLabel(c, nodeZoneLabel)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-07-25 16:40:28 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
Context("Test RBD CSI", func() {
|
2022-04-19 09:25:54 +00:00
|
|
|
if !testRBD || !upgradeTesting {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-07-25 16:40:28 +00:00
|
|
|
It("Test RBD CSI", func() {
|
|
|
|
pvcPath := rbdExamplePath + "pvc.yaml"
|
|
|
|
appPath := rbdExamplePath + "pod.yaml"
|
|
|
|
|
|
|
|
By("checking provisioner deployment is running", func() {
|
2021-10-29 08:36:30 +00:00
|
|
|
err := waitForDeploymentComplete(f.ClientSet, rbdDeploymentName, cephCSINamespace, deployTimeout)
|
2020-07-25 16:40:28 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("timeout waiting for deployment %s: %v", rbdDeploymentName, err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("checking nodeplugin deamonset pods are running", func() {
|
2020-07-25 16:40:28 +00:00
|
|
|
err := waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset %s: %v", rbdDaemonsetName, err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("upgrade to latest changes and verify app re-mount", func() {
|
|
|
|
// TODO: fetch pvc size from spec.
|
|
|
|
var err error
|
2020-09-30 13:28:18 +00:00
|
|
|
label := make(map[string]string)
|
|
|
|
data := "check data persists"
|
2020-10-14 09:37:58 +00:00
|
|
|
|
2020-07-25 16:40:28 +00:00
|
|
|
pvc, err = loadPVC(pvcPath)
|
2020-10-20 09:55:09 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to load pvc: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err = loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
2020-09-30 13:28:18 +00:00
|
|
|
label[appKey] = appLabel
|
2020-07-25 16:40:28 +00:00
|
|
|
app.Namespace = f.UniqueName
|
2020-09-30 13:28:18 +00:00
|
|
|
app.Labels = label
|
2020-07-25 16:40:28 +00:00
|
|
|
pvc.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create pvc: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
2020-09-30 13:28:18 +00:00
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
|
|
|
|
}
|
|
|
|
// fetch the path where volume is mounted.
|
|
|
|
mountPath := app.Spec.Containers[0].VolumeMounts[0].MountPath
|
|
|
|
filePath := filepath.Join(mountPath, "testClone")
|
|
|
|
|
|
|
|
// create a test file at the mountPath.
|
2021-06-25 13:07:12 +00:00
|
|
|
_, stdErr := execCommandInPodAndAllowFail(
|
|
|
|
f,
|
|
|
|
fmt.Sprintf("echo %s > %s", data, filePath),
|
|
|
|
app.Namespace,
|
|
|
|
&opt)
|
2020-09-30 13:28:18 +00:00
|
|
|
if stdErr != "" {
|
|
|
|
e2elog.Failf("failed to write data to a file %s", stdErr)
|
|
|
|
}
|
|
|
|
|
|
|
|
// force an immediate write of all cached data to disk.
|
|
|
|
_, stdErr = execCommandInPodAndAllowFail(f, fmt.Sprintf("sync %s", filePath), app.Namespace, &opt)
|
|
|
|
if stdErr != "" {
|
|
|
|
e2elog.Failf("failed to sync data to a disk %s", stdErr)
|
|
|
|
}
|
|
|
|
|
|
|
|
opt = metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", appLabel),
|
|
|
|
}
|
|
|
|
e2elog.Logf("Calculating checksum of %s", filePath)
|
|
|
|
checkSum, err = calculateSHA512sum(f, app, filePath, &opt)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to calculate checksum: %v", err)
|
2020-09-30 13:28:18 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 11:21:24 +00:00
|
|
|
// Create snapshot of the pvc
|
|
|
|
snapshotPath := rbdExamplePath + "snapshot.yaml"
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Name = "rbd-pvc-snapshot"
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create snapshot %v", err)
|
2020-09-30 13:28:18 +00:00
|
|
|
}
|
2022-04-11 11:21:24 +00:00
|
|
|
|
2020-07-25 16:40:28 +00:00
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
deleteRBDPlugin()
|
|
|
|
|
|
|
|
err = os.Chdir(cwd)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to change directory: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
deployRBDPlugin()
|
2021-05-17 09:58:15 +00:00
|
|
|
|
2021-10-29 08:36:30 +00:00
|
|
|
err = waitForDeploymentComplete(f.ClientSet, rbdDeploymentName, cephCSINamespace, deployTimeout)
|
2021-05-17 09:58:15 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("timeout waiting for upgraded deployment %s: %v", rbdDeploymentName, err)
|
2021-05-17 09:58:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("timeout waiting for upgraded daemonset %s: %v", rbdDaemonsetName, err)
|
2021-05-17 09:58:15 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 16:40:28 +00:00
|
|
|
// validate if the app gets bound to a pvc created by
|
|
|
|
// an earlier release.
|
2020-09-30 13:28:18 +00:00
|
|
|
app.Labels = label
|
2020-07-25 16:40:28 +00:00
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-30 13:28:18 +00:00
|
|
|
By("Create clone from a snapshot", func() {
|
|
|
|
pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
|
|
|
|
appClonePath := rbdExamplePath + "pod-restore.yaml"
|
|
|
|
label := make(map[string]string)
|
2022-04-11 11:21:24 +00:00
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load pvc: %v", err)
|
|
|
|
}
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
|
|
|
|
pvcClone.Spec.DataSource.Name = "rbd-pvc-snapshot"
|
|
|
|
appClone, err := loadApp(appClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
|
|
|
}
|
|
|
|
label[appKey] = "validate-snap-clone"
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
appClone.Name = "app-clone-from-snap"
|
|
|
|
appClone.Labels = label
|
|
|
|
err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create pvc: %v", err)
|
|
|
|
}
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
|
|
|
|
}
|
|
|
|
mountPath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath
|
|
|
|
testFilePath := filepath.Join(mountPath, "testClone")
|
|
|
|
newCheckSum, err := calculateSHA512sum(f, appClone, testFilePath, &opt)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to calculate checksum: %v", err)
|
|
|
|
}
|
|
|
|
if strings.Compare(newCheckSum, checkSum) != 0 {
|
|
|
|
e2elog.Failf(
|
|
|
|
"The checksum of files did not match, expected %s received %s",
|
|
|
|
checkSum,
|
|
|
|
newCheckSum)
|
|
|
|
}
|
|
|
|
e2elog.Logf("The checksum of files matched")
|
2020-10-14 09:37:58 +00:00
|
|
|
|
2022-04-11 11:21:24 +00:00
|
|
|
// delete cloned pvc and pod
|
|
|
|
err = deletePVCAndApp("", f, pvcClone, appClone)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc and application: %v", err)
|
2020-09-30 13:28:18 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("Create clone from existing PVC", func() {
|
|
|
|
pvcSmartClonePath := rbdExamplePath + "pvc-clone.yaml"
|
|
|
|
appSmartClonePath := rbdExamplePath + "pod-clone.yaml"
|
|
|
|
label := make(map[string]string)
|
2020-10-14 09:37:58 +00:00
|
|
|
|
2022-04-11 11:21:24 +00:00
|
|
|
pvcClone, err := loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load pvc: %v", err)
|
|
|
|
}
|
|
|
|
pvcClone.Spec.DataSource.Name = pvc.Name
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.Resources.Requests[v1.ResourceStorage] = resource.MustParse(pvcSize)
|
|
|
|
appClone, err := loadApp(appSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
|
|
|
}
|
|
|
|
label[appKey] = "validate-clone"
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
appClone.Name = "appclone"
|
|
|
|
appClone.Labels = label
|
|
|
|
err = createPVCAndApp("", f, pvcClone, appClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create pvc: %v", err)
|
|
|
|
}
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
|
|
|
|
}
|
|
|
|
mountPath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath
|
|
|
|
testFilePath := filepath.Join(mountPath, "testClone")
|
|
|
|
newCheckSum, err := calculateSHA512sum(f, appClone, testFilePath, &opt)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to calculate checksum: %v", err)
|
|
|
|
}
|
|
|
|
if strings.Compare(newCheckSum, checkSum) != 0 {
|
|
|
|
e2elog.Failf(
|
|
|
|
"The checksum of files did not match, expected %s received %s",
|
|
|
|
checkSum,
|
|
|
|
newCheckSum)
|
|
|
|
}
|
|
|
|
e2elog.Logf("The checksum of files matched")
|
2020-09-30 13:28:18 +00:00
|
|
|
|
2022-04-11 11:21:24 +00:00
|
|
|
// delete cloned pvc and pod
|
|
|
|
err = deletePVCAndApp("", f, pvcClone, appClone)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc and application: %v", err)
|
2020-09-30 13:28:18 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-07-25 16:40:28 +00:00
|
|
|
By("Resize pvc and verify expansion", func() {
|
|
|
|
pvcExpandSize := "5Gi"
|
2020-09-30 13:28:18 +00:00
|
|
|
label := make(map[string]string)
|
2020-10-14 09:37:58 +00:00
|
|
|
|
2022-04-11 11:21:24 +00:00
|
|
|
label[appKey] = appLabel
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
|
|
|
|
}
|
|
|
|
var err error
|
2022-05-06 06:59:50 +00:00
|
|
|
pvc, err = getPersistentVolumeClaim(f.ClientSet, pvc.Namespace, pvc.Name)
|
2022-04-11 11:21:24 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to get pvc: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// resize PVC
|
|
|
|
err = expandPVCSize(f.ClientSet, pvc, pvcExpandSize, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to expand pvc: %v", err)
|
|
|
|
}
|
|
|
|
// wait for application pod to come up after resize
|
|
|
|
err = waitForPodInRunningState(app.Name, app.Namespace, f.ClientSet, deployTimeout, noError)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("timeout waiting for pod to be in running state: %v", err)
|
|
|
|
}
|
|
|
|
// validate if resize is successful.
|
|
|
|
err = checkDirSize(app, f, &opt, pvcExpandSize)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to check directory size: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("delete pvc and app", func() {
|
|
|
|
err := deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete pvc and application: %v", err)
|
2020-07-25 16:40:28 +00:00
|
|
|
}
|
|
|
|
})
|
2021-02-22 11:13:40 +00:00
|
|
|
// delete RBD provisioner secret
|
|
|
|
err := deleteCephUser(f, keyringRBDProvisionerUsername)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete user %s: %v", keyringRBDProvisionerUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
// delete RBD plugin secret
|
|
|
|
err = deleteCephUser(f, keyringRBDNodePluginUsername)
|
|
|
|
if err != nil {
|
2021-11-22 06:54:05 +00:00
|
|
|
e2elog.Failf("failed to delete user %s: %v", keyringRBDNodePluginUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2020-07-25 16:40:28 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|