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

cnf-network: add multi-netpolicy tests for ipvlan cni #345

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

ajaggapa
Copy link
Collaborator

multinetpolicy_ipvlan.go Multi-NetworkPolicy IPVLAN CNI Tests

By("Enable MultiNetworkPolicy support")
enableMultiNetworkPolicy(true)

By("Deploy Test Resources: 2 Namespaces")
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO rather then the number 2 use two.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok. Updated.

WithLabel("ns", "ns2").Create()
Expect(err).ToNot(HaveOccurred(), "Failed to create test namespace")

By("Deploy Test Resources: 2 NADs for IPVLAN CNI")
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here By("Deploy Test Resources: two NADs for IPVLAN CNI"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

defineAndCreateIpvlanNAD("ipvlan", testNs1, sriovInterfacesUnderTest[0])
defineAndCreateIpvlanNAD("ipvlan", testNs2, sriovInterfacesUnderTest[1])

By("Deploy Test Resources: 5 Pods")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is generally best to write out numbers from zero to 10 in technical writing. So that goes for where ever you used numbers rather then writing them out. Up to you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, Updated accordingly.

Copy link
Collaborator

@evgenLevin evgenLevin left a comment

Choose a reason for hiding this comment

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

several minor comments


const (
testNs1, testNs2 = "policy-ns1", "policy-ns2"
pod1, pod2, pod3, pod4, pod5 = "pod1", "pod2", "pod3", "pod4", "pod5"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can see only one time use. If it's true remove var, if not please rename var to podname1


By("Check ingress traffic to pod1 from other four pods. All ports should be open")

verifyPaths(testPod2, testPod1, allOpen, allOpen, testData)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you move all common func to the internal folder or create a common.go (check the metallb implementation)?

Comment on lines 28 to 51
var (
sriovInterfacesUnderTest []string
tNs1, tNs2 *namespace.Builder
testPod1, testPod2, testPod3, testPod4, testPod5 *pod.Builder
ports = []string{"5001", "5002", "5003"}
protocols = []string{"tcp", "tcp", "udp"}
allOpen = map[string]string{"5001": "pass", "5002": "pass", "5003": "pass"}
allClose = map[string]string{"5001": "fail", "5002": "fail", "5003": "fail"}
p5001Open = map[string]string{"5001": "pass", "5002": "fail", "5003": "fail"}
p5001p5002Open = map[string]string{"5001": "pass", "5002": "pass", "5003": "fail"}
)

const (
testNs1, testNs2 = "policy-ns1", "policy-ns2"
pod1, pod2, pod3, pod4, pod5 = "pod1", "pod2", "pod3", "pod4", "pod5"
)

testData := podsData{
"pod1": {IPv4: "192.168.10.10/24", IPv6: "2001:0:0:1::10/64", Protocols: protocols, Ports: ports},
"pod2": {IPv4: "192.168.10.11/24", IPv6: "2001:0:0:1::11/64", Protocols: protocols, Ports: ports},
"pod3": {IPv4: "192.168.10.12/24", IPv6: "2001:0:0:1::12/64", Protocols: protocols, Ports: ports},
"pod4": {IPv4: "192.168.20.11/24", IPv6: "2001:0:0:2::11/64", Protocols: protocols, Ports: ports},
"pod5": {IPv4: "192.168.20.12/24", IPv6: "2001:0:0:2::12/64", Protocols: protocols, Ports: ports},
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like you used very similar var and const in the bond tests. If so, could you move them to the internal folder?

Comment on lines 80 to 81
defineAndCreateIpvlanNAD("ipvlan", testNs1, sriovInterfacesUnderTest[0])
defineAndCreateIpvlanNAD("ipvlan", testNs2, sriovInterfacesUnderTest[1])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
defineAndCreateIpvlanNAD("ipvlan", testNs1, sriovInterfacesUnderTest[0])
defineAndCreateIpvlanNAD("ipvlan", testNs2, sriovInterfacesUnderTest[1])
defineAndCreateIpvlanNAD(testNs1, sriovInterfacesUnderTest[0])
defineAndCreateIpvlanNAD(testNs2, sriovInterfacesUnderTest[1])

defineAndCreateIpvlanNAD("ipvlan", testNs2, sriovInterfacesUnderTest[1])

By("Deploy Test Resources: Five Pods")
testPod1 = defineAndCreatePodWithIpvlanIf(pod1, testNs1, workerNodeList[0].Object.Name, testData)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
testPod1 = defineAndCreatePodWithIpvlanIf(pod1, testNs1, workerNodeList[0].Object.Name, testData)
testPod1 = defineAndCreatePodWithIpvlanIf(pod1, testNs1, testData)

Copy link
Collaborator

@evgenLevin evgenLevin left a comment

Choose a reason for hiding this comment

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

1 minor comment.

Comment on lines 52 to 57
// AllClose represents that all what ports are expected to be open for policy tests.
AllClose = map[string]string{"5001": "fail", "5002": "fail", "5003": "fail"}
// P5001Open represents that all what ports are expected to be open for policy tests.
P5001Open = map[string]string{"5001": "pass", "5002": "fail", "5003": "fail"}
// P5001p5002Open represents that all what ports are expected to be open for policy tests.
P5001p5002Open = map[string]string{"5001": "pass", "5002": "pass", "5003": "fail"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fix the comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@evgenLevin evgenLevin left a comment

Choose a reason for hiding this comment

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

LGTM

@ajaggapa ajaggapa merged commit 389b893 into openshift-kni:main Dec 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants