e2e: use Ginkgo context

All code must use the context from Ginkgo when doing API calls or polling for a
change, otherwise the code would not return immediately when the test gets
aborted.
This commit is contained in:
Patrick Ohly
2022-12-12 10:11:10 +01:00
parent bf1d1dfd0f
commit 2f6c4f5eab
418 changed files with 11489 additions and 11369 deletions

View File

@@ -89,8 +89,8 @@ var _ = SIGDescribe("Container Runtime Conformance Test", func() {
defer os.Remove(configFile)
// checkContainerStatus checks whether the container status matches expectation.
checkContainerStatus := func() error {
status, err := container.GetStatus()
checkContainerStatus := func(ctx context.Context) error {
status, err := container.GetStatus(ctx)
if err != nil {
return fmt.Errorf("failed to get container status: %v", err)
}
@@ -116,7 +116,7 @@ var _ = SIGDescribe("Container Runtime Conformance Test", func() {
}
}
// Check pod phase
phase, err := container.GetPhase()
phase, err := container.GetPhase(ctx)
if err != nil {
return fmt.Errorf("failed to get pod phase: %v", err)
}
@@ -131,15 +131,15 @@ var _ = SIGDescribe("Container Runtime Conformance Test", func() {
for i := 1; i <= flakeRetry; i++ {
var err error
ginkgo.By("create the container")
container.Create()
container.Create(ctx)
ginkgo.By("check the container status")
for start := time.Now(); time.Since(start) < node.ContainerStatusRetryTimeout; time.Sleep(node.ContainerStatusPollInterval) {
if err = checkContainerStatus(); err == nil {
if err = checkContainerStatus(ctx); err == nil {
break
}
}
ginkgo.By("delete the container")
container.Delete()
_ = container.Delete(ctx)
if err == nil {
break
}