Skip to content

Commit

Permalink
Remove all references to busybox in e2e tests (antrea-io#6000) (antre…
Browse files Browse the repository at this point in the history
…a-io#6701)

Fixes antrea-io#5991

Signed-off-by: Shikhar Soni <[email protected]>
  • Loading branch information
XinShuYang authored Sep 30, 2024
1 parent 89bb9ae commit 2bcb2c4
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 131 deletions.
28 changes: 14 additions & 14 deletions test/e2e/antreapolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4718,7 +4718,7 @@ func testANNPNetworkPolicyStatsWithDropAction(t *testing.T, data *TestData) {
serverName, serverIPs, cleanupFunc := createAndWaitForPod(t, data, data.createNginxPodOnNode, "test-server-", "", data.testNamespace, false)
defer cleanupFunc()

clientName, _, cleanupFunc := createAndWaitForPod(t, data, data.createBusyboxPodOnNode, "test-client-", "", data.testNamespace, false)
clientName, _, cleanupFunc := createAndWaitForPod(t, data, data.createToolboxPodOnNode, "test-client-", "", data.testNamespace, false)
defer cleanupFunc()
var err error
k8sUtils, err = NewKubernetesUtils(data)
Expand All @@ -4737,11 +4737,11 @@ func testANNPNetworkPolicyStatsWithDropAction(t *testing.T, data *TestData) {
// So we need to "warm-up" the tunnel.
if clusterInfo.podV4NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("nc -vz -w 4 %s 80", serverIPs.IPv4.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
}
if clusterInfo.podV6NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("nc -vz -w 4 %s 80", serverIPs.IPv6.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
}
var annp = &crdv1beta1.NetworkPolicy{
ObjectMeta: metav1.ObjectMeta{Namespace: data.testNamespace, Name: "np1", Labels: map[string]string{"antrea-e2e": "np1"}},
Expand Down Expand Up @@ -4799,14 +4799,14 @@ func testANNPNetworkPolicyStatsWithDropAction(t *testing.T, data *TestData) {
if clusterInfo.podV4NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 80", serverIPs.IPv4.String())}
cmd2 := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 443", serverIPs.IPv4.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd2)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd2)
}
if clusterInfo.podV6NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 80", serverIPs.IPv6.String())}
cmd2 := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 443", serverIPs.IPv6.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd2)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd2)
}
wg.Done()
}()
Expand Down Expand Up @@ -4853,7 +4853,7 @@ func testAntreaClusterNetworkPolicyStats(t *testing.T, data *TestData) {
serverName, serverIPs, cleanupFunc := createAndWaitForPod(t, data, data.createNginxPodOnNode, "test-server-", "", data.testNamespace, false)
defer cleanupFunc()

clientName, _, cleanupFunc := createAndWaitForPod(t, data, data.createBusyboxPodOnNode, "test-client-", "", data.testNamespace, false)
clientName, _, cleanupFunc := createAndWaitForPod(t, data, data.createToolboxPodOnNode, "test-client-", "", data.testNamespace, false)
defer cleanupFunc()
var err error
k8sUtils, err = NewKubernetesUtils(data)
Expand All @@ -4872,11 +4872,11 @@ func testAntreaClusterNetworkPolicyStats(t *testing.T, data *TestData) {
// So we need to "warm-up" the tunnel.
if clusterInfo.podV4NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("nc -vz -w 4 %s 80", serverIPs.IPv4.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
}
if clusterInfo.podV6NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("nc -vz -w 4 %s 80", serverIPs.IPv6.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
}
var acnp = &crdv1beta1.ClusterNetworkPolicy{
ObjectMeta: metav1.ObjectMeta{Namespace: data.testNamespace, Name: "cnp1", Labels: map[string]string{"antrea-e2e": "cnp1"}},
Expand Down Expand Up @@ -4934,14 +4934,14 @@ func testAntreaClusterNetworkPolicyStats(t *testing.T, data *TestData) {
if clusterInfo.podV4NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 800", serverIPs.IPv4.String())}
cmd2 := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 4430", serverIPs.IPv4.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd2)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd2)
}
if clusterInfo.podV6NetworkCIDR != "" {
cmd := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 800", serverIPs.IPv6.String())}
cmd2 := []string{"/bin/sh", "-c", fmt.Sprintf("echo test | nc -w 4 -u %s 4430", serverIPs.IPv6.String())}
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, busyboxContainerName, cmd2)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd)
data.RunCommandFromPod(data.testNamespace, clientName, toolboxContainerName, cmd2)
}
wg.Done()
}()
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ func TestBasic(t *testing.T) {
}

// testPodAssignIP verifies that Antrea allocates IP addresses properly to new Pods. It does this by
// deploying a busybox Pod, then waiting for the K8s apiserver to report the new IP address for that
// deploying a toolbox Pod, then waiting for the K8s apiserver to report the new IP address for that
// Pod, and finally verifying that the IP address is in the Pod Network CIDR for the cluster.
func testPodAssignIP(t *testing.T, data *TestData, namespace string, podV4NetworkCIDR, podV6NetworkCIDR string) {
podName := randName("test-pod-")

t.Logf("Creating a busybox test Pod")
if err := data.createBusyboxPodOnNode(podName, namespace, "", false); err != nil {
t.Fatalf("Error when creating busybox test Pod: %v", err)
t.Logf("Creating a toolbox test Pod")
if err := data.createToolboxPodOnNode(podName, namespace, "", false); err != nil {
t.Fatalf("Error when creating toolbox test Pod: %v", err)
}
defer deletePodWrapper(t, data, namespace, podName)

Expand Down Expand Up @@ -296,9 +296,9 @@ func testIPAMRestart(t *testing.T, data *TestData, namespace string) {
}()

createPodAndGetIP := func(podName string) (*PodIPs, error) {
t.Logf("Creating a busybox test Pod '%s' and waiting for IP", podName)
if err := data.createBusyboxPodOnNode(podName, namespace, nodeName, false); err != nil {
t.Fatalf("Error when creating busybox test Pod '%s': %v", podName, err)
t.Logf("Creating a toolbox test Pod '%s' and waiting for IP", podName)
if err := data.createToolboxPodOnNode(podName, namespace, nodeName, false); err != nil {
t.Fatalf("Error when creating toolbox test Pod '%s': %v", podName, err)
return nil, err
}
pods = append(pods, podName)
Expand Down Expand Up @@ -831,7 +831,7 @@ func testGratuitousARP(t *testing.T, data *TestData, namespace string) {
nodeName := workerNodeName(1)

t.Logf("Creating Pod '%s' on '%s'", podName, nodeName)
if err := data.createBusyboxPodOnNode(podName, namespace, nodeName, false); err != nil {
if err := data.createToolboxPodOnNode(podName, namespace, nodeName, false); err != nil {
t.Fatalf("Error when creating Pod '%s': %v", podName, err)
}
defer deletePodWrapper(t, data, namespace, podName)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestBatchCreatePods(t *testing.T) {

oldFDs := getFDs()

_, _, cleanupFn := createTestBusyboxPods(t, data, batchNum, data.testNamespace, node1)
_, _, cleanupFn := createTestToolboxPods(t, data, batchNum, data.testNamespace, node1)
defer cleanupFn()

// It is possible for new FDs to be allocated temporarily by the process, for different
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (data *TestData) testHostPortPodConnectivity(t *testing.T, clientNamespace,
hpPodHostIP := hpPod.Status.HostIP
// Create client Pod to test connectivity.
clientName := randName("test-client-")
if err := data.createBusyboxPodOnNode(clientName, clientNamespace, "", false); err != nil {
if err := data.createToolboxPodOnNode(clientName, clientNamespace, "", false); err != nil {
t.Fatalf("Error when creating test client Pod: %v", err)
}
defer deletePodWrapper(t, data, clientNamespace, clientName)
Expand Down Expand Up @@ -334,19 +334,19 @@ func testPodConnectivityAfterAntreaRestart(t *testing.T, data *TestData, namespa
// br-int bridge is to implement normal L2 forwarding.
func testOVSRestartSameNode(t *testing.T, data *TestData, namespace string) {
workerNode := workerNodeName(1)
t.Logf("Creating two busybox test Pods on '%s'", workerNode)
podNames, podIPs, cleanupFn := createTestBusyboxPods(t, data, 2, namespace, workerNode)
t.Logf("Creating two toolbox test Pods on '%s'", workerNode)
podNames, podIPs, cleanupFn := createTestToolboxPods(t, data, 2, namespace, workerNode)
defer cleanupFn()

resCh := make(chan error, 1)

runArping := func() error {
// we send arp pings for 25 seconds; this duration is a bit arbitrary and we assume
// that restarting Antrea takes less than that time. Unfortunately, the arping
// utility in busybox does not let us choose a smaller interval than 1 second.
// utility in toolbox does not let us choose a smaller interval than 1 second.
count := 25
cmd := fmt.Sprintf("arping -c %d %s", count, podIPs[1].IPv4.String())
stdout, stderr, err := data.RunCommandFromPod(namespace, podNames[0], busyboxContainerName, strings.Fields(cmd))
stdout, stderr, err := data.RunCommandFromPod(namespace, podNames[0], toolboxContainerName, strings.Fields(cmd))
if err != nil {
return fmt.Errorf("error when running arping command: %v - stdout: %s - stderr: %s", err, stdout, stderr)
}
Expand Down
28 changes: 14 additions & 14 deletions test/e2e/egress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ func testEgressClientIP(t *testing.T, data *TestData) {

localPod := fmt.Sprintf("localpod%s", tt.name)
remotePod := fmt.Sprintf("remotepod%s", tt.name)
if err := data.createBusyboxPodOnNode(localPod, data.testNamespace, egressNode, false); err != nil {
if err := data.createToolboxPodOnNode(localPod, data.testNamespace, egressNode, false); err != nil {
t.Fatalf("Failed to create local Pod: %v", err)
}
defer deletePodWrapper(t, data, data.testNamespace, localPod)
if err := data.podWaitForRunning(defaultTimeout, localPod, data.testNamespace); err != nil {
t.Fatalf("Error when waiting for Pod '%s' to be in the Running state", localPod)
}
if err := data.createBusyboxPodOnNode(remotePod, data.testNamespace, workerNodeName(1), false); err != nil {
if err := data.createToolboxPodOnNode(remotePod, data.testNamespace, workerNodeName(1), false); err != nil {
t.Fatalf("Failed to create remote Pod: %v", err)
}
defer deletePodWrapper(t, data, data.testNamespace, remotePod)
Expand All @@ -156,8 +156,8 @@ func testEgressClientIP(t *testing.T, data *TestData) {

// As the fake server runs in a netns of the Egress Node, only egress Node can reach the server, Pods running on
// other Nodes cannot reach it before Egress is added.
assertClientIP(data, t, localPod, busyboxContainerName, serverIPStr, tt.localIP0, tt.localIP1)
assertConnError(data, t, remotePod, busyboxContainerName, serverIPStr)
assertClientIP(data, t, localPod, toolboxContainerName, serverIPStr, tt.localIP0, tt.localIP1)
assertConnError(data, t, remotePod, toolboxContainerName, serverIPStr)

t.Logf("Creating an Egress applying to all e2e Pods")
matchExpressions := []metav1.LabelSelectorRequirement{
Expand All @@ -168,8 +168,8 @@ func testEgressClientIP(t *testing.T, data *TestData) {
}
egress := data.createEgress(t, "egress-", matchExpressions, nil, "", egressNodeIP, nil)
defer data.crdClient.CrdV1beta1().Egresses().Delete(context.TODO(), egress.Name, metav1.DeleteOptions{})
assertClientIP(data, t, localPod, busyboxContainerName, serverIPStr, egressNodeIP)
assertClientIP(data, t, remotePod, busyboxContainerName, serverIPStr, egressNodeIP)
assertClientIP(data, t, localPod, toolboxContainerName, serverIPStr, egressNodeIP)
assertClientIP(data, t, remotePod, toolboxContainerName, serverIPStr, egressNodeIP)

var err error
err = wait.Poll(time.Millisecond*100, time.Second, func() (bool, error) {
Expand Down Expand Up @@ -210,8 +210,8 @@ func testEgressClientIP(t *testing.T, data *TestData) {
if err != nil {
t.Fatalf("Failed to update Egress %v: %v", egress, err)
}
assertClientIP(data, t, localPod, busyboxContainerName, serverIPStr, tt.localIP0, tt.localIP1)
assertClientIP(data, t, remotePod, busyboxContainerName, serverIPStr, egressNodeIP)
assertClientIP(data, t, localPod, toolboxContainerName, serverIPStr, tt.localIP0, tt.localIP1)
assertClientIP(data, t, remotePod, toolboxContainerName, serverIPStr, egressNodeIP)

t.Log("Updating the Egress's AppliedTo to localPod only")
egress.Spec.AppliedTo = v1beta1.AppliedTo{
Expand All @@ -223,25 +223,25 @@ func testEgressClientIP(t *testing.T, data *TestData) {
if err != nil {
t.Fatalf("Failed to update Egress %v: %v", egress, err)
}
assertClientIP(data, t, localPod, busyboxContainerName, serverIPStr, egressNodeIP)
assertConnError(data, t, remotePod, busyboxContainerName, serverIPStr)
assertClientIP(data, t, localPod, toolboxContainerName, serverIPStr, egressNodeIP)
assertConnError(data, t, remotePod, toolboxContainerName, serverIPStr)

t.Logf("Updating the Egress's EgressIP to %s", tt.localIP1)
egress.Spec.EgressIP = tt.localIP1
egress, err = data.crdClient.CrdV1beta1().Egresses().Update(context.TODO(), egress, metav1.UpdateOptions{})
if err != nil {
t.Fatalf("Failed to update Egress %v: %v", egress, err)
}
assertClientIP(data, t, localPod, busyboxContainerName, serverIPStr, tt.localIP1)
assertConnError(data, t, remotePod, busyboxContainerName, serverIPStr)
assertClientIP(data, t, localPod, toolboxContainerName, serverIPStr, tt.localIP1)
assertConnError(data, t, remotePod, toolboxContainerName, serverIPStr)

t.Log("Deleting the Egress")
err = data.crdClient.CrdV1beta1().Egresses().Delete(context.TODO(), egress.Name, metav1.DeleteOptions{})
if err != nil {
t.Fatalf("Failed to delete Egress %v: %v", egress, err)
}
assertClientIP(data, t, localPod, busyboxContainerName, serverIPStr, tt.localIP0, tt.localIP1)
assertConnError(data, t, remotePod, busyboxContainerName, serverIPStr)
assertClientIP(data, t, localPod, toolboxContainerName, serverIPStr, tt.localIP0, tt.localIP1)
assertConnError(data, t, remotePod, toolboxContainerName, serverIPStr)
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,17 +523,17 @@ func deletePodWrapper(tb testing.TB, data *TestData, namespace, name string) {
}
}

// createTestBusyboxPods creates the desired number of busybox Pods and wait for their IP address to
// createTestToolboxPods creates the desired number of toolbox Pods and wait for their IP address to
// become available. This is a common patter in our tests, so having this helper function makes
// sense. It calls Fatalf in case of error, so it must be called from the goroutine running the test
// or benchmark function. You can create all the Pods on the same Node by setting nodeName. If
// nodeName is the empty string, each Pod will be created on an arbitrary
// Node. createTestBusyboxPods returns the cleanupFn function which can be used to delete the
// Node. createTestToolboxPods returns the cleanupFn function which can be used to delete the
// created Pods. Pods are created in parallel to reduce the time required to run the tests.
func createTestBusyboxPods(tb testing.TB, data *TestData, num int, ns string, nodeName string) (
func createTestToolboxPods(tb testing.TB, data *TestData, num int, ns string, nodeName string) (
podNames []string, podIPs []*PodIPs, cleanupFn func(),
) {
return createTestPods(tb, data, num, ns, nodeName, false, data.createBusyboxPodOnNode)
return createTestPods(tb, data, num, ns, nodeName, false, data.createToolboxPodOnNode)
}

func createTestAgnhostPods(tb testing.TB, data *TestData, num int, ns string, nodeName string) (
Expand Down
Loading

0 comments on commit 2bcb2c4

Please sign in to comment.