Skip to content

Commit b7817ff

Browse files
authored
Merge pull request #8005 from zalando-incubator/refactor-code
[e2e] Refactor code
2 parents a303d50 + bce38dc commit b7817ff

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

test/e2e/audit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func expectEvents(f *framework.Framework, expectedEvents []utils.AuditEvent) {
121121
// to find all expected events. However, we're waiting for 5 minutes to avoid flakes.
122122
pollingInterval := 30 * time.Second
123123
pollingTimeout := 5 * time.Minute
124-
err := wait.Poll(pollingInterval, pollingTimeout, func() (bool, error) {
124+
err := wait.PollUntilContextTimeout(context.TODO(), pollingInterval, pollingTimeout, false, func(context.Context) (bool, error) {
125125
// Fetch the log stream.
126126
stream, err := f.ClientSet.CoreV1().RESTClient().Get().AbsPath("/logs/kube-audit.log").Stream(context.TODO())
127127
if err != nil {

test/e2e/authorisation_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"net/http"
109
"strings"
1110

@@ -941,7 +940,7 @@ var _ = describe("Authorization tests [Authorization] [RBAC] [Zalando]", func()
941940
rsp, err := client.Do(req)
942941
Expect(err).NotTo(HaveOccurred())
943942

944-
body, err := ioutil.ReadAll(rsp.Body)
943+
body, err := io.ReadAll(rsp.Body)
945944
Expect(err).NotTo(HaveOccurred())
946945

947946
verifyResponse(rsp.StatusCode, body, subtest)

test/e2e/util.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ var (
5252
pollLongTimeout = 5 * time.Minute
5353
)
5454

55-
// type ConditionFunc func() (done bool, err error)
56-
// Poll(interval, timeout time.Duration, condition ConditionFunc)
5755
func waitForRouteGroup(cs rgclient.ZalandoInterface, name, ns string, d time.Duration) (string, error) {
5856
var addr string
59-
err := wait.Poll(10*time.Second, d, func() (done bool, err error) {
57+
err := wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, d, false, func(context.Context) (done bool, err error) {
6058
rg, err := cs.ZalandoV1().RouteGroups(ns).Get(context.TODO(), name, metav1.GetOptions{ResourceVersion: "0"})
6159
if err != nil {
6260
return true, err
@@ -719,7 +717,7 @@ func waitForResponseReturnResponse(req *http.Request, timeout time.Duration, exp
719717

720718
func waitForReplicas(deploymentName, namespace string, kubeClient clientset.Interface, timeout time.Duration, desiredReplicas int) {
721719
interval := 20 * time.Second
722-
err := wait.PollImmediate(interval, timeout, func() (bool, error) {
720+
err := wait.PollUntilContextTimeout(context.TODO(), interval, timeout, true, func(context.Context) (bool, error) {
723721
deployment, err := kubeClient.AppsV1().Deployments(namespace).Get(context.TODO(), deploymentName, metav1.GetOptions{})
724722
if err != nil {
725723
framework.Failf("Failed to get replication controller %s: %v", deployment, err)

0 commit comments

Comments
 (0)