Skip to content

Commit

Permalink
Create different namespaces for different e2e tests (#3506)
Browse files Browse the repository at this point in the history
Created different namespaces for different e2e tests, so that the test
should not be delayed because of waiting for namespace deletion from
prior tests.

Time Statistics:

Name                               old time    new time
antrea-e2e test                    2692.584s   2316.626s
antrea-e2e test                    2640.578s   2309.422s

Removed stale TODO comment from agent.go file.

Signed-off-by: Pulkit Jain <jainpu@vmware.com>
Co-authored-by: Zhengsheng Zhou <zhengshengz@vmware.com>
  • Loading branch information
jainpulkit22 and Zhengsheng Zhou authored May 26, 2022
1 parent 6d3036b commit 6445ee1
Show file tree
Hide file tree
Showing 26 changed files with 873 additions and 866 deletions.
1 change: 0 additions & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func run(o *Options) error {

_, serviceCIDRNet, _ := net.ParseCIDR(o.config.ServiceCIDR)
var serviceCIDRNetv6 *net.IPNet
// Todo: use FeatureGate to check if IPv6 is enabled and then read configuration item "ServiceCIDRv6".
if o.config.ServiceCIDRv6 != "" {
_, serviceCIDRNetv6, _ = net.ParseCIDR(o.config.ServiceCIDRv6)
}
Expand Down
14 changes: 9 additions & 5 deletions multicluster/test/e2e/antreapolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ const (
)

var (
allPodsPerCluster []antreae2e.Pod
perNamespacePods, perClusterNamespaces []string
podsByNamespace map[string][]antreae2e.Pod
clusterK8sUtilsMap map[string]*antreae2e.KubernetesUtils
allPodsPerCluster []antreae2e.Pod
perNamespacePods []string
perClusterNamespaces map[string]string
podsByNamespace map[string][]antreae2e.Pod
clusterK8sUtilsMap map[string]*antreae2e.KubernetesUtils
)

func failOnError(err error, t *testing.T) {
Expand All @@ -52,7 +53,10 @@ func failOnError(err error, t *testing.T) {
// initializeForPolicyTest creates three Pods in three test Namespaces for each test cluster.
func initializeForPolicyTest(t *testing.T, data *MCTestData) {
perNamespacePods = []string{"a", "b", "c"}
perClusterNamespaces = []string{"x", "y", "z"}
perClusterNamespaces = make(map[string]string)
perClusterNamespaces["x"] = "x"
perClusterNamespaces["y"] = "y"
perClusterNamespaces["z"] = "z"

allPodsPerCluster = []antreae2e.Pod{}
podsByNamespace = make(map[string][]antreae2e.Pod)
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/antreaipam_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func TestAntreaIPAMService(t *testing.T) {
})
t.Run("testAntreaIPAMClusterIPv4", func(t *testing.T) {
skipIfNotIPv4Cluster(t)
data.testClusterIP(t, false, testNamespace, testAntreaIPAMNamespace)
data.testClusterIP(t, false, data.testNamespace, testAntreaIPAMNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMPodToClusterIPv4", func(t *testing.T) {
skipIfNotIPv4Cluster(t)
data.testClusterIP(t, false, testAntreaIPAMNamespace, testNamespace)
data.testClusterIP(t, false, testAntreaIPAMNamespace, data.testNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMVLAN11PodToAntreaIPAMVLAN11ClusterIPv4", func(t *testing.T) {
Expand All @@ -84,12 +84,12 @@ func TestAntreaIPAMService(t *testing.T) {
})
t.Run("testAntreaIPAMVLAN11ClusterIPv4", func(t *testing.T) {
skipIfNotIPv4Cluster(t)
data.testClusterIP(t, false, testNamespace, testAntreaIPAMNamespace11)
data.testClusterIP(t, false, data.testNamespace, testAntreaIPAMNamespace11)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMVLAN11PodToClusterIPv4", func(t *testing.T) {
skipIfNotIPv4Cluster(t)
data.testClusterIP(t, false, testAntreaIPAMNamespace11, testNamespace)
data.testClusterIP(t, false, testAntreaIPAMNamespace11, data.testNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})

Expand All @@ -100,12 +100,12 @@ func TestAntreaIPAMService(t *testing.T) {
})
t.Run("testAntreaIPAMNodePort", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testNodePort(t, false, testNamespace, testAntreaIPAMNamespace)
data.testNodePort(t, false, data.testNamespace, testAntreaIPAMNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMPodToNodePort", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testNodePort(t, false, testAntreaIPAMNamespace, testNamespace)
data.testNodePort(t, false, testAntreaIPAMNamespace, data.testNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMVLAN11PodToAntreaIPAMVLAN11NodePort", func(t *testing.T) {
Expand All @@ -130,12 +130,12 @@ func TestAntreaIPAMService(t *testing.T) {
})
t.Run("testAntreaIPAMVLAN11NodePort", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testNodePort(t, false, testNamespace, testAntreaIPAMNamespace11)
data.testNodePort(t, false, data.testNamespace, testAntreaIPAMNamespace11)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMVLAN11PodToNodePort", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testNodePort(t, false, testAntreaIPAMNamespace11, testNamespace)
data.testNodePort(t, false, testAntreaIPAMNamespace11, data.testNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
}
12 changes: 6 additions & 6 deletions test/e2e/antreaipam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ func TestAntreaIPAM(t *testing.T) {
})
t.Run("testAntreaIPAMHostPortPodConnectivity", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testHostPortPodConnectivity(t, testNamespace, testAntreaIPAMNamespace)
data.testHostPortPodConnectivity(t, data.testNamespace, testAntreaIPAMNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMPodToHostPortPodConnectivity", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testHostPortPodConnectivity(t, testAntreaIPAMNamespace, testNamespace)
data.testHostPortPodConnectivity(t, testAntreaIPAMNamespace, data.testNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMVLAN11PodToAntreaIPAMVLAN11HostPortPodConnectivity", func(t *testing.T) {
Expand All @@ -216,12 +216,12 @@ func TestAntreaIPAM(t *testing.T) {
})
t.Run("testAntreaIPAMVLAN11HostPortPodConnectivity", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testHostPortPodConnectivity(t, testNamespace, testAntreaIPAMNamespace11)
data.testHostPortPodConnectivity(t, data.testNamespace, testAntreaIPAMNamespace11)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMVLAN11PodToHostPortPodConnectivity", func(t *testing.T) {
skipIfHasWindowsNodes(t)
data.testHostPortPodConnectivity(t, testAntreaIPAMNamespace11, testNamespace)
data.testHostPortPodConnectivity(t, testAntreaIPAMNamespace11, data.testNamespace)
checkIPPoolsEmpty(t, data, ipPools)
})
t.Run("testAntreaIPAMOVSRestartSameNode", func(t *testing.T) {
Expand Down Expand Up @@ -260,7 +260,7 @@ func testAntreaIPAMPodConnectivitySameNode(t *testing.T, data *TestData) {
// One Per-Node IPAM Pod
podInfos = append(podInfos, podInfo{
name: randName("test-pod-0-"),
namespace: testNamespace,
namespace: data.testNamespace,
})
workerNode := workerNodeName(1)

Expand All @@ -279,7 +279,7 @@ func testAntreaIPAMPodConnectivitySameNode(t *testing.T, data *TestData) {
func testAntreaIPAMPodConnectivityDifferentNodes(t *testing.T, data *TestData) {
maxNodes := 3
var podInfos []podInfo
for _, namespace := range []string{testNamespace, testAntreaIPAMNamespace, testAntreaIPAMNamespace11, testAntreaIPAMNamespace12} {
for _, namespace := range []string{data.testNamespace, testAntreaIPAMNamespace, testAntreaIPAMNamespace11, testAntreaIPAMNamespace12} {
createdPodInfos, deletePods := createPodsOnDifferentNodes(t, data, namespace, "differentnodes")
defer deletePods()
if len(createdPodInfos) > maxNodes {
Expand Down
Loading

0 comments on commit 6445ee1

Please sign in to comment.