-
Notifications
You must be signed in to change notification settings - Fork 29
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-nftables-test-cases #366
base: main
Are you sure you want to change the base?
Conversation
19b87aa
to
6bbb0c1
Compare
@@ -38,6 +38,7 @@ type NetworkConfig struct { | |||
//nolint:lll | |||
PrometheusOperatorNamespace string `yaml:"prometheus_operator_namespace" envconfig:"ECO_CNF_CORE_NET_PROMETHEUS_OPERATOR_NAMESPACE"` | |||
MlbAddressPoolIP string `envconfig:"ECO_CNF_CORE_NET_MLB_ADDR_LIST"` | |||
SecurityIPAddList string `envconfig:"ECO_CNF_CORE_NET_SECURITY_ADDR_LIST"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it? Is MlbAddressPoolIP not good for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use it. Its the same addresses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
// delete table inet custom_table | ||
// table inet custom_table { | ||
// }` | ||
CustomFireWallDelete = `data:;base64, ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomFireWallDelete = `data:;base64, ` + | |
CustomFirewallDelete = `data:;base64, ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
// ReporterCRDsToDump tells to the reporter what CRs to dump. | ||
ReporterCRDsToDump = []k8sreporter.CRData{} | ||
// ExternalMacVlanNADName represents default external NetworkAttachmentDefinition name. | ||
ExternalMacVlanNADName = "external" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls move it to the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
apimachinerytype "k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move all var under describe or to the tsparams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
masterPodIPv4Prefix = "172.16.0.1/24" | ||
masterPodIPv4Address = "172.16.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
masterPodIPv4Prefix = "172.16.0.1/24" | |
masterPodIPv4Address = "172.16.0.1" | |
masterPodIPv4Address = "172.16.0.1" | |
masterPodIPv4WithPrefix = masterPodIPv4Address + "/24" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
return testPod | ||
} | ||
|
||
func validateTCPTraffic(clientPod *pod.Builder, destIPAddrs []string, interfaceName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need return an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to leave the error message. There are tests that I am expecting an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the func to metallb.internal.cmd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it to network.internal.cmd
stringgzip := "gzip" | ||
|
||
mode := 384 | ||
fileContents := fileContentString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is the base64 string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does it mean?
you can use it
Source: &fileContentString,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using mc WithRawConfig to create and delete the machineConfig. This is using IgnitionConfig. So I am using the fileContents and not directly adding to Source:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don'y understand. This is work for me:
https://github.com/openshift-kni/eco-gotests/pull/378/files#diff-22e4ee6efd525f4fd9fbbfbc89a65635f4039a762ef79e6181e6063bbccd3712R550
Yes I already made the change. Not sure why it didnt show after I pushed. I see it now
Create() | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create nftables machine config") | ||
|
||
err = WaitForMcpStable(APIClient, 4*time.Minute, 30*time.Second, "workercnf") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"workercnf" should be a var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
Create() | ||
Expect(err).ToNot(HaveOccurred(), "Failed to create nftables machine config") | ||
|
||
err = WaitForMcpStable(APIClient, 4*time.Minute, 30*time.Second, "workercnf") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please increase the timers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
increased
} | ||
|
||
// WaitForMcpStable waits for the stability of the MCP with the given name. | ||
func WaitForMcpStable(apiClient *clients.Settings, waitingTime, stableDuration time.Duration, mcpName string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure we have the same func somewhere, please reuse it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found it
b336a5a
to
e306cc0
Compare
// This yaml is created using butane file. | ||
// butane mc-update-input-rule8888.bu -o mc-custom-firewall-input-port8888.yaml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
` | ||
|
||
// FRRDefaultBGPPreConfig represents FRR daemon BGP minimal config. | ||
FRRDefaultBGPPreConfig = ` bgp router-id 10.10.10.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
`GRXpH7IcoJX2/I3Z6/a57e/Xffuy2Gze0C2WD+2AVf/U3WGGVEW9O/uz/w0AAP//` + | ||
`kU0CJQUBAAA=` | ||
// FRRBaseConfig represents FRR daemon minimal configuration. | ||
FRRBaseConfig = `! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find where it is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct removed
ipv4SecurityIPList []string, | ||
hubIPv4ExternalAddresses []string, | ||
ipv4NodeAddrList []string, | ||
hubPodWorkerName []string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need.
_ = createFrrPodTest("hub-pod-worker-0", workerNodeList[0].Object.Name, hubConfigMap.Definition.Name, containerFrrName, []string{}, hub0BRstaticIPAnnotation, false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
"Failed to update the machineconfiguration cluster file") | ||
} | ||
|
||
func createExternalNad(name string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the same func in common
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used existing define.CreateNadWithMasterPlugin func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still here
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
return ipAddressListWithoutPrefix | ||
} | ||
|
||
func buildRoutesMapWithSpecificRoutes(podList []*pod.Builder, workerNodeList []*nodes.Builder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reuse from frrk8-tests.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here again. I will give you a call and we can discuss where to place it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to network.internal.frrconfig
return routesMap | ||
} | ||
|
||
func setStaticRoute(frrPod *pod.Builder, action, destIP string, nextHopMap map[string]string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reuse frr.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to network.internal.frrconfig
return testPod | ||
} | ||
|
||
func validateTCPTraffic(clientPod *pod.Builder, destIPAddrs []string, interfaceName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the func to metallb.internal.cmd
stringgzip := "gzip" | ||
|
||
mode := 384 | ||
fileContents := fileContentString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does it mean?
you can use it
Source: &fileContentString,
Expect(err).ToNot(HaveOccurred(), "Failed to wait for MCP to be stable") | ||
} | ||
|
||
func createStaticRouteOnWorkerNodes(testPodList []*pod.Builder, routeMap map[string]string, routeAction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename the func, it's not only create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed name
ee3ba43
to
5ffcef2
Compare
@@ -160,3 +176,12 @@ func getNumberOfPackets(line, firstFieldSubstr string) int { | |||
|
|||
return numberOfPackets | |||
} | |||
|
|||
func removePrefixFromIPList(ipAddressList []string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please reuse func from metallb common: move it and use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already moved it to network.internal.frrconfig
} | ||
|
||
if len(nextHopList) == 0 { | ||
glog.Error("Nexthop IP addresses list is empty") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use glog.V(90).Infof instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
} | ||
|
||
// BuildRoutesMapWithSpecificRoutes creates a route map with specific routes. | ||
func BuildRoutesMapWithSpecificRoutes(podList []*pod.Builder, workerNodeList []*nodes.Builder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BuildRoutesMapWithSpecificRoutes and SetStaticRoute are not related to frr. Please move them to cmd.go or netenv.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to netenv
} | ||
|
||
// RemovePrefixFromIPList removes the prefix from an IP address. | ||
func RemovePrefixFromIPList(ipAddressList []string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to frr func. And you already added it to cmd.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed from frrconfig
|
||
// ReporterNamespacesToDump tells to the reporter from where to collect logs. | ||
ReporterNamespacesToDump = map[string]string{ | ||
"openshift-performance-addon-operator": "performance", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to dump openshift-performance-addon-operator ns? Please add ns that you're using in the test suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct removed and changed to security-tests
err error | ||
) | ||
BeforeAll(func() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls remove line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
It("Verify the creation of a new custom node firewall NFTables table with an ingress rule", | ||
reportxml.ID("77412"), func() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls remove line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
"Failed to update the machineconfiguration cluster file") | ||
} | ||
|
||
func createExternalNad(name string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still here
fixed
masterConfigMap.Definition.Name, containerFrrName, []string{}, masterStaticIPAnnotation, true) | ||
} | ||
|
||
func createStaticIPAnnotations(internalNADName, externalNADName string, internalIPAddresses, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still here
In my code its changed. Try refreshing and look again?
stringgzip := "gzip" | ||
|
||
mode := 384 | ||
fileContents := fileContentString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don'y understand. This is work for me:
https://github.com/openshift-kni/eco-gotests/pull/378/files#diff-22e4ee6efd525f4fd9fbbfbc89a65635f4039a762ef79e6181e6063bbccd3712R550
Yes I already made the change. Not sure why it didnt show after I pushed. I see it now
a4ab1e0
to
602b55a
Compare
|
||
// CreateExternalNad creats an external network-attchment-definition using the br-ex interface. | ||
func CreateExternalNad(apiClient *clients.Settings, name, testNameSpace string) { | ||
glog.V(2).Info("Creating external BR-EX NetworkAttachmentDefinition") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glog.V(2).Info("Creating external BR-EX NetworkAttachmentDefinition") | |
glog.V(90).Info("Creating external BR-EX NetworkAttachmentDefinition") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
return | ||
} | ||
|
||
// Create the NetworkAttachmentDefinition | ||
_, err = define.CreateNadWithMasterPlugin(apiClient, name, testNameSpace, macVlanPlugin) | ||
if err != nil { | ||
glog.V(90).Infof("Failed to create external NetworkAttachmentDefinition: %v", err) | ||
|
||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please return the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please return err
return | ||
} | ||
|
||
glog.V(2).Infof("Successfully created external NetworkAttachmentDefinition: %s", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glog.V(2).Infof("Successfully created external NetworkAttachmentDefinition: %s", name) | |
glog.V(90).Infof("Successfully created external NetworkAttachmentDefinition: %s", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
} | ||
|
||
// WaitForMcpStable waits for the stability of the MCP with the given name. | ||
func WaitForMcpStable(apiClient *clients.Settings, waitingTime, stableDuration time.Duration, mcpName string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add glog.V(90).Infof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -628,14 +643,17 @@ var _ = Describe("FRR", Ordered, Label(tsparams.LabelFRRTestCases), ContinueOnFa | |||
srIovInterfacesUnderTest[0], frrNodeSecIntIPv4Addresses[1], "2001:100::253", vlanID) | |||
|
|||
By("Adding static routes to the speakers") | |||
speakerRoutesMap := buildRoutesMapWithSpecificRoutes(frrk8sPods, hubSecIntIPv4Addresses) | |||
// speakerRoutesMap := buildRoutesMapWithSpecificRoutes(frrk8sPods, hubSecIntIPv4Addresses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
// ReporterNamespacesToDump tells to the reporter from where to collect logs. | ||
ReporterNamespacesToDump = map[string]string{ | ||
"security-tests": "security-tests", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use TestNamespaceName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
masterConfigMap.Definition.Name, containerFrrName, []string{}, masterStaticIPAnnotation, true) | ||
} | ||
|
||
func createStaticIPAnnotations(internalNADName, externalNADName string, internalIPAddresses, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still can see it
602b55a
to
471b138
Compare
return | ||
} | ||
|
||
// Create the NetworkAttachmentDefinition | ||
_, err = define.CreateNadWithMasterPlugin(apiClient, name, testNameSpace, macVlanPlugin) | ||
if err != nil { | ||
glog.V(90).Infof("Failed to create external NetworkAttachmentDefinition: %v", err) | ||
|
||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please return err
err = mcp.WaitToBeStableFor(stableDuration, waitingTime) | ||
|
||
if err != nil { | ||
glog.V(90).Infof("Failed to create external NetworkAttachmentDefinition: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
func WaitForMcpStable(apiClient *clients.Settings, waitingTime, stableDuration time.Duration, mcpName string) error { | ||
mcp, err := mco.Pull(apiClient, mcpName) | ||
|
||
glog.V(90).Info("Waiting for mcp to be stable after adding or deleting a machine-Config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glog.V(90).Info("Waiting for mcp to be stable after adding or deleting a machine-Config") | |
glog.V(90).Info("Waiting for mcp to be stable") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
// TestNamespaceName security-tests namespace where all test cases are performed. | ||
TestNamespaceName = "security-tests" | ||
// ReporterCRDsToDump tells to the reporter what CRs to dump. | ||
ReporterCRDsToDump = []k8sreporter.CRData{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add CRs what you want to dump after the failure. machineconfigs or something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know when you are free for a call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
471b138
to
3686479
Compare
3686479
to
36d1201
Compare
Add first of two PRs cnf network nftables custom firewall test cases