e2e: reformat long lines in this package to 120 chars

We have many declarations and invocations..etc with long lines which are
very difficult to follow while doing code reading. This address the issues
in 'e2e/cephfs*.go' files to restrict the line length to 120 chars.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-06-25 18:01:28 +05:30 committed by mergify[bot]
parent 404e011ae9
commit 49d11bf5ea
2 changed files with 64 additions and 15 deletions

View File

@ -160,7 +160,10 @@ func validateSubvolumePath(f *framework.Framework, pvcName, pvcNamespace, fileSy
return err return err
} }
if subVolumePath != subVolumePathInPV { if subVolumePath != subVolumePathInPV {
return fmt.Errorf("subvolumePath %s is not matching the subvolumePath %s in PV", subVolumePath, subVolumePathInPV) return fmt.Errorf(
"subvolumePath %s is not matching the subvolumePath %s in PV",
subVolumePath,
subVolumePathInPV)
} }
return nil return nil
} }
@ -226,11 +229,15 @@ var _ = Describe("cephfs", func() {
if err != nil { if err != nil {
e2elog.Failf("failed to delete configmap with error %v", err) e2elog.Failf("failed to delete configmap with error %v", err)
} }
err = c.CoreV1().Secrets(cephCSINamespace).Delete(context.TODO(), cephFSProvisionerSecretName, metav1.DeleteOptions{}) err = c.CoreV1().
Secrets(cephCSINamespace).
Delete(context.TODO(), cephFSProvisionerSecretName, metav1.DeleteOptions{})
if err != nil { if err != nil {
e2elog.Failf("failed to delete provisioner secret with error %v", err) e2elog.Failf("failed to delete provisioner secret with error %v", err)
} }
err = c.CoreV1().Secrets(cephCSINamespace).Delete(context.TODO(), cephFSNodePluginSecretName, metav1.DeleteOptions{}) err = c.CoreV1().
Secrets(cephCSINamespace).
Delete(context.TODO(), cephFSNodePluginSecretName, metav1.DeleteOptions{})
if err != nil { if err != nil {
e2elog.Failf("failed to delete node secret with error %v", err) e2elog.Failf("failed to delete node secret with error %v", err)
} }
@ -298,7 +305,11 @@ var _ = Describe("cephfs", func() {
By("create PVC in storageClass with volumeNamePrefix", func() { By("create PVC in storageClass with volumeNamePrefix", func() {
volumeNamePrefix := "foo-bar-" volumeNamePrefix := "foo-bar-"
err := createCephfsStorageClass(f.ClientSet, f, false, map[string]string{"volumeNamePrefix": volumeNamePrefix}) err := createCephfsStorageClass(
f.ClientSet,
f,
false,
map[string]string{"volumeNamePrefix": volumeNamePrefix})
if err != nil { if err != nil {
e2elog.Failf("failed to create storageclass with error %v", err) e2elog.Failf("failed to create storageclass with error %v", err)
} }
@ -591,7 +602,11 @@ var _ = Describe("cephfs", func() {
} }
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail(f, fmt.Sprintf("echo 'Hello World' > %s", filePath), app.Namespace, &opt) _, stdErr := execCommandInPodAndAllowFail(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
app.Namespace,
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) { if !strings.Contains(stdErr, readOnlyErr) {
e2elog.Failf(stdErr) e2elog.Failf(stdErr)
@ -1110,7 +1125,11 @@ var _ = Describe("cephfs", func() {
} }
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test" filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
_, stdErr := execCommandInPodAndAllowFail(f, fmt.Sprintf("echo 'Hello World' > %s", filePath), app.Namespace, &opt) _, stdErr := execCommandInPodAndAllowFail(
f,
fmt.Sprintf("echo 'Hello World' > %s", filePath),
app.Namespace,
&opt)
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath) readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
if !strings.Contains(stdErr, readOnlyErr) { if !strings.Contains(stdErr, readOnlyErr) {
e2elog.Failf(stdErr) e2elog.Failf(stdErr)

View File

@ -37,7 +37,11 @@ func validateSubvolumegroup(f *framework.Framework, subvolgrp string) error {
return nil return nil
} }
func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool, params map[string]string) error { func createCephfsStorageClass(
c kubernetes.Interface,
f *framework.Framework,
enablePool bool,
params map[string]string) error {
scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml") scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml")
sc, err := getStorageClass(scPath) sc, err := getStorageClass(scPath)
if err != nil { if err != nil {
@ -108,13 +112,24 @@ func unmountCephFSVolume(f *framework.Framework, appName, pvcName string) error
e2elog.Logf("Error occurred getting pod %s in namespace %s", appName, f.UniqueName) e2elog.Logf("Error occurred getting pod %s in namespace %s", appName, f.UniqueName)
return fmt.Errorf("failed to get pod: %w", err) return fmt.Errorf("failed to get pod: %w", err)
} }
pvc, err := f.ClientSet.CoreV1().PersistentVolumeClaims(f.UniqueName).Get(context.TODO(), pvcName, metav1.GetOptions{}) pvc, err := f.ClientSet.CoreV1().
PersistentVolumeClaims(f.UniqueName).
Get(context.TODO(), pvcName, metav1.GetOptions{})
if err != nil { if err != nil {
e2elog.Logf("Error occurred getting PVC %s in namespace %s", pvcName, f.UniqueName) e2elog.Logf("Error occurred getting PVC %s in namespace %s", pvcName, f.UniqueName)
return fmt.Errorf("failed to get pvc: %w", err) return fmt.Errorf("failed to get pvc: %w", err)
} }
cmd := fmt.Sprintf("umount /var/lib/kubelet/pods/%s/volumes/kubernetes.io~csi/%s/mount", pod.UID, pvc.Spec.VolumeName) cmd := fmt.Sprintf(
_, stdErr, err := execCommandInDaemonsetPod(f, cmd, cephfsDeamonSetName, pod.Spec.NodeName, cephfsContainerName, cephCSINamespace) "umount /var/lib/kubelet/pods/%s/volumes/kubernetes.io~csi/%s/mount",
pod.UID,
pvc.Spec.VolumeName)
_, stdErr, err := execCommandInDaemonsetPod(
f,
cmd,
cephfsDeamonSetName,
pod.Spec.NodeName,
cephfsContainerName,
cephCSINamespace)
if stdErr != "" { if stdErr != "" {
e2elog.Logf("StdErr occurred: %s", stdErr) e2elog.Logf("StdErr occurred: %s", stdErr)
} }
@ -144,7 +159,10 @@ type cephfsSubVolume struct {
func listCephFSSubVolumes(f *framework.Framework, filesystem, groupname string) ([]cephfsSubVolume, error) { func listCephFSSubVolumes(f *framework.Framework, filesystem, groupname string) ([]cephfsSubVolume, error) {
var subVols []cephfsSubVolume var subVols []cephfsSubVolume
stdout, stdErr, err := execCommandInToolBoxPod(f, fmt.Sprintf("ceph fs subvolume ls %s --group_name=%s --format=json", filesystem, groupname), rookNamespace) stdout, stdErr, err := execCommandInToolBoxPod(
f,
fmt.Sprintf("ceph fs subvolume ls %s --group_name=%s --format=json", filesystem, groupname),
rookNamespace)
if err != nil { if err != nil {
return subVols, err return subVols, err
} }
@ -177,11 +195,15 @@ func getSnapName(snapNamespace, snapName string) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
snap, err := sclient.VolumeSnapshots(snapNamespace).Get(context.TODO(), snapName, metav1.GetOptions{}) snap, err := sclient.
VolumeSnapshots(snapNamespace).
Get(context.TODO(), snapName, metav1.GetOptions{})
if err != nil { if err != nil {
return "", fmt.Errorf("failed to get volumesnapshot: %w", err) return "", fmt.Errorf("failed to get volumesnapshot: %w", err)
} }
sc, err := sclient.VolumeSnapshotContents().Get(context.TODO(), *snap.Status.BoundVolumeSnapshotContentName, metav1.GetOptions{}) sc, err := sclient.
VolumeSnapshotContents().
Get(context.TODO(), *snap.Status.BoundVolumeSnapshotContentName, metav1.GetOptions{})
if err != nil { if err != nil {
return "", fmt.Errorf("failed to get volumesnapshotcontent: %w", err) return "", fmt.Errorf("failed to get volumesnapshotcontent: %w", err)
} }
@ -192,7 +214,10 @@ func getSnapName(snapNamespace, snapName string) (string, error) {
return snapshotName, nil return snapshotName, nil
} }
func deleteBackingCephFSSubvolumeSnapshot(f *framework.Framework, pvc *v1.PersistentVolumeClaim, snap *snapapi.VolumeSnapshot) error { func deleteBackingCephFSSubvolumeSnapshot(
f *framework.Framework,
pvc *v1.PersistentVolumeClaim,
snap *snapapi.VolumeSnapshot) error {
snapshotName, err := getSnapName(snap.Namespace, snap.Name) snapshotName, err := getSnapName(snap.Namespace, snap.Name)
if err != nil { if err != nil {
return err return err
@ -201,7 +226,12 @@ func deleteBackingCephFSSubvolumeSnapshot(f *framework.Framework, pvc *v1.Persis
if err != nil { if err != nil {
return err return err
} }
cmd := fmt.Sprintf("ceph fs subvolume snapshot rm %s %s %s %s", fileSystemName, imageData.imageName, snapshotName, subvolumegroup) cmd := fmt.Sprintf(
"ceph fs subvolume snapshot rm %s %s %s %s",
fileSystemName,
imageData.imageName,
snapshotName,
subvolumegroup)
_, stdErr, err := execCommandInToolBoxPod(f, cmd, rookNamespace) _, stdErr, err := execCommandInToolBoxPod(f, cmd, rookNamespace)
if err != nil { if err != nil {
return err return err