Skip to content

Commit

Permalink
Replace nc with curl in egressfirewall e2e.
Browse files Browse the repository at this point in the history
Signed-off-by: Nadia Pinaeva <[email protected]>
  • Loading branch information
npinaeva committed Jul 1, 2024
1 parent b550c8e commit 39b5334
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/e2e/egress_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,23 @@ var _ = ginkgo.Describe("e2e egress firewall policy validation", func() {
if shouldSucceed {
gomega.Eventually(func() bool {
_, err := e2ekubectl.RunKubectl(f.Namespace.Name, "exec", srcPodName, testContainerFlag, "--",
"nc", "-vz", "-w", fmt.Sprint(testTimeout), dstIP, fmt.Sprint(dstPort))
"curl", "-s", "--connect-timeout", fmt.Sprint(testTimeout), net.JoinHostPort(dstIP, fmt.Sprint(dstPort)))
return err == nil
}, time.Duration(2*testTimeout)*time.Second).Should(gomega.BeTrue(),
fmt.Sprintf("expected connection from %s to [%s]:%d to suceed", srcPodName, dstIP, dstPort))
} else {
gomega.Consistently(func() bool {
_, err := e2ekubectl.RunKubectl(f.Namespace.Name, "exec", srcPodName, testContainerFlag, "--",
"nc", "-vz", "-w", fmt.Sprint(testTimeout), dstIP, fmt.Sprint(dstPort))
"curl", "-s", "--connect-timeout", fmt.Sprint(testTimeout), net.JoinHostPort(dstIP, fmt.Sprint(dstPort)))
return err != nil
}, time.Duration(2*testTimeout)*time.Second).Should(gomega.BeTrue(),
fmt.Sprintf("expected connection from %s to [%s]:%d to fail", srcPodName, dstIP, dstPort))
}
}

checkExternalContainerConnectivity := func(containerName, dstIP string, dstPort int) {
cmd := []string{"docker", "exec", containerName, "nc", "-vz", "-w", fmt.Sprint(testTimeout), dstIP, fmt.Sprint(dstPort)}
cmd := []string{"docker", "exec", containerName,
"curl", "-s", "--connect-timeout", fmt.Sprint(testTimeout), net.JoinHostPort(dstIP, fmt.Sprint(dstPort))}
framework.Logf("Running command %v", cmd)
_, err := runCommand(cmd...)
if err != nil {
Expand All @@ -167,14 +168,16 @@ var _ = ginkgo.Describe("e2e egress firewall policy validation", func() {
}

gomega.Eventually(func() bool {
cmd := []string{"docker", "exec", externalContainerName1, "nc", "-vz", "-w", fmt.Sprint(testTimeout), externalContainer2IP, fmt.Sprint(externalContainerPort2)}
cmd := []string{"docker", "exec", externalContainerName1,
"curl", "-s", "--connect-timeout", fmt.Sprint(testTimeout), net.JoinHostPort(externalContainer2IP, fmt.Sprint(externalContainerPort2))}
framework.Logf("Running command %v", cmd)
_, err := runCommand(cmd...)
if err != nil {
framework.Logf("Failed: %v", err)
return false
}
cmd = []string{"docker", "exec", externalContainerName2, "nc", "-vz", "-w", fmt.Sprint(testTimeout), externalContainer1IP, fmt.Sprint(externalContainerPort1)}
cmd = []string{"docker", "exec", externalContainerName2,
"curl", "-s", "--connect-timeout", fmt.Sprint(testTimeout), net.JoinHostPort(externalContainer1IP, fmt.Sprint(externalContainerPort1))}
framework.Logf("Running command %v", cmd)
_, err = runCommand(cmd...)
if err != nil {
Expand Down

0 comments on commit 39b5334

Please sign in to comment.