Skip to content

Commit

Permalink
[e2e tests] Remove explicit sleep command for toolbox containers (#6021)
Browse files Browse the repository at this point in the history
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 <antonin.bas@broadcom.com>
  • Loading branch information
antoninbas authored and tnqn committed Mar 22, 2024
1 parent 01455f6 commit 16ef8b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion test/e2e/connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func testHostPortPodConnectivity(t *testing.T, data *TestData) {
// alternating in this podInfo slice so that the test can cover different connectivity cases between different OSes.
func createPodsOnDifferentNodes(t *testing.T, data *TestData, namespace, tag string) (podInfos []PodInfo, cleanup func() error) {
dsName := "connectivity-test" + tag
_, deleteDaemonSet, err := data.createDaemonSet(dsName, namespace, toolboxContainerName, toolboxImage, []string{"sleep", "3600"}, nil)
_, deleteDaemonSet, err := data.createDaemonSet(dsName, namespace, toolboxContainerName, toolboxImage, nil, nil)
if err != nil {
t.Fatalf("Error when creating DaemonSet '%s': %v", dsName, err)
}
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ func (data *TestData) createMcJoinPodOnNode(name string, ns string, nodeName str
// createToolboxPodOnNode creates a Pod in the test namespace with a single toolbox container. The
// Pod will be scheduled on the specified Node (if nodeName is not empty).
func (data *TestData) createToolboxPodOnNode(name string, ns string, nodeName string, hostNetwork bool) error {
return NewPodBuilder(name, ns, toolboxImage).OnNode(nodeName).WithCommand([]string{"sleep", "3600"}).WithHostNetwork(hostNetwork).Create(data)
return NewPodBuilder(name, ns, toolboxImage).OnNode(nodeName).WithHostNetwork(hostNetwork).Create(data)
}

// createNginxPodOnNode creates a Pod in the test namespace with a single nginx container. The
Expand Down Expand Up @@ -3099,7 +3099,11 @@ func getPingCommand(count int, size int, os string, ip *net.IP, dontFragment boo
cmd = append(cmd, sizeOption, strconv.Itoa(size))
}
if dontFragment {
cmd = append(cmd, "-M", "do")
if os == "windows" {
cmd = append(cmd, "-f")
} else {
cmd = append(cmd, "-M", "do")
}
}

if ip.To4() != nil {
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestAntreaApiserverTLSConfig(t *testing.T) {
require.NotNil(t, node, "failed to get the Node")
nodeIPv4 := node.ipv4Addr
nodeIPv6 := node.ipv6Addr
clientPodName, _, cleanupFunc := createAndWaitForPod(t, data, data.createToolboxPodOnNode, "client", controllerPodNode, antreaNamespace, true)
clientPodName, _, cleanupFunc := createAndWaitForPod(t, data, data.createToolboxPodOnNode, "client", controllerPodNode, data.testNamespace, true)
defer cleanupFunc()

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

0 comments on commit 16ef8b8

Please sign in to comment.