Skip to content

Commit 7a81ecd

Browse files
authored
Merge pull request kubernetes#77794 from saiyan86/fixAzureE2ETest
Use TCP instead of ICMP to check outbound connectivity
2 parents bc1d8c6 + b158098 commit 7a81ecd

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

test/e2e/framework/util.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ var (
208208
// BusyBoxImage is the image URI of BusyBox.
209209
BusyBoxImage = imageutils.GetE2EImage(imageutils.BusyBox)
210210

211+
// AgnHostImage is the image URI of AgnHost
212+
AgnHostImage = imageutils.GetE2EImage(imageutils.Agnhost)
213+
211214
// For parsing Kubectl version for version-skewed testing.
212215
gitVersionRegexp = regexp.MustCompile("GitVersion:\"(v.+?)\"")
213216

@@ -474,8 +477,8 @@ func ProxyMode(f *Framework) (string, error) {
474477
Containers: []v1.Container{
475478
{
476479
Name: "detector",
477-
Image: imageutils.GetE2EImage(imageutils.Agnhost),
478-
Command: []string{"/bin/sleep", "3600"},
480+
Image: AgnHostImage,
481+
Command: []string{"pause"},
479482
},
480483
},
481484
},
@@ -2876,29 +2879,19 @@ func UnblockNetwork(from string, to string) {
28762879
}
28772880
}
28782881

2879-
// PingCommand is the type to hold ping command.
2880-
type PingCommand string
2881-
2882-
const (
2883-
// IPv4PingCommand is a ping command for IPv4.
2884-
IPv4PingCommand PingCommand = "ping"
2885-
// IPv6PingCommand is a ping command for IPv6.
2886-
IPv6PingCommand PingCommand = "ping6"
2887-
)
2888-
28892882
// CheckConnectivityToHost launches a pod to test connectivity to the specified
28902883
// host. An error will be returned if the host is not reachable from the pod.
28912884
//
28922885
// An empty nodeName will use the schedule to choose where the pod is executed.
2893-
func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, pingCmd PingCommand, timeout int) error {
2886+
func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, port, timeout int) error {
28942887
contName := fmt.Sprintf("%s-container", podName)
28952888

28962889
command := []string{
2897-
string(pingCmd),
2898-
"-c", "3", // send 3 pings
2899-
"-W", "2", // wait at most 2 seconds for a reply
2890+
"nc",
2891+
"-vz",
29002892
"-w", strconv.Itoa(timeout),
29012893
host,
2894+
strconv.Itoa(port),
29022895
}
29032896

29042897
pod := &v1.Pod{
@@ -2909,7 +2902,7 @@ func CheckConnectivityToHost(f *Framework, nodeName, podName, host string, pingC
29092902
Containers: []v1.Container{
29102903
{
29112904
Name: contName,
2912-
Image: BusyBoxImage,
2905+
Image: AgnHostImage,
29132906
Command: command,
29142907
},
29152908
},
@@ -3257,7 +3250,7 @@ func (f *Framework) NewAgnhostPod(name string, args ...string) *v1.Pod {
32573250
Containers: []v1.Container{
32583251
{
32593252
Name: "agnhost",
3260-
Image: imageutils.GetE2EImage(imageutils.Agnhost),
3253+
Image: AgnHostImage,
32613254
Args: args,
32623255
},
32633256
},

test/e2e/network/networking.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ var _ = SIGDescribe("Networking", func() {
4747
})
4848

4949
ginkgo.It("should provide Internet connection for containers [Feature:Networking-IPv4]", func() {
50-
ginkgo.By("Running container which tries to ping 8.8.8.8")
50+
ginkgo.By("Running container which tries to connect to 8.8.8.8")
5151
framework.ExpectNoError(
52-
framework.CheckConnectivityToHost(f, "", "ping-test", "8.8.8.8", framework.IPv4PingCommand, 30))
52+
framework.CheckConnectivityToHost(f, "", "connectivity-test", "8.8.8.8", 53, 30))
5353
})
5454

5555
ginkgo.It("should provide Internet connection for containers [Feature:Networking-IPv6][Experimental]", func() {
56-
ginkgo.By("Running container which tries to ping 2001:4860:4860::8888")
56+
ginkgo.By("Running container which tries to connect to 2001:4860:4860::8888")
5757
framework.ExpectNoError(
58-
framework.CheckConnectivityToHost(f, "", "ping-test", "2001:4860:4860::8888", framework.IPv6PingCommand, 30))
58+
framework.CheckConnectivityToHost(f, "", "connectivity-test", "2001:4860:4860::8888", 53, 30))
5959
})
6060

6161
// First test because it has no dependencies on variables created later on.

0 commit comments

Comments
 (0)