Skip to content

Commit

Permalink
Fix curl test timeouts
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
  • Loading branch information
brandond committed Feb 21, 2025
1 parent 3f3ff12 commit 2bde933
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 37 deletions.
16 changes: 8 additions & 8 deletions tests/e2e/dualstack/dualstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() {
if !strings.HasPrefix(pod.Name, "ds-clusterip-pod") {
continue
}
cmd := fmt.Sprintf("curl -L --insecure http://%s", ip)
cmd := fmt.Sprintf("curl -m 5 -s -f http://%s", ip)
Eventually(func() (string, error) {
return tc.Servers[0].RunCmdOnNode(cmd)
}, "60s", "5s").Should(ContainSubstring("Welcome to nginx!"), "failed cmd: "+cmd)
Expand All @@ -121,11 +121,11 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() {
nodeIPs, err := e2e.GetNodeIPs(tc.KubeConfigFile)
Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd)
for _, node := range nodeIPs {
cmd := fmt.Sprintf("curl --header host:%s http://%s/name.html", hostName, node.IPv4)
cmd := fmt.Sprintf("curl --header host:%s -m 5 -s -f http://%s/name.html", hostName, node.IPv4)
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "10s", "2s").Should(ContainSubstring("ds-clusterip-pod"), "failed cmd: "+cmd)
cmd = fmt.Sprintf("curl --header host:%s http://[%s]/name.html", hostName, node.IPv6)
cmd = fmt.Sprintf("curl --header host:%s -m 5 -s -f http://[%s]/name.html", hostName, node.IPv6)
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "5s", "1s").Should(ContainSubstring("ds-clusterip-pod"), "failed cmd: "+cmd)
Expand All @@ -141,11 +141,11 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() {
nodeIPs, err := e2e.GetNodeIPs(tc.KubeConfigFile)
Expect(err).NotTo(HaveOccurred())
for _, node := range nodeIPs {
cmd = "curl -L --insecure http://" + node.IPv4 + ":" + nodeport + "/name.html"
cmd = "curl -m 5 -s -f http://" + node.IPv4 + ":" + nodeport + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "10s", "1s").Should(ContainSubstring("ds-nodeport-pod"), "failed cmd: "+cmd)
cmd = "curl -L --insecure http://[" + node.IPv6 + "]:" + nodeport + "/name.html"
cmd = "curl -m 5 -s -f http://[" + node.IPv6 + "]:" + nodeport + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "10s", "1s").Should(ContainSubstring("ds-nodeport-pod"), "failed cmd: "+cmd)
Expand All @@ -154,21 +154,21 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() {
It("Verifies podSelector Network Policy", func() {
_, err := tc.DeployWorkload("pod_client.yaml")
Expect(err).NotTo(HaveOccurred())
cmd := "kubectl exec svc/client-curl -- curl -m7 ds-clusterip-svc/name.html"
cmd := "kubectl exec svc/client-curl -- curl -m 5 -s -f http://ds-clusterip-svc/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "20s", "3s").Should(ContainSubstring("ds-clusterip-pod"), "failed cmd: "+cmd)
_, err = tc.DeployWorkload("netpol-fail.yaml")
Expect(err).NotTo(HaveOccurred())
cmd = "kubectl exec svc/client-curl -- curl -m7 ds-clusterip-svc/name.html"
cmd = "kubectl exec svc/client-curl -- curl -m 5 -s -f http://ds-clusterip-svc/name.html"
Eventually(func() error {
_, err = e2e.RunCommand(cmd)
Expect(err).To(HaveOccurred())
return err
}, "20s", "3s")
_, err = tc.DeployWorkload("netpol-work.yaml")
Expect(err).NotTo(HaveOccurred())
cmd = "kubectl exec svc/client-curl -- curl -m7 ds-clusterip-svc/name.html"
cmd = "kubectl exec svc/client-curl -- curl -m 5 -s -f http://ds-clusterip-svc/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "20s", "3s").Should(ContainSubstring("ds-clusterip-pod"), "failed cmd: "+cmd)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/externalip/externalip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ var _ = Describe("Verify External-IP config", Ordered, func() {
clientIPs, err := getClientIPs(tc.KubeConfigFile)
Expect(err).NotTo(HaveOccurred())
for _, ip := range clientIPs {
cmd := "kubectl exec svc/client-curl -- curl -m7 " + ip.IPv4 + "/name.html"
cmd := "kubectl exec svc/client-curl -- curl -m 5 -s -f http://" + ip.IPv4 + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "20s", "3s").Should(ContainSubstring("client-deployment"), "failed cmd: "+cmd)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/privateregistry/privateregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var _ = Describe("Verify Create", Ordered, func() {
g.Expect(string(pod.Status.Phase)).Should(Equal("Running"))
}, "60s", "5s").Should(Succeed())

cmd := "curl " + pod.Status.PodIP
cmd := "curl -m 5 -s -f http://" + pod.Status.PodIP
Expect(tc.Servers[0].RunCmdOnNode(cmd)).To(ContainSubstring("Welcome to nginx!"))
})

Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/splitserver/splitserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var _ = Describe("Verify Create", Ordered, func() {
}, "240s", "5s").Should(ContainSubstring("test-clusterip"), "failed cmd: "+cmd)

clusterip, _ := e2e.FetchClusterIP(tc.KubeConfigFile, "nginx-clusterip-svc", false)
cmd = "curl -L --insecure http://" + clusterip + "/name.html"
cmd = "curl -m 5 -s -f http://" + clusterip + "/name.html"
for _, node := range cpNodes {
Eventually(func() (string, error) {
return node.RunCmdOnNode(cmd)
Expand All @@ -198,7 +198,7 @@ var _ = Describe("Verify Create", Ordered, func() {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-nodeport"), "nodeport pod was not created")

cmd = "curl -L --insecure http://" + nodeExternalIP + ":" + nodeport + "/name.html"
cmd = "curl -m 5 -s -f http://" + nodeExternalIP + ":" + nodeport + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-nodeport"), "failed cmd: "+cmd)
Expand All @@ -221,7 +221,7 @@ var _ = Describe("Verify Create", Ordered, func() {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-loadbalancer"), "failed cmd: "+cmd)

cmd = "curl -L --insecure http://" + ip + ":" + port + "/name.html"
cmd = "curl -m 5 -s -f http://" + ip + ":" + port + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-loadbalancer"), "failed cmd: "+cmd)
Expand All @@ -234,7 +234,7 @@ var _ = Describe("Verify Create", Ordered, func() {

for _, node := range cpNodes {
ip, _ := node.FetchNodeExternalIP()
cmd := "curl --header host:foo1.bar.com" + " http://" + ip + "/name.html"
cmd := "curl --header host:foo1.bar.com -m 5 -s -f http://" + ip + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-ingress"), "failed cmd: "+cmd)
Expand Down
20 changes: 10 additions & 10 deletions tests/e2e/svcpoliciesandfirewall/svcpoliciesandfirewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ var _ = Describe("Verify Services Traffic policies and firewall config", Ordered
// Verify connectivity to the external IP of the lbsvc service and the IP should be the flannel interface IP because of MASQ
for _, externalIP := range lbSvcExternalIPs {
Eventually(func() (string, error) {
cmd := "curl -s " + externalIP + ":81/ip"
cmd := "curl -m 5 -s -f http://" + externalIP + ":81/ip"
return e2e.RunCommand(cmd)
}, "25s", "5s").Should(ContainSubstring("10.42"))
}

// Verify connectivity to the external IP of the lbsvcExt service and the IP should not be the flannel interface IP
Eventually(func() (string, error) {
cmd := "curl -s " + lbSvcExtExternalIPs[0] + ":82/ip"
cmd := "curl -m 5 -s -f http://" + lbSvcExtExternalIPs[0] + ":82/ip"
return e2e.RunCommand(cmd)
}, "25s", "5s").ShouldNot(ContainSubstring("10.42"))

Expand All @@ -150,7 +150,7 @@ var _ = Describe("Verify Services Traffic policies and firewall config", Ordered
continue
}
Eventually(func() error {
cmd := "curl -s --max-time 5 " + externalIP + ":82/ip"
cmd := "curl -m 5 -s -f http://" + externalIP + ":82/ip"
_, err := e2e.RunCommand(cmd)
return err
}, "40s", "5s").Should(MatchError(ContainSubstring("exit status")))
Expand Down Expand Up @@ -221,12 +221,12 @@ var _ = Describe("Verify Services Traffic policies and firewall config", Ordered

var workingCmd, nonWorkingCmd string
if serverNodeName == clientPod1Node {
workingCmd = "kubectl exec " + clientPod1 + " -- curl -s --max-time 5 nginx-loadbalancer-svc-int:83/ip"
nonWorkingCmd = "kubectl exec " + clientPod2 + " -- curl -s --max-time 5 nginx-loadbalancer-svc-int:83/ip"
workingCmd = "kubectl exec " + clientPod1 + " -- curl -m 5 -s -f http://nginx-loadbalancer-svc-int:83/ip"
nonWorkingCmd = "kubectl exec " + clientPod2 + " -- curl -m 5 -s -f http://nginx-loadbalancer-svc-int:83/ip"
}
if serverNodeName == clientPod2Node {
workingCmd = "kubectl exec " + clientPod2 + " -- curl -s --max-time 5 nginx-loadbalancer-svc-int:83/ip"
nonWorkingCmd = "kubectl exec " + clientPod1 + " -- curl -s --max-time 5 nginx-loadbalancer-svc-int:83/ip"
workingCmd = "kubectl exec " + clientPod2 + " -- curl -m 5 -s -f http://nginx-loadbalancer-svc-int:83/ip"
nonWorkingCmd = "kubectl exec " + clientPod1 + " -- curl -m 5 -s -f http://nginx-loadbalancer-svc-int:83/ip"
}

Eventually(func() (string, error) {
Expand All @@ -249,7 +249,7 @@ var _ = Describe("Verify Services Traffic policies and firewall config", Ordered

// curling a service with internal traffic policy=cluster. It should work on both pods
for _, pod := range []string{clientPod1, clientPod2} {
cmd := "kubectl exec " + pod + " -- curl -s --max-time 5 nginx-loadbalancer-svc:81/ip"
cmd := "kubectl exec " + pod + " -- curl -m 5 -s -f http://nginx-loadbalancer-svc:81/ip"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "20s", "5s").Should(SatisfyAny(
Expand Down Expand Up @@ -328,13 +328,13 @@ selector:

// Verify connectivity from nodes[0] works because we passed its IP to the loadBalancerSourceRanges
Eventually(func() (string, error) {
cmd := "curl -s --max-time 5 " + node.InternalIP + ":82"
cmd := "curl -m 5 -s -f http://" + node.InternalIP + ":82"
return sNode.RunCmdOnNode(cmd)
}, "40s", "5s").Should(ContainSubstring("Welcome to nginx"))

// Verify connectivity from nodes[1] fails because we did not pass its IP to the loadBalancerSourceRanges
Eventually(func(g Gomega) error {
cmd := "curl -s --max-time 5 " + node.InternalIP + ":82"
cmd := "curl -m 5 -s -f http:// " + node.InternalIP + ":82"
_, err := aNode.RunCmdOnNode(cmd)
return err
}, "40s", "5s").Should(MatchError(ContainSubstring("exit status")))
Expand Down
16 changes: 8 additions & 8 deletions tests/e2e/upgradecluster/upgradecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
}, "240s", "5s").Should(ContainSubstring("test-clusterip"), "failed cmd: "+cmd)

clusterip, _ := e2e.FetchClusterIP(tc.KubeConfigFile, "nginx-clusterip-svc", false)
cmd = "curl -L --insecure http://" + clusterip + "/name.html"
cmd = "curl -m 5 -s -f http://" + clusterip + "/name.html"
for _, node := range tc.Servers {
Eventually(func() (string, error) {
return node.RunCmdOnNode(cmd)
Expand All @@ -103,7 +103,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-nodeport"), "nodeport pod was not created")

cmd = "curl -L --insecure http://" + nodeExternalIP + ":" + nodeport + "/name.html"
cmd = "curl -m 5 -s -f http://" + nodeExternalIP + ":" + nodeport + "/name.html"
fmt.Println(cmd)
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
Expand All @@ -125,7 +125,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-loadbalancer"))

cmd = "curl -L --insecure http://" + ip + ":" + port + "/name.html"
cmd = "curl -m 5 -s -f http://" + ip + ":" + port + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-loadbalancer"), "failed cmd: "+cmd)
Expand All @@ -138,7 +138,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {

for _, node := range tc.Servers {
ip, _ := node.FetchNodeExternalIP()
cmd := "curl --header host:foo1.bar.com" + " http://" + ip + "/name.html"
cmd := "curl --header host:foo1.bar.com -m 5 -s -f http://" + ip + "/name.html"
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-ingress"), "failed cmd: "+cmd)
Expand Down Expand Up @@ -260,7 +260,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
}, "420s", "5s").Should(ContainSubstring("test-clusterip"))

clusterip, _ := e2e.FetchClusterIP(tc.KubeConfigFile, "nginx-clusterip-svc", false)
cmd := "curl -L --insecure http://" + clusterip + "/name.html"
cmd := "curl -m 5 -s -f http://" + clusterip + "/name.html"
fmt.Println(cmd)
for _, node := range tc.Servers {
Eventually(func() (string, error) {
Expand All @@ -282,7 +282,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-nodeport"), "nodeport pod was not created")

cmd = "curl -L --insecure http://" + nodeExternalIP + ":" + nodeport + "/name.html"
cmd = "curl -m 5 -s -f http://" + nodeExternalIP + ":" + nodeport + "/name.html"
fmt.Println(cmd)
Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
Expand All @@ -297,7 +297,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
port, err := e2e.RunCommand(cmd)
Expect(err).NotTo(HaveOccurred())
Eventually(func() (string, error) {
cmd := "curl -L --insecure http://" + ip + ":" + port + "/name.html"
cmd := "curl -m 5 -s -f http://" + ip + ":" + port + "/name.html"
return e2e.RunCommand(cmd)
}, "240s", "5s").Should(ContainSubstring("test-loadbalancer"))

Expand All @@ -311,7 +311,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
It("After upgrade verifies Ingress", func() {
for _, node := range tc.Servers {
ip, _ := node.FetchNodeExternalIP()
cmd := "curl --header host:foo1.bar.com" + " http://" + ip + "/name.html"
cmd := "curl --header host:foo1.bar.com -m 5 -s -f http://" + ip + "/name.html"
fmt.Println(cmd)

Eventually(func() (string, error) {
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/validatecluster/validatecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var _ = Describe("Verify Create", Ordered, func() {
}, "240s", "5s").Should(Succeed())

clusterip, _ := e2e.FetchClusterIP(tc.KubeConfigFile, "nginx-clusterip-svc", false)
cmd := "curl -L --insecure http://" + clusterip + "/name.html"
cmd := "curl -m 5 -s -f http://" + clusterip + "/name.html"
for _, node := range tc.Servers {
Eventually(func(g Gomega) {
res, err := node.RunCmdOnNode(cmd)
Expand All @@ -113,7 +113,7 @@ var _ = Describe("Verify Create", Ordered, func() {
g.Expect(res).Should(ContainSubstring("test-nodeport"), "nodeport pod was not created")
}, "240s", "5s").Should(Succeed())

cmd = "curl -L --insecure http://" + nodeExternalIP + ":" + nodeport + "/name.html"
cmd = "curl -m 5 -s -f http://" + nodeExternalIP + ":" + nodeport + "/name.html"

Eventually(func(g Gomega) {
res, err := e2e.RunCommand(cmd)
Expand Down Expand Up @@ -142,7 +142,7 @@ var _ = Describe("Verify Create", Ordered, func() {
}, "240s", "5s").Should(Succeed())

Eventually(func(g Gomega) {
cmd = "curl -L --insecure http://" + ip + ":" + port + "/name.html"
cmd = "curl -m 5 -s -f http://" + ip + ":" + port + "/name.html"
res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("test-loadbalancer"))
Expand All @@ -156,7 +156,7 @@ var _ = Describe("Verify Create", Ordered, func() {

for _, node := range tc.Servers {
ip, _ := node.FetchNodeExternalIP()
cmd := "curl --header host:foo1.bar.com" + " http://" + ip + "/name.html"
cmd := "curl --header host:foo1.bar.com -m 5 -s -f http://" + ip + "/name.html"
fmt.Println(cmd)

Eventually(func(g Gomega) {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/wasm/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var _ = Describe("Verify K3s can run Wasm workloads", Ordered, func() {
for _, endpoint := range endpoints {
url := fmt.Sprintf("http://%s/%s", ingressIPs[0], endpoint)
fmt.Printf("Connecting to Wasm web application at: %s\n", url)
cmd := "curl -sfv " + url
cmd := "curl -m 5 -s -f -v " + url

Eventually(func() (string, error) {
return e2e.RunCommand(cmd)
Expand Down

0 comments on commit 2bde933

Please sign in to comment.