e2e: remove passing waitgroups for go routines

We are unwantedly passing around waitgroups which is not required.
This address the same inside e2e/utils.go and remove waitgroup arg

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-06-28 15:23:33 +05:30 committed by mergify[bot]
parent 053f7ee213
commit 4657ac7f00

View File

@ -600,7 +600,7 @@ func validatePVCClone(
wg.Add(totalCount) wg.Add(totalCount)
// create clone and bind it to an app // create clone and bind it to an app
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
label := make(map[string]string) label := make(map[string]string)
label[appKey] = name label[appKey] = name
@ -625,8 +625,8 @@ func validatePVCClone(
if wgErrs[n] == nil && validatePVC != nil { if wgErrs[n] == nil && validatePVC != nil {
wgErrs[n] = validatePVC(f, &p, &a) wgErrs[n] = validatePVC(f, &p, &a)
} }
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()
@ -668,12 +668,12 @@ func validatePVCClone(
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a) wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()
@ -699,8 +699,6 @@ func validatePVCSnapshot(
var wg sync.WaitGroup var wg sync.WaitGroup
wgErrs := make([]error, totalCount) wgErrs := make([]error, totalCount)
chErrs := make([]error, totalCount) chErrs := make([]error, totalCount)
wg.Add(totalCount)
err := createRBDSnapshotClass(f) err := createRBDSnapshotClass(f)
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)
@ -742,9 +740,11 @@ func validatePVCSnapshot(
snap := getSnapshot(snapshotPath) snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
wg.Add(totalCount)
// create snapshot // create snapshot
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout) wgErrs[n] = createSnapshot(&s, deployTimeout)
if wgErrs[n] == nil && kms != "" { if wgErrs[n] == nil && kms != "" {
@ -765,8 +765,8 @@ func validatePVCSnapshot(
} }
} }
} }
w.Done() wg.Done()
}(&wg, i, snap) }(i, snap)
} }
wg.Wait() wg.Wait()
@ -799,7 +799,7 @@ func validatePVCSnapshot(
// create multiple PVC from same snapshot // create multiple PVC from same snapshot
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
label := make(map[string]string) label := make(map[string]string)
label[appKey] = name label[appKey] = name
@ -827,8 +827,8 @@ func validatePVCSnapshot(
if wgErrs[n] == nil && kms != "" { if wgErrs[n] == nil && kms != "" {
wgErrs[n] = isEncryptedPVC(f, &p, &a) wgErrs[n] = isEncryptedPVC(f, &p, &a)
} }
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()
@ -860,12 +860,12 @@ func validatePVCSnapshot(
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a) wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()
@ -887,12 +887,12 @@ func validatePVCSnapshot(
// app // app
wg.Add(totalCount) wg.Add(totalCount)
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout) wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()
@ -923,7 +923,7 @@ func validatePVCSnapshot(
wg.Add(totalCount) wg.Add(totalCount)
// delete snapshot // delete snapshot
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, s snapapi.VolumeSnapshot) { go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n) s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
content := &snapapi.VolumeSnapshotContent{} content := &snapapi.VolumeSnapshotContent{}
var err error var err error
@ -951,8 +951,8 @@ func validatePVCSnapshot(
} }
} }
} }
w.Done() wg.Done()
}(&wg, i, snap) }(i, snap)
} }
wg.Wait() wg.Wait()
@ -971,12 +971,12 @@ func validatePVCSnapshot(
wg.Add(totalCount) wg.Add(totalCount)
// delete clone and app // delete clone and app
for i := 0; i < totalCount; i++ { for i := 0; i < totalCount; i++ {
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) { go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n) name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a) wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
w.Done() wg.Done()
}(&wg, i, *pvcClone, *appClone) }(i, *pvcClone, *appClone)
} }
wg.Wait() wg.Wait()