Skip to content

Commit bd6dbc3

Browse files
author
nwickramasin
committed
Increase http call timeout
1 parent c7ab265 commit bd6dbc3

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

test/e2e/aaas.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ var _ = Describe("Ingress tests for OPA filters", func() {
5959

6060
url := "https://" + hostName + authorizationEnforcedPath
6161
req, err := http.NewRequest("GET", url, nil)
62-
resp, err := getAndWaitResponse(rt, req, 10*time.Second, http.StatusForbidden)
62+
resp, err := getAndWaitResponseWithInterval(rt, req, 60*time.Second, 5*time.Second, http.StatusForbidden)
6363
framework.ExpectNoError(err)
6464
Expect(resp.StatusCode).To(Equal(http.StatusForbidden))
6565

6666
By(fmt.Sprintf("Calling ingress %s/%s we wait to get a 200 with opaAuthorizeRequest %s policy", ingressUpdate.Namespace, ingressUpdate.Name, opaPolicyName))
6767
req.Header.Set("Authorization", "Basic valid_token") // Authorized request
68-
resp, err = getAndWaitResponse(rt, req, 10*time.Second, http.StatusOK)
68+
resp, err = getAndWaitResponseWithInterval(rt, req, 60*time.Second, 5*time.Second, http.StatusOK)
6969
framework.ExpectNoError(err)
7070
Expect(resp.StatusCode).To(Equal(http.StatusOK))
7171
s, err := getBody(resp)
@@ -91,13 +91,13 @@ var _ = Describe("Ingress tests for OPA filters", func() {
9191

9292
url := "https://" + hostName + serveResponsePath
9393
req, err := http.NewRequest("GET", url, nil)
94-
resp, err := getAndWaitResponse(rt, req, 10*time.Second, http.StatusForbidden)
94+
resp, err := getAndWaitResponseWithInterval(rt, req, 60*time.Second, 5*time.Second, http.StatusForbidden)
9595
framework.ExpectNoError(err)
9696
Expect(resp.StatusCode).To(Equal(http.StatusForbidden))
9797

9898
By(fmt.Sprintf("Calling ingress %s/%s we wait to get a 200 with opaServeResponse %s policy", ingressUpdate.Namespace, ingressUpdate.Name, opaPolicyName))
9999
req.Header.Set("Authorization", "Basic permissions_token") // Authorized request
100-
resp, err = getAndWaitResponse(rt, req, 10*time.Second, http.StatusOK)
100+
resp, err = getAndWaitResponseWithInterval(rt, req, 60*time.Second, 5*time.Second, http.StatusOK)
101101
framework.ExpectNoError(err)
102102
Expect(resp.StatusCode).To(Equal(http.StatusOK))
103103
s, err := getBody(resp)
@@ -147,7 +147,7 @@ func updateIngressAndWait(serviceName, hostName, path, ingressRoute string, port
147147
)
148148
ingressUpdate, err := cs.NetworkingV1().Ingresses(ingressCreate.ObjectMeta.Namespace).Update(context.TODO(), updatedIng, metav1.UpdateOptions{})
149149
framework.ExpectNoError(err)
150-
time.Sleep(4 * time.Minute) // wait for routing change propagation
150+
time.Sleep(2 * time.Minute) // wait for routing change propagation
151151

152152
return ingressUpdate
153153
}

test/e2e/util.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,12 @@ func createHTTPRoundTripper() (http.RoundTripper, chan<- struct{}) {
953953
}
954954

955955
func getAndWaitResponse(rt http.RoundTripper, req *http.Request, timeout time.Duration, expectedStatusCode int) (resp *http.Response, err error) {
956-
d := 1 * time.Second
957-
if timeout < d {
958-
d = timeout - 1
956+
return getAndWaitResponseWithInterval(rt, req, timeout, 1*time.Second, expectedStatusCode)
957+
}
958+
959+
func getAndWaitResponseWithInterval(rt http.RoundTripper, req *http.Request, timeout time.Duration, interval time.Duration, expectedStatusCode int) (resp *http.Response, err error) {
960+
if timeout < interval {
961+
interval = timeout - 1
959962
}
960963
timeoutCH := make(chan struct{})
961964
go func() {
@@ -976,7 +979,7 @@ func getAndWaitResponse(rt http.RoundTripper, req *http.Request, timeout time.Du
976979
case <-timeoutCH:
977980
log.Printf("timeout to GET %s", req.URL)
978981
return
979-
case <-time.After(d):
982+
case <-time.After(interval):
980983
log.Printf("retry to GET %s", req.URL)
981984
continue
982985
}

0 commit comments

Comments
 (0)