diff --git a/test/integration-new/cni-version-testing/cni_version_host_networking_test.go b/test/integration-new/cni-version-testing/cni_version_host_networking_test.go deleted file mode 100644 index 348a2474f48..00000000000 --- a/test/integration-new/cni-version-testing/cni_version_host_networking_test.go +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"). You may -// not use this file except in compliance with the License. A copy of the -// License is located at -// -// http://aws.amazon.com/apache2.0/ -// -// or in the "license" file accompanying this file. This file is distributed -// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -// express or implied. See the License for the specific language governing -// permissions and limitations under the License. - -package versiontesting - -import ( - "fmt" - "strconv" - "time" - - "github.com/aws/amazon-vpc-cni-k8s/test/agent/pkg/input" - v1 "k8s.io/api/core/v1" - - "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/manifest" - k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils" - "github.com/aws/amazon-vpc-cni-k8s/test/framework/utils" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type TestType int - -const ( - NetworkingTearDownSucceeds TestType = iota - NetworkingTearDownFails - NetworkingSetupSucceeds - NetworkingSetupFails -) - -const ( - AWS_VPC_ENI_MTU = "AWS_VPC_ENI_MTU" - AWS_VPC_K8S_CNI_VETHPREFIX = "AWS_VPC_K8S_CNI_VETHPREFIX" - NEW_MTU_VAL = 1300 - NEW_VETH_PREFIX = "veth" - DEFAULT_MTU_VAL = "9001" - DEFAULT_VETH_PREFIX = "eni" -) - -var _ = Describe("test host networking on upgrade/downgrade", func() { - - It("should apply initial addon version successfully", func() { - ApplyAddOn(initialCNIVersion) - //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", - "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) - - }) - - Context("when testing host networking on initial version", func() { - testHostNetworking() - }) - - It("should apply final addon version successfully", func() { - ApplyAddOn(finalCNIVersion) - //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", - "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) - - }) - - Context("when testing host networking on final version", func() { - testHostNetworking() - }) - -}) - -func testHostNetworking() { - var err error - var podLabelKey = "app" - var podLabelVal = "host-networking-test" - - Context("when pods using IP from primary and secondary ENI are created", func() { - AfterEach(func() { - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, utils.AwsNodeName, utils.AwsNodeNamespace, utils.AwsNodeName, map[string]string{ - AWS_VPC_ENI_MTU: DEFAULT_MTU_VAL, - AWS_VPC_K8S_CNI_VETHPREFIX: DEFAULT_VETH_PREFIX, - }) - }) - It("should have correct host networking setup when running and cleaned up once terminated", func() { - // Launch enough pods so some pods end up using primary ENI IP and some using secondary - // ENI IP - deployment := manifest.NewBusyBoxDeploymentBuilder(). - Replicas(maxIPPerInterface*2). - PodLabel(podLabelKey, podLabelVal). - NodeName(primaryNode.Name). - Build() - - By("creating a deployment to launch pod using primary and secondary ENI IP") - deployment, err = f.K8sResourceManagers.DeploymentManager(). - CreateAndWaitTillDeploymentIsReady(deployment, utils.DefaultDeploymentReadyTimeout) - Expect(err).ToNot(HaveOccurred()) - - By("getting the list of pods using IP from primary and secondary ENI") - interfaceTypeToPodList := - GetPodsOnPrimaryAndSecondaryInterface(primaryNode, podLabelKey, podLabelVal) - - // Primary ENI and Secondary ENI IPs are handled differently when setting up - // the host networking rule hence this check - Expect(len(interfaceTypeToPodList.PodsOnSecondaryENI)). - Should(BeNumerically(">", 0)) - Expect(len(interfaceTypeToPodList.PodsOnPrimaryENI)). - Should(BeNumerically(">", 0)) - - By("generating the pod networking validation input to be passed to tester") - input, err := GetPodNetworkingValidationInput(interfaceTypeToPodList).Serialize() - Expect(err).NotTo(HaveOccurred()) - - By("validating host networking setup is setup correctly") - ValidateHostNetworking(NetworkingSetupSucceeds, input) - - By("deleting the deployment to test teardown") - err = f.K8sResourceManagers.DeploymentManager(). - DeleteAndWaitTillDeploymentIsDeleted(deployment) - Expect(err).ToNot(HaveOccurred()) - - By("waiting to allow CNI to tear down networking for terminated pods") - time.Sleep(time.Second * 60) - - By("validating host networking is teared down correctly") - ValidateHostNetworking(NetworkingTearDownSucceeds, input) - }) - - It("Validate Host Networking setup after changing MTU and Veth Prefix", func() { - deployment := manifest.NewBusyBoxDeploymentBuilder(). - Replicas(6). - PodLabel(podLabelKey, podLabelVal). - NodeName(primaryNode.Name). - Build() - - By("Configuring Veth Prefix and MTU value on aws-node daemonset") - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, utils.AwsNodeName, utils.AwsNodeNamespace, utils.AwsNodeName, map[string]string{ - AWS_VPC_ENI_MTU: strconv.Itoa(NEW_MTU_VAL), - AWS_VPC_K8S_CNI_VETHPREFIX: NEW_VETH_PREFIX, - }) - - By("creating a deployment to launch pods") - deployment, err = f.K8sResourceManagers.DeploymentManager(). - CreateAndWaitTillDeploymentIsReady(deployment, utils.DefaultDeploymentReadyTimeout) - Expect(err).ToNot(HaveOccurred()) - - By("getting the list of pods using IP from primary and secondary ENI") - interfaceTypeToPodList := - GetPodsOnPrimaryAndSecondaryInterface(primaryNode, podLabelKey, podLabelVal) - - By("generating the pod networking validation input to be passed to tester") - podNetworkingValidationInput := GetPodNetworkingValidationInput(interfaceTypeToPodList) - podNetworkingValidationInput.VethPrefix = NEW_VETH_PREFIX - podNetworkingValidationInput.ValidateMTU = true - podNetworkingValidationInput.MTU = NEW_MTU_VAL - input, err := podNetworkingValidationInput.Serialize() - Expect(err).NotTo(HaveOccurred()) - - By("validating host networking setup is setup correctly with MTU check as well") - ValidateHostNetworking(NetworkingSetupSucceeds, input) - - By("deleting the deployment to test teardown") - err = f.K8sResourceManagers.DeploymentManager(). - DeleteAndWaitTillDeploymentIsDeleted(deployment) - Expect(err).ToNot(HaveOccurred()) - - By("waiting to allow CNI to tear down networking for terminated pods") - time.Sleep(time.Second * 60) - - By("validating host networking is teared down correctly") - ValidateHostNetworking(NetworkingTearDownSucceeds, input) - }) - }) - - Context("when host networking is tested on invalid input", func() { - It("tester pod should error out", func() { - - By("creating a single pod on the test node") - parkingPod := manifest.NewDefaultPodBuilder(). - Container(manifest.NewBusyBoxContainerBuilder().Build()). - Name("parking-pod"). - NodeName(primaryNode.Name). - Build() - - parkingPod, err = f.K8sResourceManagers.PodManager(). - CreatAndWaitTillRunning(parkingPod) - Expect(err).ToNot(HaveOccurred()) - - validInput, err := GetPodNetworkingValidationInput(InterfaceTypeToPodList{ - PodsOnPrimaryENI: []v1.Pod{*parkingPod}, - }).Serialize() - Expect(err).NotTo(HaveOccurred()) - - By("first validating the tester work on valid input") - ValidateHostNetworking(NetworkingSetupSucceeds, validInput) - - By("validating tester fails when invalid IP is passed") - invalidPod := parkingPod.DeepCopy() - invalidPod.Status.PodIP = "1.1.1.1" - - invalidInput, err := GetPodNetworkingValidationInput(InterfaceTypeToPodList{ - PodsOnPrimaryENI: []v1.Pod{*invalidPod}, - }).Serialize() - Expect(err).NotTo(HaveOccurred()) - - ValidateHostNetworking(NetworkingSetupFails, invalidInput) - - By("validating the tester fails when invalid namespace is passed") - invalidPod = parkingPod.DeepCopy() - // veth pair name is generated using namespace+name so the test should fail - invalidPod.Namespace = "different" - - invalidInput, err = GetPodNetworkingValidationInput(InterfaceTypeToPodList{ - PodsOnPrimaryENI: []v1.Pod{*invalidPod}, - }).Serialize() - Expect(err).NotTo(HaveOccurred()) - - ValidateHostNetworking(NetworkingSetupFails, invalidInput) - - By("validating the tester fails when tear down check is run on running pod") - ValidateHostNetworking(NetworkingTearDownFails, validInput) - - By("deleting the parking pod") - err = f.K8sResourceManagers.PodManager(). - DeleteAndWaitTillPodDeleted(parkingPod) - Expect(err).ToNot(HaveOccurred()) - }) - }) -} - -// Validate host networking for the list of pods supplied -func ValidateHostNetworking(testType TestType, podValidationInputString string) { - testerArgs := []string{fmt.Sprintf("-pod-networking-validation-input=%s", - podValidationInputString)} - - var shouldTestPodError bool - if NetworkingSetupSucceeds == testType { - testerArgs = append(testerArgs, "-test-setup=true") - } else if NetworkingSetupFails == testType { - testerArgs = append(testerArgs, "-test-setup=true") - shouldTestPodError = true - } else if NetworkingTearDownSucceeds == testType { - testerArgs = append(testerArgs, "-test-cleanup=true") - } else if NetworkingTearDownFails == testType { - testerArgs = append(testerArgs, "-test-cleanup=true") - shouldTestPodError = true - } - - testContainer := manifest.NewTestHelperContainer(). - Command([]string{"./networking"}). - Args(testerArgs). - Build() - - testPod := manifest.NewDefaultPodBuilder(). - Container(testContainer). - NodeName(primaryNode.Name). - HostNetwork(true). - Build() - - By("creating pod to test host networking setup") - testPod, err := f.K8sResourceManagers.PodManager(). - CreateAndWaitTillPodCompleted(testPod) - logs, errLogs := f.K8sResourceManagers.PodManager(). - PodLogs(testPod.Namespace, testPod.Name) - Expect(errLogs).ToNot(HaveOccurred()) - - fmt.Fprintln(GinkgoWriter, logs) - - if shouldTestPodError { - Expect(err).To(HaveOccurred()) - } else { - Expect(err).ToNot(HaveOccurred()) - } - - By("deleting the host networking setup pod") - err = f.K8sResourceManagers.PodManager(). - DeleteAndWaitTillPodDeleted(testPod) - Expect(err).ToNot(HaveOccurred()) -} - -// GetPodNetworkingValidationInput returns input string containing the list of pods for which -// the host networking has to be tested -func GetPodNetworkingValidationInput(interfaceTypeToPodList InterfaceTypeToPodList) input.PodNetworkingValidationInput { - - ip := input.PodNetworkingValidationInput{ - VPCCidrRange: vpcCIDRs, - VethPrefix: "eni", - PodList: []input.Pod{}, - ValidateMTU: false, - } - - for _, primaryENIPod := range interfaceTypeToPodList.PodsOnPrimaryENI { - ip.PodList = append(ip.PodList, input.Pod{ - PodName: primaryENIPod.Name, - PodNamespace: primaryENIPod.Namespace, - PodIPv4Address: primaryENIPod.Status.PodIP, - IsIPFromSecondaryENI: false, - }) - } - - for _, secondaryENIPod := range interfaceTypeToPodList.PodsOnSecondaryENI { - ip.PodList = append(ip.PodList, input.Pod{ - PodName: secondaryENIPod.Name, - PodNamespace: secondaryENIPod.Namespace, - PodIPv4Address: secondaryENIPod.Status.PodIP, - IsIPFromSecondaryENI: true, - }) - } - - return ip -} diff --git a/test/integration-new/cni-version-testing/cni_version_pod_traffic_test.go b/test/integration-new/cni-version-testing/cni_version_pod_traffic_test.go deleted file mode 100644 index a8d705ceaa5..00000000000 --- a/test/integration-new/cni-version-testing/cni_version_pod_traffic_test.go +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"). You may -// not use this file except in compliance with the License. A copy of the -// License is located at -// -// http://aws.amazon.com/apache2.0/ -// -// or in the "license" file accompanying this file. This file is distributed -// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -// express or implied. See the License for the specific language governing -// permissions and limitations under the License. - -package versiontesting - -import ( - "fmt" - - "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/manifest" - k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils" - "github.com/aws/amazon-vpc-cni-k8s/test/framework/utils" - "github.com/aws/aws-sdk-go/service/ec2" - v1 "k8s.io/api/apps/v1" - - . "github.com/onsi/ginkgo" - - . "github.com/onsi/gomega" - - "strconv" - - coreV1 "k8s.io/api/core/v1" -) - -var ( - // Primary node server deployment - primaryNodeDeployment *v1.Deployment - // Secondary node Server deployment - secondaryNodeDeployment *v1.Deployment - - // Map of Pods placed on primary/secondary ENI IP on primary node - interfaceToPodListOnPrimaryNode InterfaceTypeToPodList - // Map of Pods placed on primary/secondary ENI IP on secondary node - interfaceToPodListOnSecondaryNode InterfaceTypeToPodList -) - -var _ = Describe("test pod traffic on upgrade/downgrade", func() { - - It("should apply initial addon version successfully", func() { - ApplyAddOn(initialCNIVersion) - //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", - "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) - - }) - - Context("when testing pod traffic on initial version", func() { - testPodNetworking() - }) - - It("should apply final addon version successfully", func() { - - ApplyAddOn(finalCNIVersion) - //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", - "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) - - }) - - Context("when testing pod traffic on final version", func() { - testPodNetworking() - }) - -}) - -func testPodNetworking() { - JustBeforeEach(func() { - By("authorizing security group ingress on instance security group") - err = f.CloudServices.EC2(). - AuthorizeSecurityGroupIngress(instanceSecurityGroupID, protocol, serverPort, serverPort, "0.0.0.0/0") - Expect(err).ToNot(HaveOccurred()) - - By("authorizing security group egress on instance security group") - err = f.CloudServices.EC2(). - AuthorizeSecurityGroupEgress(instanceSecurityGroupID, protocol, serverPort, serverPort, "0.0.0.0/0") - Expect(err).ToNot(HaveOccurred()) - - serverContainer := manifest. - NewNetCatAlpineContainer(). - Command(serverListenCmd). - Args(serverListenCmdArgs). - Build() - - By("creating server deployment on the primary node") - primaryNodeDeployment = manifest. - NewDefaultDeploymentBuilder(). - Container(serverContainer). - Replicas(maxIPPerInterface*2). // X2 so Pods are created on secondary ENI too - NodeName(primaryNode.Name). - PodLabel("node", "primary"). - Name("primary-node-server"). - Build() - - primaryNodeDeployment, err = f.K8sResourceManagers. - DeploymentManager(). - CreateAndWaitTillDeploymentIsReady(primaryNodeDeployment, utils.DefaultDeploymentReadyTimeout) - Expect(err).ToNot(HaveOccurred()) - - interfaceToPodListOnPrimaryNode = - GetPodsOnPrimaryAndSecondaryInterface(primaryNode, "node", "primary") - - // At least two Pods should be placed on the Primary and Secondary Interface - // on the Primary and Secondary Node in order to test all possible scenarios - Expect(len(interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI)). - Should(BeNumerically(">", 1)) - Expect(len(interfaceToPodListOnPrimaryNode.PodsOnSecondaryENI)). - Should(BeNumerically(">", 1)) - - By("creating server deployment on secondary node") - secondaryNodeDeployment = manifest. - NewDefaultDeploymentBuilder(). - Container(serverContainer). - Replicas(maxIPPerInterface*2). // X2 so Pods are created on secondary ENI too - NodeName(secondaryNode.Name). - PodLabel("node", "secondary"). - Name("secondary-node-server"). - Build() - - secondaryNodeDeployment, err = f.K8sResourceManagers. - DeploymentManager(). - CreateAndWaitTillDeploymentIsReady(secondaryNodeDeployment, utils.DefaultDeploymentReadyTimeout) - Expect(err).ToNot(HaveOccurred()) - - interfaceToPodListOnSecondaryNode = - GetPodsOnPrimaryAndSecondaryInterface(secondaryNode, "node", "secondary") - - // Same reason as mentioned above - Expect(len(interfaceToPodListOnSecondaryNode.PodsOnPrimaryENI)). - Should(BeNumerically(">", 1)) - Expect(len(interfaceToPodListOnSecondaryNode.PodsOnSecondaryENI)). - Should(BeNumerically(">", 1)) - }) - - JustAfterEach(func() { - By("revoking security group ingress on instance security group") - err = f.CloudServices.EC2(). - RevokeSecurityGroupIngress(instanceSecurityGroupID, protocol, serverPort, serverPort, "0.0.0.0/0") - Expect(err).ToNot(HaveOccurred()) - - By("revoking security group egress on instance security group") - err = f.CloudServices.EC2(). - RevokeSecurityGroupEgress(instanceSecurityGroupID, protocol, serverPort, serverPort, "0.0.0.0/0") - Expect(err).ToNot(HaveOccurred()) - - By("deleting the primary node server deployment") - err = f.K8sResourceManagers.DeploymentManager(). - DeleteAndWaitTillDeploymentIsDeleted(primaryNodeDeployment) - Expect(err).ToNot(HaveOccurred()) - - By("deleting the secondary node server deployment") - err = f.K8sResourceManagers.DeploymentManager(). - DeleteAndWaitTillDeploymentIsDeleted(secondaryNodeDeployment) - Expect(err).ToNot(HaveOccurred()) - }) - - Context("when testing ICMP traffic", func() { - BeforeEach(func() { - // The number of packets to be sent - packetCount := 5 - // Protocol needs to be set allow ICMP traffic on the EC2 SG - protocol = "ICMP" - // ICMP doesn't need any port to be opened on the SG - serverPort = 0 - // Since ping doesn't need any server, just sleep on the server pod - serverListenCmd = []string{"sleep"} - serverListenCmdArgs = []string{"1000"} - - // Verify all the packets were transmitted and received successfully - testerExpectedStdOut = fmt.Sprintf("%d packets transmitted, "+ - "%d packets received", packetCount, packetCount) - testerExpectedStdErr = "" - - testConnectionCommandFunc = func(receiverPod coreV1.Pod, port int) []string { - return []string{"ping", "-c", strconv.Itoa(packetCount), receiverPod.Status.PodIP} - } - }) - - It("should allow ICMP traffic", func() { - CheckConnectivityForMultiplePodPlacement( - interfaceToPodListOnPrimaryNode, interfaceToPodListOnSecondaryNode, - serverPort, testerExpectedStdOut, testerExpectedStdErr, testConnectionCommandFunc) - }) - }) - Context("[CANARY][SMOKE] when establishing UDP connection from tester to server", func() { - BeforeEach(func() { - serverPort = 2273 - protocol = ec2.ProtocolUdp - serverListenCmd = []string{"nc"} - // The nc flag "-l" for listen mode, "-k" to keep server up and not close - // connection after each connection, "-u" for udp - serverListenCmdArgs = []string{"-u", "-l", "-k", strconv.Itoa(serverPort)} - - // Verbose output from nc is being redirected to stderr instead of stdout - testerExpectedStdErr = "succeeded!" - testerExpectedStdOut = "" - - // The nc flag "-u" for UDP traffic, "-v" for verbose output and "-wn" for timing out - // in n seconds - testConnectionCommandFunc = func(receiverPod coreV1.Pod, port int) []string { - return []string{"nc", "-u", "-v", "-w2", receiverPod.Status.PodIP, strconv.Itoa(port)} - } - - // Create a negative test case with the wrong port number. This is to reinforce the - // positive test case work by verifying negative cases do throw error - testFailedConnectionCommandFunc = func(receiverPod coreV1.Pod, port int) []string { - return []string{"nc", "-u", "-v", "-w2", receiverPod.Status.PodIP, strconv.Itoa(port + 1)} - } - }) - - It("connection should be established", func() { - CheckConnectivityForMultiplePodPlacement( - interfaceToPodListOnPrimaryNode, interfaceToPodListOnSecondaryNode, - serverPort, testerExpectedStdOut, testerExpectedStdErr, testConnectionCommandFunc) - - By("verifying connection fails for unreachable port") - VerifyConnectivityFailsForNegativeCase(interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[0], - interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[1], serverPort, - testFailedConnectionCommandFunc) - }) - }) - - Context("[CANARY][SMOKE] when establishing TCP connection from tester to server", func() { - - BeforeEach(func() { - serverPort = 2273 - protocol = ec2.ProtocolTcp - // Test tcp connection using netcat - serverListenCmd = []string{"nc"} - // The nc flag "-l" for listen mode, "-k" to keep server up and not close - // connection after each connection - serverListenCmdArgs = []string{"-k", "-l", strconv.Itoa(serverPort)} - - // netcat verbose output is being redirected to stderr instead of stdout - testerExpectedStdErr = "succeeded!" - testerExpectedStdOut = "" - - // The nc flag "-v" for verbose output and "-wn" for timing out in n seconds - testConnectionCommandFunc = func(receiverPod coreV1.Pod, port int) []string { - return []string{"nc", "-v", "-w2", receiverPod.Status.PodIP, strconv.Itoa(port)} - } - - // Create a negative test case with the wrong port number. This is to reinforce the - // positive test case work by verifying negative cases do throw error - testFailedConnectionCommandFunc = func(receiverPod coreV1.Pod, port int) []string { - return []string{"nc", "-v", "-w2", receiverPod.Status.PodIP, strconv.Itoa(port + 1)} - } - }) - - It("should allow connection across nodes and across interface types", func() { - CheckConnectivityForMultiplePodPlacement( - interfaceToPodListOnPrimaryNode, interfaceToPodListOnSecondaryNode, - serverPort, testerExpectedStdOut, testerExpectedStdErr, testConnectionCommandFunc) - - By("verifying connection fails for unreachable port") - VerifyConnectivityFailsForNegativeCase(interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[0], - interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[1], serverPort, - testFailedConnectionCommandFunc) - }) - }) -} - -func VerifyConnectivityFailsForNegativeCase(senderPod coreV1.Pod, receiverPod coreV1.Pod, port int, - getTestCommandFunc func(receiverPod coreV1.Pod, port int) []string) { - - testerCommand := getTestCommandFunc(receiverPod, port) - - fmt.Fprintf(GinkgoWriter, "verifying connectivity fails from pod %s on node %s with IP %s to pod"+ - " %s on node %s with IP %s\n", senderPod.Name, senderPod.Spec.NodeName, senderPod.Status.PodIP, - receiverPod.Name, receiverPod.Spec.NodeName, receiverPod.Status.PodIP) - - _, _, err := f.K8sResourceManagers.PodManager(). - PodExec(senderPod.Namespace, senderPod.Name, testerCommand) - Expect(err).To(HaveOccurred()) -} - -// CheckConnectivityForMultiplePodPlacement checks connectivity for various scenarios, an example -// connection from Pod on Node 1 having IP from Primary Network Interface to Pod on Node 2 having -// IP from Secondary Network Interface -func CheckConnectivityForMultiplePodPlacement(interfaceToPodListOnPrimaryNode InterfaceTypeToPodList, - interfaceToPodListOnSecondaryNode InterfaceTypeToPodList, port int, - testerExpectedStdOut string, testerExpectedStdErr string, - getTestCommandFunc func(receiverPod coreV1.Pod, port int) []string) { - - By("checking connection on same node, primary to primary") - testConnectivity( - interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[0], - interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[1], - testerExpectedStdOut, testerExpectedStdErr, port, getTestCommandFunc) - - By("checking connection on same node, primary to secondary") - testConnectivity( - interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[0], - interfaceToPodListOnPrimaryNode.PodsOnSecondaryENI[0], - testerExpectedStdOut, testerExpectedStdErr, port, getTestCommandFunc) - - By("checking connection on same node, secondary to secondary") - testConnectivity( - interfaceToPodListOnPrimaryNode.PodsOnSecondaryENI[0], - interfaceToPodListOnPrimaryNode.PodsOnSecondaryENI[1], - testerExpectedStdOut, testerExpectedStdErr, port, getTestCommandFunc) - - By("checking connection on different node, primary to primary") - testConnectivity( - interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[0], - interfaceToPodListOnSecondaryNode.PodsOnPrimaryENI[0], - testerExpectedStdOut, testerExpectedStdErr, port, getTestCommandFunc) - - By("checking connection on different node, primary to secondary") - testConnectivity( - interfaceToPodListOnPrimaryNode.PodsOnPrimaryENI[0], - interfaceToPodListOnSecondaryNode.PodsOnSecondaryENI[0], - testerExpectedStdOut, testerExpectedStdErr, port, getTestCommandFunc) - - By("checking connection on different node, secondary to secondary") - testConnectivity( - interfaceToPodListOnPrimaryNode.PodsOnSecondaryENI[0], - interfaceToPodListOnSecondaryNode.PodsOnSecondaryENI[0], - testerExpectedStdOut, testerExpectedStdErr, port, getTestCommandFunc) -} - -// testConnectivity verifies connectivity between tester and server -func testConnectivity(senderPod coreV1.Pod, receiverPod coreV1.Pod, expectedStdout string, - expectedStderr string, port int, getTestCommandFunc func(receiverPod coreV1.Pod, port int) []string) { - - testerCommand := getTestCommandFunc(receiverPod, port) - - fmt.Fprintf(GinkgoWriter, "verifying connectivity from pod %s on node %s with IP %s to pod"+ - " %s on node %s with IP %s\n", senderPod.Name, senderPod.Spec.NodeName, senderPod.Status.PodIP, - receiverPod.Name, receiverPod.Spec.NodeName, receiverPod.Status.PodIP) - - stdOut, stdErr, err := f.K8sResourceManagers.PodManager(). - PodExec(senderPod.Namespace, senderPod.Name, testerCommand) - Expect(err).ToNot(HaveOccurred()) - - fmt.Fprintf(GinkgoWriter, "stdout: %s and stderr: %s\n", stdOut, stdErr) - - Expect(stdErr).To(ContainSubstring(expectedStderr)) - Expect(stdOut).To(ContainSubstring(expectedStdout)) -} diff --git a/test/integration-new/cni-version-testing/cni_version_service_connectivity_test.go b/test/integration-new/cni-version-testing/cni_version_service_connectivity_test.go deleted file mode 100644 index 6b41fc377a4..00000000000 --- a/test/integration-new/cni-version-testing/cni_version_service_connectivity_test.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"). You may -// not use this file except in compliance with the License. A copy of the -// License is located at -// -// http://aws.amazon.com/apache2.0/ -// -// or in the "license" file accompanying this file. This file is distributed -// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -// express or implied. See the License for the specific language governing -// permissions and limitations under the License. - -package versiontesting - -import ( - "context" - "fmt" - "time" - - k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils" - - "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/manifest" - "github.com/aws/amazon-vpc-cni-k8s/test/framework/utils" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - appsV1 "k8s.io/api/apps/v1" - batchV1 "k8s.io/api/batch/v1" - v1 "k8s.io/api/core/v1" -) - -const ( - serviceLabelSelectorKey = "role" - serviceLabelSelectorVal = "service-test" -) - -var _ = Describe("test service connectivity on upgrade/downgrade", func() { - - It("should apply initial addon version successfully", func() { - ApplyAddOn(initialCNIVersion) - //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", - "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) - - }) - - Context("when testing service connectivity on initial version", func() { - testServiceConnectivity() - }) - - It("should apply final addon version successfully", func() { - ApplyAddOn(finalCNIVersion) - //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI - k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", - "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) - - }) - - Context("when testing service connectivity on final version", func() { - testServiceConnectivity() - }) - -}) - -func testServiceConnectivity() { - var err error - - // Deployment running the http server - var deployment *appsV1.Deployment - var deploymentContainer v1.Container - - // Service front ending the http server deployment - var service *v1.Service - var serviceType v1.ServiceType - var serviceAnnotation map[string]string - - // Test job that verifies connectivity to the http server - // by querying the service URL - var testerJob *batchV1.Job - var testerContainer v1.Container - - // Test job that verifies test fails when connecting to - // a non reachable port/address - var negativeTesterJob *batchV1.Job - var negativeTesterContainer v1.Container - - JustBeforeEach(func() { - deploymentContainer = manifest.NewBusyBoxContainerBuilder(). - Image("nginx:1.21.4"). - Command(nil). - Port(v1.ContainerPort{ - ContainerPort: 80, - Protocol: "TCP", - }).Build() - - deployment = manifest.NewDefaultDeploymentBuilder(). - Name("http-server"). - Container(deploymentContainer). - Replicas(20). - PodLabel(serviceLabelSelectorKey, serviceLabelSelectorVal). - Build() - - By("creating and waiting for deployment to be ready") - deployment, err = f.K8sResourceManagers.DeploymentManager(). - CreateAndWaitTillDeploymentIsReady(deployment, utils.DefaultDeploymentReadyTimeout) - Expect(err).ToNot(HaveOccurred()) - - service = manifest.NewHTTPService(). - ServiceType(serviceType). - Name("test-service"). - Selector(serviceLabelSelectorKey, serviceLabelSelectorVal). - Annotations(serviceAnnotation). - Build() - - By(fmt.Sprintf("creating the service of type %s", serviceType)) - service, err = f.K8sResourceManagers.ServiceManager(). - CreateService(context.Background(), service) - Expect(err).ToNot(HaveOccurred()) - - fmt.Fprintf(GinkgoWriter, "created service\n: %+v\n", service.Status) - - By("sleeping for some time to allow service to become ready") - time.Sleep(utils.PollIntervalLong) - - testerContainer = manifest.NewBusyBoxContainerBuilder(). - Command([]string{"wget"}). - Args([]string{"--spider", "-T", "5", fmt.Sprintf("%s:%d", service.Spec.ClusterIP, - service.Spec.Ports[0].Port)}). - Build() - - testerJob = manifest.NewDefaultJobBuilder(). - Parallelism(20). - Container(testerContainer). - Build() - - By("creating jobs to verify service connectivity") - _, err = f.K8sResourceManagers.JobManager(). - CreateAndWaitTillJobCompleted(testerJob) - Expect(err).ToNot(HaveOccurred()) - - // Test connection to an unreachable port should fail - negativeTesterContainer = manifest.NewBusyBoxContainerBuilder(). - Command([]string{"wget"}). - Args([]string{"--spider", "-T", "1", fmt.Sprintf("%s:%d", service.Spec.ClusterIP, 2273)}). - Build() - - negativeTesterJob = manifest.NewDefaultJobBuilder(). - Name("negative-test-job"). - Parallelism(2). - Container(negativeTesterContainer). - Build() - - By("creating negative jobs to verify service connectivity fails for unreachable port") - _, err = f.K8sResourceManagers.JobManager(). - CreateAndWaitTillJobCompleted(negativeTesterJob) - Expect(err).To(HaveOccurred()) - }) - - JustAfterEach(func() { - err := f.K8sResourceManagers.JobManager().DeleteAndWaitTillJobIsDeleted(testerJob) - Expect(err).ToNot(HaveOccurred()) - - err = f.K8sResourceManagers.JobManager().DeleteAndWaitTillJobIsDeleted(negativeTesterJob) - Expect(err).ToNot(HaveOccurred()) - - err = f.K8sResourceManagers.ServiceManager().DeleteAndWaitTillServiceDeleted(context.Background(), service) - Expect(err).ToNot(HaveOccurred()) - - err = f.K8sResourceManagers.DeploymentManager().DeleteAndWaitTillDeploymentIsDeleted(deployment) - Expect(err).ToNot(HaveOccurred()) - }) - - Context("when a deployment behind clb service is created", func() { - BeforeEach(func() { - serviceType = v1.ServiceTypeLoadBalancer - }) - - It("clb service pod should be reachable", func() {}) - }) - - Context("when a deployment behind nlb service is created", func() { - BeforeEach(func() { - serviceType = v1.ServiceTypeLoadBalancer - serviceAnnotation = map[string]string{"service.beta.kubernetes.io/" + - "aws-load-balancer-type": "nlb"} - }) - - It("nlb service pod should be reachable", func() {}) - }) - - Context("when a deployment behind cluster IP is created", func() { - BeforeEach(func() { - serviceType = v1.ServiceTypeClusterIP - }) - - It("clusterIP service pod should be reachable", func() {}) - }) - - Context("when a deployment behind node port is created", func() { - BeforeEach(func() { - serviceType = v1.ServiceTypeNodePort - }) - - It("node port service pod should be reachable", func() {}) - }) - -} diff --git a/test/integration-new/cni-version-testing/cni_version_suite_test.go b/test/integration-new/cni-version-testing/cni_version_suite_test.go deleted file mode 100644 index 10f722b0783..00000000000 --- a/test/integration-new/cni-version-testing/cni_version_suite_test.go +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"). You may -// not use this file except in compliance with the License. A copy of the -// License is located at -// -// http://aws.amazon.com/apache2.0/ -// -// or in the "license" file accompanying this file. This file is distributed -// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -// express or implied. See the License for the specific language governing -// permissions and limitations under the License. - -package versiontesting - -import ( - "fmt" - "testing" - "time" - - "github.com/aws/amazon-vpc-cni-k8s/test/framework" - k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils" - "github.com/aws/amazon-vpc-cni-k8s/test/framework/utils" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/aws/aws-sdk-go/service/eks" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - coreV1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" -) - -const InstanceTypeNodeLabelKey = "beta.kubernetes.io/instance-type" - -var ( - f *framework.Framework - maxIPPerInterface int - primaryNode v1.Node - secondaryNode v1.Node - instanceSecurityGroupID string - vpcCIDRs []string - - k8sVersion string - initialCNIVersion string - finalCNIVersion string - err error - // The command to run on server pods, to allow incoming - // connections for different traffic type - serverListenCmd []string - // Arguments to the server listen command - serverListenCmdArgs []string - // The function that generates command which will be sent from - // tester pod to receiver pod - testConnectionCommandFunc func(serverPod coreV1.Pod, port int) []string - // The functions reinforces that the positive test is working as - // expected by creating a negative test command that should fail - testFailedConnectionCommandFunc func(serverPod coreV1.Pod, port int) []string - // Expected stdout from the exec command on testing connection - // from tester to server - testerExpectedStdOut string - // Expected stderr from the exec command on testing connection - // from tester to server - testerExpectedStdErr string - // The port on which server is listening for new connections - serverPort int - // Protocol for establishing connection to server - protocol string -) - -func TestCNIVersion(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "CNI Upgrade/Downgrade Testing Suite") -} - -var ( - describeAddonOutput *eks.DescribeAddonOutput -) -var _ = BeforeSuite(func() { - f = framework.New(framework.GlobalOptions) - - By("creating test namespace") - f.K8sResourceManagers.NamespaceManager(). - CreateNamespace(utils.DefaultTestNamespace) - - By(fmt.Sprintf("getting the node with the node label key %s and value %s", - f.Options.NgNameLabelKey, f.Options.NgNameLabelVal)) - nodes, err := f.K8sResourceManagers.NodeManager().GetNodes(f.Options.NgNameLabelKey, f.Options.NgNameLabelVal) - Expect(err).ToNot(HaveOccurred()) - - By("verifying more than 1 nodes are present for the test") - Expect(len(nodes.Items)).Should(BeNumerically(">", 1)) - - // Set the primary and secondary node for testing - primaryNode = nodes.Items[0] - secondaryNode = nodes.Items[1] - - // Get the node security group - instanceID := k8sUtils.GetInstanceIDFromNode(primaryNode) - primaryInstance, err := f.CloudServices.EC2().DescribeInstance(instanceID) - Expect(err).ToNot(HaveOccurred()) - - // This won't work if the first SG is only associated with the primary instance. - // Need a robust substring in the SGP name to identify node SGP - instanceSecurityGroupID = *primaryInstance.NetworkInterfaces[0].Groups[0].GroupId - - By("getting the instance type from node label " + InstanceTypeNodeLabelKey) - instanceType := primaryNode.Labels[InstanceTypeNodeLabelKey] - - By("getting the network interface details from ec2") - instanceOutput, err := f.CloudServices.EC2().DescribeInstanceType(instanceType) - Expect(err).ToNot(HaveOccurred()) - - // Pods often get stuck due insufficient capacity, so adding some buffer to the maxIPPerInterface - maxIPPerInterface = int(*instanceOutput[0].NetworkInfo.Ipv4AddressesPerInterface) - 5 - - By("describing the VPC to get the VPC CIDRs") - describeVPCOutput, err := f.CloudServices.EC2().DescribeVPC(f.Options.AWSVPCID) - Expect(err).ToNot(HaveOccurred()) - - for _, cidrBlockAssociationSet := range describeVPCOutput.Vpcs[0].CidrBlockAssociationSet { - vpcCIDRs = append(vpcCIDRs, *cidrBlockAssociationSet.CidrBlock) - } - - By("getting the cluster k8s version") - describeClusterOutput, err := f.CloudServices.EKS().DescribeCluster(f.Options.ClusterName) - Expect(err).ToNot(HaveOccurred()) - - k8sVersion = *describeClusterOutput.Cluster.Version - initialCNIVersion = f.Options.InitialCNIVersion - finalCNIVersion = f.Options.FinalCNIVersion - -}) - -var _ = AfterSuite(func() { - By("deleting test namespace") - f.K8sResourceManagers.NamespaceManager(). - DeleteAndWaitTillNamespaceDeleted(utils.DefaultTestNamespace) - -}) - -func ApplyAddOn(versionName string) { - By("getting the current addon") - describeAddonOutput, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) - if err == nil { - fmt.Printf("By applying addon %s\n", versionName) - By("checking if the current addon is same as addon to be applied") - if *describeAddonOutput.Addon.AddonVersion != versionName { - - By("deleting the current vpc cni addon ") - _, err = f.CloudServices.EKS().DeleteAddon("vpc-cni", f.Options.ClusterName) - Expect(err).ToNot(HaveOccurred()) - - _, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) - for err == nil { - time.Sleep(5 * time.Second) - _, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) - - } - - By("apply initial addon version") - _, err = f.CloudServices.EKS().CreateAddonWithVersion("vpc-cni", f.Options.ClusterName, versionName) - Expect(err).ToNot(HaveOccurred()) - - } - } else { - By("apply addon version") - _, err = f.CloudServices.EKS().CreateAddonWithVersion("vpc-cni", f.Options.ClusterName, versionName) - Expect(err).ToNot(HaveOccurred()) - } - - var status = "" - - By("waiting for addon to be ACTIVE") - for status != "ACTIVE" { - describeAddonOutput, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) - Expect(err).ToNot(HaveOccurred()) - status = *describeAddonOutput.Addon.Status - time.Sleep(5 * time.Second) - } -} - -type InterfaceTypeToPodList struct { - PodsOnPrimaryENI []coreV1.Pod - PodsOnSecondaryENI []coreV1.Pod -} - -// GetPodsOnPrimaryAndSecondaryInterface returns the list of Pods on Primary Networking -// Interface and Secondary Network Interface on a given Node -func GetPodsOnPrimaryAndSecondaryInterface(node coreV1.Node, - podLabelKey string, podLabelVal string) InterfaceTypeToPodList { - podList, err := f.K8sResourceManagers. - PodManager(). - GetPodsWithLabelSelector(podLabelKey, podLabelVal) - Expect(err).ToNot(HaveOccurred()) - - instance, err := f.CloudServices.EC2(). - DescribeInstance(k8sUtils.GetInstanceIDFromNode(node)) - Expect(err).ToNot(HaveOccurred()) - - interfaceToPodList := InterfaceTypeToPodList{ - PodsOnPrimaryENI: []coreV1.Pod{}, - PodsOnSecondaryENI: []coreV1.Pod{}, - } - - ipToPod := map[string]coreV1.Pod{} - for _, pod := range podList.Items { - ipToPod[pod.Status.PodIP] = pod - } - - for _, nwInterface := range instance.NetworkInterfaces { - isPrimary := IsPrimaryENI(nwInterface, instance.PrivateIpAddress) - for _, ip := range nwInterface.PrivateIpAddresses { - if pod, found := ipToPod[*ip.PrivateIpAddress]; found { - if isPrimary { - interfaceToPodList.PodsOnPrimaryENI = - append(interfaceToPodList.PodsOnPrimaryENI, pod) - } else { - interfaceToPodList.PodsOnSecondaryENI = - append(interfaceToPodList.PodsOnSecondaryENI, pod) - } - } - } - } - return interfaceToPodList -} - -func IsPrimaryENI(nwInterface *ec2.InstanceNetworkInterface, instanceIPAddr *string) bool { - for _, privateIPAddress := range nwInterface.PrivateIpAddresses { - if *privateIPAddress.PrivateIpAddress == *instanceIPAddr { - return true - } - } - return false -} diff --git a/test/integration-new/cni/cni_version_test.go b/test/integration-new/cni/cni_version_test.go new file mode 100644 index 00000000000..4fdf5047042 --- /dev/null +++ b/test/integration-new/cni/cni_version_test.go @@ -0,0 +1,93 @@ +package cni + +import ( + "fmt" + k8sUtils "github.com/aws/amazon-vpc-cni-k8s/test/framework/resources/k8s/utils" + "github.com/aws/aws-sdk-go/service/eks" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "time" +) + +var ( + describeAddonOutput *eks.DescribeAddonOutput + err error + initialCNIVersion string + finalCNIVersion string +) + +var _ = Describe("test cluster upgrade/downgrade", func() { + + initialCNIVersion = f.Options.InitialCNIVersion + finalCNIVersion = f.Options.FinalCNIVersion + + It("should apply initial addon version successfully", func() { + ApplyAddOn(initialCNIVersion) + //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI + k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", + "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) + + }) + + Context("when testing host networking on initial version", func() { + HostNetworkingTest() + PodTrafficTest() + ServiceConnectivityTest() + }) + + It("should apply final addon version successfully", func() { + ApplyAddOn(finalCNIVersion) + //Set the WARM_ENI_TARGET to 0 to prevent all pods being scheduled on secondary ENI + k8sUtils.AddEnvVarToDaemonSetAndWaitTillUpdated(f, "aws-node", "kube-system", + "aws-node", map[string]string{"WARM_IP_TARGET": "3", "WARM_ENI_TARGET": "0"}) + + }) + + Context("when testing host networking on final version", func() { + HostNetworkingTest() + PodTrafficTest() + ServiceConnectivityTest() + }) + +}) + +func ApplyAddOn(versionName string) { + By("getting the current addon") + describeAddonOutput, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) + if err == nil { + fmt.Printf("By applying addon %s\n", versionName) + By("checking if the current addon is same as addon to be applied") + if *describeAddonOutput.Addon.AddonVersion != versionName { + + By("deleting the current vpc cni addon ") + _, err = f.CloudServices.EKS().DeleteAddon("vpc-cni", f.Options.ClusterName) + Expect(err).ToNot(HaveOccurred()) + + _, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) + for err == nil { + time.Sleep(5 * time.Second) + _, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) + + } + + By("apply initial addon version") + _, err = f.CloudServices.EKS().CreateAddonWithVersion("vpc-cni", f.Options.ClusterName, versionName) + Expect(err).ToNot(HaveOccurred()) + + } + } else { + By("apply addon version") + _, err = f.CloudServices.EKS().CreateAddonWithVersion("vpc-cni", f.Options.ClusterName, versionName) + Expect(err).ToNot(HaveOccurred()) + } + + var status = "" + + By("waiting for addon to be ACTIVE") + for status != "ACTIVE" { + describeAddonOutput, err = f.CloudServices.EKS().DescribeAddon("vpc-cni", f.Options.ClusterName) + Expect(err).ToNot(HaveOccurred()) + status = *describeAddonOutput.Addon.Status + time.Sleep(5 * time.Second) + } +} diff --git a/test/integration-new/cni/host_networking_test.go b/test/integration-new/cni/host_networking_test.go index 03a3abe6879..f544fe4066c 100644 --- a/test/integration-new/cni/host_networking_test.go +++ b/test/integration-new/cni/host_networking_test.go @@ -49,7 +49,10 @@ const ( DEFAULT_VETH_PREFIX = "eni" ) -var _ = Describe("test host networking", func() { +var _ = Describe("test host networking", HostNetworkingTest) + +func HostNetworkingTest() { + var err error var podLabelKey = "app" var podLabelVal = "host-networking-test" @@ -205,7 +208,7 @@ var _ = Describe("test host networking", func() { Expect(err).ToNot(HaveOccurred()) }) }) -}) +} // Validate host networking for the list of pods supplied func ValidateHostNetworking(testType TestType, podValidationInputString string) { diff --git a/test/integration-new/cni/pod_traffic_test.go b/test/integration-new/cni/pod_traffic_test.go index 7014ddac618..06f1f282b3a 100644 --- a/test/integration-new/cni/pod_traffic_test.go +++ b/test/integration-new/cni/pod_traffic_test.go @@ -32,7 +32,9 @@ import ( // Verifies network connectivity across Pods placed on different combination of // primary and second Elastic Networking Interface on two nodes. The test verifies // different traffic type for instance TCP, UDP, ICMP -var _ = Describe("test pod networking", func() { +var _ = Describe("test pod networking", PodTrafficTest) + +func PodTrafficTest() { var ( err error @@ -263,7 +265,7 @@ var _ = Describe("test pod networking", func() { testFailedConnectionCommandFunc) }) }) -}) +} func VerifyConnectivityFailsForNegativeCase(senderPod coreV1.Pod, receiverPod coreV1.Pod, port int, getTestCommandFunc func(receiverPod coreV1.Pod, port int) []string) { diff --git a/test/integration-new/cni/service_connectivity_test.go b/test/integration-new/cni/service_connectivity_test.go index 94e9c944707..47ca4af2332 100644 --- a/test/integration-new/cni/service_connectivity_test.go +++ b/test/integration-new/cni/service_connectivity_test.go @@ -34,7 +34,9 @@ const ( ) // Verifies connectivity to deployment behind different service types -var _ = Describe("[CANARY] test service connectivity", func() { +var _ = Describe("[CANARY] test service connectivity", ServiceConnectivityTest) + +func ServiceConnectivityTest() { var err error // Deployment running the http server @@ -177,4 +179,4 @@ var _ = Describe("[CANARY] test service connectivity", func() { }) //TODO: Add test case to install lb controller and test with nlb-ip mode -}) +}