Skip to content

Commit 5789889

Browse files
authored
[e2e tests] Remove explicit sleep command for toolbox containers (#6021)
An explicit sleep is not required as the default command in the container is already "pause". The Windows version of the toolbox image will not start when using "sleep", as the command is not available. Even on Linux, pause is superior to sleep for signal handling. We also fix the "don't fragment" ping option for Windows. Signed-off-by: Antonin Bas <[email protected]>
1 parent 04d2eba commit 5789889

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

test/e2e/connectivity_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func testHostPortPodConnectivity(t *testing.T, data *TestData) {
193193
// alternating in this podInfo slice so that the test can cover different connectivity cases between different OSes.
194194
func createPodsOnDifferentNodes(t *testing.T, data *TestData, namespace, tag string) (podInfos []PodInfo, cleanup func() error) {
195195
dsName := "connectivity-test" + tag
196-
_, deleteDaemonSet, err := data.createDaemonSet(dsName, namespace, toolboxContainerName, ToolboxImage, []string{"sleep", "3600"}, nil)
196+
_, deleteDaemonSet, err := data.createDaemonSet(dsName, namespace, toolboxContainerName, ToolboxImage, nil, nil)
197197
if err != nil {
198198
t.Fatalf("Error when creating DaemonSet '%s': %v", dsName, err)
199199
}

test/e2e/framework.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ func (data *TestData) createMcJoinPodOnNode(name string, ns string, nodeName str
15081508
// createToolboxPodOnNode creates a Pod in the test namespace with a single toolbox container. The
15091509
// Pod will be scheduled on the specified Node (if nodeName is not empty).
15101510
func (data *TestData) createToolboxPodOnNode(name string, ns string, nodeName string, hostNetwork bool) error {
1511-
return NewPodBuilder(name, ns, ToolboxImage).OnNode(nodeName).WithCommand([]string{"sleep", "3600"}).WithHostNetwork(hostNetwork).Create(data)
1511+
return NewPodBuilder(name, ns, ToolboxImage).OnNode(nodeName).WithHostNetwork(hostNetwork).Create(data)
15121512
}
15131513

15141514
// createNginxPodOnNode creates a Pod in the test namespace with a single nginx container. The
@@ -3086,7 +3086,11 @@ func getPingCommand(count int, size int, os string, ip *net.IP, dontFragment boo
30863086
cmd = append(cmd, sizeOption, strconv.Itoa(size))
30873087
}
30883088
if dontFragment {
3089-
cmd = append(cmd, "-M", "do")
3089+
if os == "windows" {
3090+
cmd = append(cmd, "-f")
3091+
} else {
3092+
cmd = append(cmd, "-M", "do")
3093+
}
30903094
}
30913095

30923096
if ip.To4() != nil {

test/e2e/tls_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestAntreaApiserverTLSConfig(t *testing.T) {
5959
require.NotNil(t, node, "failed to get the Node")
6060
nodeIPv4 := node.ipv4Addr
6161
nodeIPv6 := node.ipv6Addr
62-
clientPodName, _, cleanupFunc := createAndWaitForPod(t, data, data.createToolboxPodOnNode, "client", controllerPodNode, antreaNamespace, true)
62+
clientPodName, _, cleanupFunc := createAndWaitForPod(t, data, data.createToolboxPodOnNode, "client", controllerPodNode, data.testNamespace, true)
6363
defer cleanupFunc()
6464

6565
tests := []struct {
@@ -73,7 +73,6 @@ func TestAntreaApiserverTLSConfig(t *testing.T) {
7373
for _, tc := range tests {
7474
tc := tc
7575
t.Run(tc.name, func(t *testing.T) {
76-
t.Parallel()
7776
data.checkTLS(t, clientPodName, toolboxContainerName, tc.apiserver, tc.apiserverStr, nodeIPv4, nodeIPv6)
7877
})
7978
}
@@ -134,7 +133,7 @@ func (data *TestData) curlTestTLS(t *testing.T, pod string, container string, tl
134133
if tls12 {
135134
cmd = append(cmd, "--tls-max", "1.2", "--tlsv1.2")
136135
}
137-
stdout, stderr, err := data.RunCommandFromPod(antreaNamespace, pod, container, cmd)
136+
stdout, stderr, err := data.RunCommandFromPod(data.testNamespace, pod, container, cmd)
138137
assert.NoError(t, err, "failed to run curl command on Pod '%s'\nstdout: %s", pod, stdout)
139138
t.Logf("Ran '%s' on Pod %s", strings.Join(cmd, " "), pod)
140139
// Collect stderr as all TLS-related details such as the cipher suite are present in stderr.

0 commit comments

Comments
 (0)