Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e test case for SecondaryNetwork of SR-IOV type #6922

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wenqiq
Copy link
Contributor

@wenqiq wenqiq commented Jan 14, 2025

  • Add a script to create a Kubernetes testbed on AWS VM Nodes with SR-IOV interface configured.

  • Add e2e test codes for SR-IOV case to validate the traffic between two Pods with secondary network enabled.

  • Add a Jenkins job named cloud-antrea-test-aws-sriov-secondary-network in Jenkins service, and add github comment trigger to trigger the e2e tests for SecondaryNetwork with SR-IOV on demand.

The complete test process record:
https://jenkins.antrea.io/job/cloud-antrea-test-aws-sriov-secondary-network/16/

@luolanzone luolanzone added this to the Antrea v2.3 release milestone Jan 15, 2025
@luolanzone luolanzone added the area/secondary-network Issues or PRs related to support for secondary networks in Antrea label Jan 15, 2025
@wenqiq wenqiq force-pushed the add-sriov-e2e branch 4 times, most recently from 758c687 to 1f77538 Compare January 20, 2025 03:06
@wenqiq wenqiq changed the title [WIP]Add e2e test case for SecondaryNetwork of SR-IOV type Add e2e test case for SecondaryNetwork of SR-IOV type Jan 20, 2025
@wenqiq wenqiq marked this pull request as ready for review January 21, 2025 00:59
@luolanzone luolanzone requested review from antoninbas and tnqn January 21, 2025 07:33
ci/aws/test-sr-iov-secondary-network-aws.sh Outdated Show resolved Hide resolved
ci/aws/test-sr-iov-secondary-network-aws.sh Outdated Show resolved Hide resolved
ci/aws/test-sr-iov-secondary-network-aws.sh Outdated Show resolved Hide resolved
sudo systemctl restart containerd
sudo systemctl enable containerd

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this v1.32 be a parameter of the script? then we can use the latest K8s if we need in the future through the Jenkins job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

sudo apt install -y docker.io
sudo docker --version

sudo apt-get update
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would fail during install the tools.

ci/aws/test-sr-iov-secondary-network-aws.sh Outdated Show resolved Hide resolved
ci/aws/test-sr-iov-secondary-network-aws.sh Outdated Show resolved Hide resolved
ci/jenkins/jobs/projects-cloud.yaml Show resolved Hide resolved
Comment on lines 101 to 103
- cidr: "172.31.22.0/24"
subnetInfo:
gateway: "172.31.16.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these IPs from? or it's totally a private CIDR which can be defined by us without any limitation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

test/e2e/framework.go Outdated Show resolved Hide resolved
ci/aws/assign_ip_to_instance_networkinterface.sh Outdated Show resolved Hide resolved
ci/aws/assign_ip_to_instance_networkinterface.sh Outdated Show resolved Hide resolved
ci/aws/test-sriov-secondary-network-aws.sh Outdated Show resolved Hide resolved
ci/aws/assign_ip_to_instance_networkinterface.sh Outdated Show resolved Hide resolved
Comment on lines +115 to +110
resNum = sriovResNum
if pod.isSRIOV {
resNum = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused, it seems resNum is set to the number specific to SRIOV in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the testSecondaryNetwork test case it should set to 3 (sriovResNum = 3), and it is 1 in this test case:

apiVersion: v1
kind: Pod
metadata:
 name: sample-pod-1
 labels:
   app: sample-pod-1
 annotations:
   k8s.v1.cni.cncf.io/networks: sriov-net1
spec:
 containers:
 - name: toolbox
   image: antrea/toolbox:latest
   resources:
      requests:
        intel.com/intel_sriov_netdevice: '1'
      limits:
        intel.com/intel_sriov_netdevice: '1'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may make sense at this point to just remove the existing TestSriovNetwork (which was meant for baremetal) since we never run it, in order to avoid confusion. cc @jianjuns

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine to remove the baremetal test.

test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
Comment on lines 422 to 432
t.Run("testCreateTestPodOnNode", func(t *testing.T) {
err := testData.createPods(t, e2eTestData.GetTestNamespace())
assert.NoError(t, err)
})
t.Run("testAssignPodIP", func(t *testing.T) {
err := testData.assignIP()
if err != nil {
t.Fatalf("Error when assign IP to ec2 instance: %v", err)
}
})
t.Run("testpingBetweenInterfaces", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are 3 steps of a single test, shouldn't be 3 tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. I saw the testSecondaryNetwork function use two tests and updated them.

@wenqiq wenqiq force-pushed the add-sriov-e2e branch 2 times, most recently from aea2610 to 62000e7 Compare January 27, 2025 08:04
ci/aws/test-sriov-secondary-network-aws.sh Outdated Show resolved Hide resolved
ci/aws/test-sriov-secondary-network-aws.sh Outdated Show resolved Hide resolved
install_kubernetes() {
local node_ip=$1
echo "Installing Kubernetes on node $node_ip..."
ssh -o StrictHostKeyChecking=no -i "$AWS_EC2_SSH_KEY_NAME" ubuntu@$node_ip << EOF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be realistic to use the Ansible playbook we already have (over SSH) instead of having that long list of commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that integrating Ansible involves significant changes and requires considerable effort. Given the scope of these modifications, it would be more efficient to implement them in a separate pull request (PR).

ci/aws/test-sriov-secondary-network-aws.sh Outdated Show resolved Hide resolved
ci/aws/test-sriov-secondary-network-aws.sh Outdated Show resolved Hide resolved
Comment on lines +115 to +110
resNum = sriovResNum
if pod.isSRIOV {
resNum = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may make sense at this point to just remove the existing TestSriovNetwork (which was meant for baremetal) since we never run it, in order to avoid confusion. cc @jianjuns

test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e/framework.go Show resolved Hide resolved
return out.String(), nil
}

func (data *testData) assignIP() error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good if we could find a way to "isolate" the AWS-specific stuff in a single function and have the test script provide an "aws" flag when running the tests.

The function can iterate over the Pods, retrieve the Node, lookup the eni label and perform the IP assignment, all in one place. We don't need to build the mapping from Pod to eni ahead of time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

}

// createNetworkAttachmentDefinition creates a NetworkAttachmentDefinition in the specified namespace.
func createNetworkAttachmentDefinition(client networkclient.Interface, namespace, name, config string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we let the script create the NetworkAttachmentDefinition with kubectl, like we do in ci/kind/test-secondary-network-kind.sh. This is also how we create the IPPool. I don't see anything "dynamic" here so I am not sure why we are doing it programmatically?

We should probably follow the existing model and create it in the default namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the Namespace where the test Pod is located is randomly generated, the NetworkAttachmentDefinition needs to be in the same Namespace. Otherwise, it won`t work.

go.mod Outdated Show resolved Hide resolved
Signed-off-by: Wenqi Qiu <[email protected]>
Signed-off-by: Wenqi Qiu <[email protected]>
Signed-off-by: Wenqi Qiu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/secondary-network Issues or PRs related to support for secondary networks in Antrea
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants