Skip to content

Commit

Permalink
chore: apply gofumpt in test packages
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 committed Jan 14, 2025
1 parent ddc1bcb commit 656e150
Show file tree
Hide file tree
Showing 50 changed files with 270 additions and 173 deletions.
4 changes: 2 additions & 2 deletions test/e2e/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
It("should be successfully backed up and restored to the default BackupStorageLocation", func() {
if InstallVelero {
if useVolumeSnapshots {
//Install node agent also
// Install node agent also
veleroCfg.UseNodeAgent = useVolumeSnapshots
// DefaultVolumesToFsBackup should be mutually exclusive with useVolumeSnapshots in installation CLI,
// otherwise DefaultVolumesToFsBackup need to be set to false in backup CLI when taking volume snapshot
Expand Down Expand Up @@ -162,7 +162,7 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
if InstallVelero {
if useVolumeSnapshots {
veleroCfg.DefaultVolumesToFsBackup = !useVolumeSnapshots
} else { //FS volume backup
} else { // FS volume backup
// Install VolumeSnapshots also
veleroCfg.UseVolumeSnapshots = !useVolumeSnapshots
// DefaultVolumesToFsBackup is false in installation CLI here,
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/backups/deletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func BackupDeletionWithSnapshots() {
func BackupDeletionWithRestic() {
backup_deletion_test(false)
}

func backup_deletion_test(useVolumeSnapshots bool) {
veleroCfg := VeleroCfg
veleroCfg.UseVolumeSnapshots = useVolumeSnapshots
Expand Down Expand Up @@ -81,7 +82,8 @@ func backup_deletion_test(useVolumeSnapshots bool) {

// runUpgradeTests runs upgrade test on the provider by kibishii.
func runBackupDeletionTests(client TestClient, veleroCfg VeleroConfig, backupLocation string,
useVolumeSnapshots bool, kibishiiDirectory string) error {
useVolumeSnapshots bool, kibishiiDirectory string,
) error {
var err error
var snapshotCheckPoint SnapshotCheckPoint
backupName := "backup-" + UUIDgen.String()
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/backups/sync_backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ func (b *SyncBackups) Init() {

func BackupsSyncTest() {
test := new(SyncBackups)
var (
err error
)
var err error
veleroCfg := VeleroCfg
BeforeEach(func() {
flag.Parse()
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/basic/api-group/enable_api_group_extentions.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import (
)

func APIExtensionsVersionsTest() {
var (
backupName, restoreName string
)
var backupName, restoreName string

resourceName := "apiextensions.k8s.io"
crdName := "rocknrollbands.music.example.io"
Expand Down
1 change: 1 addition & 0 deletions test/e2e/basic/backup-volume-info/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (v *BackupVolumeInfo) Start() error {
v.TestCase.Start()
return nil
}

func (v *BackupVolumeInfo) CreateResources() error {
labels := map[string]string{
"volume-info": "true",
Expand Down
10 changes: 6 additions & 4 deletions test/e2e/basic/namespace-mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ type NamespaceMapping struct {

const NamespaceBaseName string = "ns-mp-"

var OneNamespaceMappingResticTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 1, UseVolumeSnapshots: false}})
var MultiNamespacesMappingResticTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 2, UseVolumeSnapshots: false}})
var OneNamespaceMappingSnapshotTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 1, UseVolumeSnapshots: true}})
var MultiNamespacesMappingSnapshotTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 2, UseVolumeSnapshots: true}})
var (
OneNamespaceMappingResticTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 1, UseVolumeSnapshots: false}})
MultiNamespacesMappingResticTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 2, UseVolumeSnapshots: false}})
OneNamespaceMappingSnapshotTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 1, UseVolumeSnapshots: true}})
MultiNamespacesMappingSnapshotTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 2, UseVolumeSnapshots: true}})
)

func (n *NamespaceMapping) Init() error {
n.TestCase.Init()
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/basic/nodeport.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ func (n *NodePort) Restore() error {
}

func createServiceWithNodeport(ctx context.Context, client TestClient, namespace string,
service string, labels map[string]string, nodePort int32) error {
service string, labels map[string]string, nodePort int32,
) error {
serviceSpec := &v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/basic/pvc-selected-node-changing.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ func (p *PVCSelectedNodeChanging) Init() error {
}
p.BackupName = "backup-" + p.CaseBaseName
p.RestoreName = "restore-" + p.CaseBaseName
p.labels = map[string]string{"velero.io/plugin-config": "",
"velero.io/change-pvc-node-selector": "RestoreItemAction"}
p.labels = map[string]string{
"velero.io/plugin-config": "",
"velero.io/change-pvc-node-selector": "RestoreItemAction",
}
p.configmaptName = "change-pvc-node-selector-config"
p.volume = "volume-1"
p.podName = "pod-1"
Expand Down Expand Up @@ -128,6 +130,7 @@ func (p *PVCSelectedNodeChanging) Restore() error {
})
return nil
}

func (p *PVCSelectedNodeChanging) Verify() error {
By(fmt.Sprintf("PVC selected node should be %s", p.newNodeName), func() {
pvcNameList, err := GetPvcByPVCName(p.Ctx, p.mappedNS, p.pvcName)
Expand Down
1 change: 0 additions & 1 deletion test/e2e/basic/resources-check/namespaces_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func (n *NSAnnotationCase) Verify() error {
checkNSName := fmt.Sprintf("%s-%00000d", n.CaseBaseName, nsNum)
checkAnnoName := fmt.Sprintf("annotation-%s-%00000d", n.CaseBaseName, nsNum)
checkNS, err := GetNamespace(n.Ctx, n.Client, checkNSName)

if err != nil {
return errors.Wrapf(err, "Could not retrieve test namespace %s", checkNSName)
}
Expand Down
15 changes: 6 additions & 9 deletions test/e2e/basic/resources-check/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ func (r *RBACCase) Verify() error {
return errors.Errorf("Retrieved namespace for %s has name %s instead", checkNSName, checkNS.Name)
}

//getting service account from the restore
// getting service account from the restore
checkSA, err := GetServiceAccount(r.Ctx, r.Client, checkNSName, checkServiceAccountName)

if err != nil {
return errors.Wrapf(err, "Could not retrieve test service account %s", checkSA)
}
Expand All @@ -123,9 +122,8 @@ func (r *RBACCase) Verify() error {
return errors.Errorf("Retrieved service account for %s has name %s instead", checkServiceAccountName, checkSA.Name)
}

//getting cluster role from the restore
// getting cluster role from the restore
checkClusterRole, err := GetClusterRole(r.Ctx, r.Client, checkClusterRoleName)

if err != nil {
return errors.Wrapf(err, "Could not retrieve test cluster role %s", checkClusterRole)
}
Expand All @@ -134,9 +132,8 @@ func (r *RBACCase) Verify() error {
return errors.Errorf("Retrieved cluster role for %s has name %s instead", checkClusterRoleName, checkClusterRole.Name)
}

//getting cluster role binding from the restore
// getting cluster role binding from the restore
checkClusterRoleBinding, err := GetClusterRoleBinding(r.Ctx, r.Client, checkClusterRoleBindingName)

if err != nil {
return errors.Wrapf(err, "Could not retrieve test cluster role binding %s", checkClusterRoleBinding)
}
Expand All @@ -145,7 +142,7 @@ func (r *RBACCase) Verify() error {
return errors.Errorf("Retrieved cluster role binding for %s has name %s instead", checkClusterRoleBindingName, checkClusterRoleBinding.Name)
}

//check if the role binding maps to service account
// check if the role binding maps to service account
checkSubjects := checkClusterRoleBinding.Subjects[0].Name

if checkSubjects != checkServiceAccountName {
Expand All @@ -156,13 +153,13 @@ func (r *RBACCase) Verify() error {
}

func (r *RBACCase) Destroy() error {
//cleanup clusterrole
// cleanup clusterrole
err := CleanupClusterRole(r.Ctx, r.Client, r.CaseBaseName)
if err != nil {
return errors.Wrap(err, "Could not cleanup clusterroles")
}

//cleanup cluster rolebinding
// cleanup cluster rolebinding
err = CleanupClusterRoleBinding(r.Ctx, r.Client, r.CaseBaseName)
if err != nil {
return errors.Wrap(err, "Could not cleanup clusterrolebindings")
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/basic/storage-class-changing.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ func (s *StorageClasssChanging) Init() error {
}
s.srcStorageClass = StorageClassName
s.desStorageClass = StorageClassName2
s.labels = map[string]string{"velero.io/change-storage-class": "RestoreItemAction",
"velero.io/plugin-config": ""}
s.labels = map[string]string{
"velero.io/change-storage-class": "RestoreItemAction",
"velero.io/plugin-config": "",
}
s.data = map[string]string{s.srcStorageClass: s.desStorageClass}
s.cmName = "change-storage-class-config"
s.volume = "volume-1"
Expand Down Expand Up @@ -124,6 +126,7 @@ func (s *StorageClasssChanging) Restore() error {
})
return nil
}

func (s *StorageClasssChanging) Verify() error {
By(fmt.Sprintf("Expect storage class of PV %s to be %s ", s.volume, s.desStorageClass), func() {
Expect(WaitForReadyDeployment(s.Client.ClientGo, s.mappedNS, s.deploymentName)).To(Succeed())
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/bsl-mgmt/deletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func BslDeletionWithSnapshots() {
func BslDeletionWithRestic() {
BslDeletionTest(false)
}

func BslDeletionTest(useVolumeSnapshots bool) {
var (
err error
Expand Down Expand Up @@ -143,7 +144,7 @@ func BslDeletionTest(useVolumeSnapshots bool) {

label1 := "for=1"
// TODO remove when issue https://github.com/vmware-tanzu/velero/issues/4724 is fixed
//label2 := "for!=1"
// label2 := "for!=1"
label2 := "for=2"
By("Create namespace for sample workload", func() {
Expect(CreateNamespace(oneHourTimeout, *veleroCfg.ClientToInstallVelero, bslDeletionTestNs)).To(Succeed())
Expand Down
Loading

0 comments on commit 656e150

Please sign in to comment.