mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
e2e: do not use Failf() to abort tests in a go-routine (rbd)
There are several go-routines where Failf() is called, which will cause a Golang panic inside the Ginko test framework. Instead of aborting the go-routine, capture the error and check for failures once all go-routines have finished. The CephFS tests have been updated already, this changs only affects the RBD tests. Updates: #1359 Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
96eafecad8
commit
45d64ab7d0
99
e2e/rbd.go
99
e2e/rbd.go
@ -361,6 +361,7 @@ var _ = Describe("RBD", func() {
|
|||||||
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
|
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
totalCount := 10
|
totalCount := 10
|
||||||
|
wgErrs := make([]error, totalCount)
|
||||||
wg.Add(totalCount)
|
wg.Add(totalCount)
|
||||||
err := createRBDSnapshotClass(f)
|
err := createRBDSnapshotClass(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -384,15 +385,24 @@ var _ = Describe("RBD", func() {
|
|||||||
for i := 0; i < totalCount; i++ {
|
for i := 0; i < totalCount; i++ {
|
||||||
go func(w *sync.WaitGroup, n int, s v1beta1.VolumeSnapshot) {
|
go func(w *sync.WaitGroup, n int, s v1beta1.VolumeSnapshot) {
|
||||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||||
err = createSnapshot(&s, deployTimeout)
|
wgErrs[n] = createSnapshot(&s, deployTimeout)
|
||||||
if err != nil {
|
|
||||||
e2elog.Failf("failed to create snapshot with error %v", err)
|
|
||||||
}
|
|
||||||
w.Done()
|
w.Done()
|
||||||
}(&wg, i, snap)
|
}(&wg, i, snap)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
failed := 0
|
||||||
|
for i, err := range wgErrs {
|
||||||
|
if err != nil {
|
||||||
|
// not using Failf() as it aborts the test and does not log other errors
|
||||||
|
e2elog.Logf("failed to create snapshot (%s%d): %v", f.UniqueName, i, err)
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if failed != 0 {
|
||||||
|
e2elog.Failf("creating snapshots failed, %d errors were logged", failed)
|
||||||
|
}
|
||||||
|
|
||||||
// total images in cluster is 1 parent rbd image+ total snaps
|
// total images in cluster is 1 parent rbd image+ total snaps
|
||||||
validateRBDImageCount(f, totalCount+1)
|
validateRBDImageCount(f, totalCount+1)
|
||||||
pvcClone, err := loadPVC(pvcClonePath)
|
pvcClone, err := loadPVC(pvcClonePath)
|
||||||
@ -412,15 +422,23 @@ var _ = Describe("RBD", func() {
|
|||||||
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(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
||||||
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
name := fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||||
err = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
||||||
if err != nil {
|
|
||||||
e2elog.Failf("failed to create PVC and application with error %v", err)
|
|
||||||
}
|
|
||||||
w.Done()
|
w.Done()
|
||||||
}(&wg, i, *pvcClone, *appClone)
|
}(&wg, i, *pvcClone, *appClone)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
for i, err := range wgErrs {
|
||||||
|
if err != nil {
|
||||||
|
// not using Failf() as it aborts the test and does not log other errors
|
||||||
|
e2elog.Logf("failed to create PVC and application (%s%d): %v", f.UniqueName, i, err)
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if failed != 0 {
|
||||||
|
e2elog.Failf("creating PVCs and applications failed, %d errors were logged", failed)
|
||||||
|
}
|
||||||
|
|
||||||
// total images in cluster is 1 parent rbd image+ total
|
// total images in cluster is 1 parent rbd image+ total
|
||||||
// snaps+ total clones
|
// snaps+ total clones
|
||||||
totalCloneCount := totalCount + totalCount + 1
|
totalCloneCount := totalCount + totalCount + 1
|
||||||
@ -431,15 +449,23 @@ var _ = Describe("RBD", func() {
|
|||||||
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
go func(w *sync.WaitGroup, 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
|
||||||
err = deletePVCAndApp(name, f, &p, &a)
|
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
|
||||||
if err != nil {
|
|
||||||
e2elog.Failf("failed to delete PVC and app with error %v", err)
|
|
||||||
}
|
|
||||||
w.Done()
|
w.Done()
|
||||||
}(&wg, i, *pvcClone, *appClone)
|
}(&wg, i, *pvcClone, *appClone)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
for i, err := range wgErrs {
|
||||||
|
if err != nil {
|
||||||
|
// not using Failf() as it aborts the test and does not log other errors
|
||||||
|
e2elog.Logf("failed to delete PVC and application (%s%d): %v", f.UniqueName, i, err)
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if failed != 0 {
|
||||||
|
e2elog.Failf("deleting PVCs and applications failed, %d errors were logged", failed)
|
||||||
|
}
|
||||||
|
|
||||||
// total images in cluster is 1 parent rbd image+ total
|
// total images in cluster is 1 parent rbd image+ total
|
||||||
// snaps
|
// snaps
|
||||||
validateRBDImageCount(f, totalCount+1)
|
validateRBDImageCount(f, totalCount+1)
|
||||||
@ -450,15 +476,23 @@ var _ = Describe("RBD", func() {
|
|||||||
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
go func(w *sync.WaitGroup, 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
|
||||||
err = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
|
||||||
if err != nil {
|
|
||||||
e2elog.Failf("failed to create PVC and app with error %v", err)
|
|
||||||
}
|
|
||||||
w.Done()
|
w.Done()
|
||||||
}(&wg, i, *pvcClone, *appClone)
|
}(&wg, i, *pvcClone, *appClone)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
for i, err := range wgErrs {
|
||||||
|
if err != nil {
|
||||||
|
// not using Failf() as it aborts the test and does not log other errors
|
||||||
|
e2elog.Logf("failed to create PVC and application (%s%d): %v", f.UniqueName, i, err)
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if failed != 0 {
|
||||||
|
e2elog.Failf("creating PVCs and applications failed, %d errors were logged", failed)
|
||||||
|
}
|
||||||
|
|
||||||
// total images in cluster is 1 parent rbd image+ total
|
// total images in cluster is 1 parent rbd image+ total
|
||||||
// snaps+ total clones
|
// snaps+ total clones
|
||||||
totalCloneCount = totalCount + totalCount + 1
|
totalCloneCount = totalCount + totalCount + 1
|
||||||
@ -477,15 +511,23 @@ var _ = Describe("RBD", func() {
|
|||||||
for i := 0; i < totalCount; i++ {
|
for i := 0; i < totalCount; i++ {
|
||||||
go func(w *sync.WaitGroup, n int, s v1beta1.VolumeSnapshot) {
|
go func(w *sync.WaitGroup, n int, s v1beta1.VolumeSnapshot) {
|
||||||
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
|
||||||
err = deleteSnapshot(&s, deployTimeout)
|
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
|
||||||
if err != nil {
|
|
||||||
e2elog.Failf("failed to delete snapshot with error %v", err)
|
|
||||||
}
|
|
||||||
w.Done()
|
w.Done()
|
||||||
}(&wg, i, snap)
|
}(&wg, i, snap)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
for i, err := range wgErrs {
|
||||||
|
if err != nil {
|
||||||
|
// not using Failf() as it aborts the test and does not log other errors
|
||||||
|
e2elog.Logf("failed to delete snapshot (%s%d): %v", f.UniqueName, i, err)
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if failed != 0 {
|
||||||
|
e2elog.Failf("deleting snapshots failed, %d errors were logged", failed)
|
||||||
|
}
|
||||||
|
|
||||||
validateRBDImageCount(f, totalCount)
|
validateRBDImageCount(f, totalCount)
|
||||||
wg.Add(totalCount)
|
wg.Add(totalCount)
|
||||||
// delete clone and app
|
// delete clone and app
|
||||||
@ -493,14 +535,23 @@ var _ = Describe("RBD", func() {
|
|||||||
go func(w *sync.WaitGroup, n int, p v1.PersistentVolumeClaim, a v1.Pod) {
|
go func(w *sync.WaitGroup, 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
|
||||||
err = deletePVCAndApp(name, f, &p, &a)
|
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
|
||||||
if err != nil {
|
|
||||||
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
|
||||||
}
|
|
||||||
w.Done()
|
w.Done()
|
||||||
}(&wg, i, *pvcClone, *appClone)
|
}(&wg, i, *pvcClone, *appClone)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
for i, err := range wgErrs {
|
||||||
|
if err != nil {
|
||||||
|
// not using Failf() as it aborts the test and does not log other errors
|
||||||
|
e2elog.Logf("failed to delete PVC and application (%s%d): %v", f.UniqueName, i, err)
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if failed != 0 {
|
||||||
|
e2elog.Failf("deleting PVCs and applications failed, %d errors were logged", failed)
|
||||||
|
}
|
||||||
|
|
||||||
// validate created backend rbd images
|
// validate created backend rbd images
|
||||||
validateRBDImageCount(f, 0)
|
validateRBDImageCount(f, 0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user