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 ffrk8 metallb test cases #213

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

gkopels
Copy link
Collaborator

@gkopels gkopels commented Sep 21, 2024

Add 7 of the 9 test cases for epic metallb-frrk8

@gkopels gkopels changed the title bump-eco-infra-frrk8 cnf network: add ffrk8 metallb test cases Sep 22, 2024
@gkopels gkopels force-pushed the add-metallb-frrk8-test-cases branch 6 times, most recently from 5d53f97 to 4424d8b Compare September 22, 2024 14:49
@@ -91,6 +135,51 @@ func DefineBGPConfig(localBGPASN, remoteBGPASN int, neighborsIPAddresses []strin
return bgpConfig
}

// DefineBGPConfigWitgStaticRoutes returns string which represents BGP config file peering to all given IP addresses.
func DefineBGPConfigWitgStaticRoutes(localBGPASN, remoteBGPASN int, neighborsIPAddresses []string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo. With

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 528 to 532
for _, pod := range podList {
if pod.Definition.Spec.NodeName == "worker-0" {
routesMap[pod.Definition.Spec.NodeName] = nextHopList[1]
} else {
routesMap[pod.Definition.Spec.NodeName] = nextHopList[0]
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this loop need coverage for 3 worker cluster ?
I assume this covers when frr pods are only on worker-0 and worker-1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I returned the func to its orginal form and created a new one for frrk8 test cases. There I only will use two worker nodes each with one hub pod. Because of security policies it is not possible on the same two communicate between two pods on the same IP address range. So the static routes need to be crossed between the two workers.

func createExternalNad() {
func createHubConfigMap(name string) *configmap.Builder {
frrBFDConfig := frr.DefineBGPConfig(
64500, tsparams.LocalBGPASN, []string{"10.10.0.10"}, false, false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use constant for 64500 LocalBGPASN

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

@@ -91,6 +135,51 @@ func DefineBGPConfig(localBGPASN, remoteBGPASN int, neighborsIPAddresses []strin
return bgpConfig
}

// DefineBGPConfigWitgStaticRoutes returns string which represents BGP config file peering to all given IP addresses.
Copy link
Collaborator

Choose a reason for hiding this comment

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

wrong comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Change name and description DefineBGPConfigWithStaticRouteAndNetwork

// DefineBGPConfigWitgStaticRoutes returns string which represents BGP config file peering to all given IP addresses.
func DefineBGPConfigWitgStaticRoutes(localBGPASN, remoteBGPASN int, neighborsIPAddresses []string,
multiHop, bfd bool) string {
bgpConfig := tsparams.FRRBaseConfig + fmt.Sprintf("ip route %s/32 172.16.0.10\n", neighborsIPAddresses[1]) +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where did you get 172.16.0.10 and 172.16.0.11. Make it as a func atribute or general parameter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added as func attribute

}

// VerifyBGPReceivedRoutes verifies routes were received via BGP.
func VerifyBGPReceivedRoutes(frrk8sPods []*pod.Builder) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Incorrect name, this function does more than just verify the routes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its only verifying the routes received on the frr nodes.

return allRoutes.String(), nil
}

func parseBGPAdvertisedRoutes(jsonData string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move all func to the enf of the file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved

}

// Store the result for the current nodeIP
allRoutes.WriteString(fmt.Sprintf("Node IP: %s\n", nodeIP))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are you working with string not with maps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to maps

Copy link
Collaborator

Choose a reason for hiding this comment

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

nothing changed


By("Checking that BGP session is established and up")
verifyMetalLbBGPSessionsAreUPOnFrrPod(frrPod, removePrefixFromIPList(ipv4NodeAddrList))
time.Sleep(30 * time.Second)
Copy link
Collaborator

Choose a reason for hiding this comment

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

?
Use Eventually if needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


for _, frrk8sPod := range frrk8sPods {
out, err := frr.SetStaticRoute(frrk8sPod, "del", "172.16.0.1", speakerRoutesMap)
fmt.Println("OUT", out)
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


func createNewMetalLbDaemonSetAndWaitUntilItsRunningWithAlwaysBlock(timeout time.Duration,
nodeLabel map[string]string, prefixes []string) error {
glog.V(90).Infof("Verifying if metalLb daemonset is running")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use BY instead of glog

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

frrPod := createFrrPod(
masterNodeList[0].Object.Name, masterConfigMap.Definition.Name, []string{}, staticIPAnnotation)

Eventually(func() error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

}

func deployTestPods(addressPool []string) *pod.Builder {
var err error
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

@gkopels gkopels force-pushed the add-metallb-frrk8-test-cases branch 5 times, most recently from 54ed23f to 6c10dc8 Compare September 24, 2024 12:36
}

// Store the result for the current nodeIP
allRoutes.WriteString(fmt.Sprintf("Node IP: %s\n", nodeIP))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nothing changed

@evgenLevin
Copy link
Collaborator

evgenLevin commented Sep 24, 2024

Please rebase

Rebased.

@gkopels gkopels force-pushed the add-metallb-frrk8-test-cases branch 2 times, most recently from 7214d2c to 2dd2db7 Compare September 25, 2024 05:48
Comment on lines 132 to 142
}, 60*time.Second, 5*time.Second).Should(ContainSubstring(externalAdvertisedIPv4Routes[1]),
"Fail to find received routes")
})
Copy link
Member

Choose a reason for hiding this comment

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

iiuc this checks that the 2nd prefix is there, but does not validate that it is the only one (i.e that the 1st prefix is actually blocked), I think this should validate that the routes is exactly the 1st prefix (or at least that it does not contain the first prefix)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added verifiying that the blocked route is not received

@@ -9,8 +9,13 @@ const (
LabelBGPTestCases = "bgp"
// LabelLayer2TestCases represents layer2 label that can be used for test cases selection.
LabelLayer2TestCases = "layer2"
// LabelFRRTestCases represents frrk8 label that can be used for test cases selection.
LabelFRRTestCases = "frrk8"
Copy link
Member

Choose a reason for hiding this comment

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

nit: frrk8 -> frrk8s

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

tests/cnf/core/network/metallb/tests/frrk8-tests.go Outdated Show resolved Hide resolved

By("Create a frrconfiguration with prefix filter")
err := createFrrConfiguration("frrconfig-filtered", ipv4metalLbIPList[0],
64500, []string{externalAdvertisedIPv4Routes[0], externalAdvertisedIPv6Routes[0]}, false)
Copy link
Member

Choose a reason for hiding this comment

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

same, declare a filteredIPs var to make this more readable and reuse later.
also, the IPv6 prefix is not verified later, is that on purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added.
Currently we are having issues deploying IPv6 in our lab. We will add the IPv6 when it is possible to test.

if metalLbDs.IsReady(timeout) {
return nil
}

Copy link
Member

Choose a reason for hiding this comment

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

wdyt about also verifying that the frr-k8s daemonset is ready?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added

), "Fail to find all expected received routes")
})

It("Verify that a FRR speaker rejects a contrasting FRRConfiguration merge",
Copy link
Member

Choose a reason for hiding this comment

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

wdyt about keeping only the part about the conflicting configs? seems the metallb / peering part is redundant when all you want to check is that it handles conflicting configs properly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree. Removed the peering.


By("Creating a new instance of MetalLB Speakers on workers blocking specific incoming prefixes")
err := createNewMetalLbDaemonSetAndWaitUntilItsRunningWithAlwaysBlock(tsparams.DefaultTimeout,
workerLabelMap, []string{externalAdvertisedIPv4Routes[0]})
Copy link
Collaborator

Choose a reason for hiding this comment

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

use prefixToBlock

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

})
Expect(err).ToNot(HaveOccurred(), "Fail to list speaker pods")

By("Collecting information before test")
Copy link
Collaborator

Choose a reason for hiding this comment

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

??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


By("Collecting information before test")

Expect(err).ToNot(HaveOccurred(), "Failed to list speaker pods")
Copy link
Collaborator

Choose a reason for hiding this comment

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

??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

}
}

glog.V(90).Infof("Create new metalLb speaker's daemonSet.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

change to By

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

return err
}

glog.V(90).Infof("Waiting until the new metalLb daemonset is in Ready state.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

change to By

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

_, err := frrConfig.Create()

if err != nil {
glog.V(90).Infof("failed to create a frrconfiugration")
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed


})

func createNewMetalLbDaemonSetAndWaitUntilItsRunningWithAlwaysBlock(timeout time.Duration,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Valdate all errors inside the local func via Expect()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed

return masterConfigMap
}

func verifyExternalAdvertisedRoutes(frrPod *pod.Builder, ipv4NodeAddrList, externalExpectedRoutes []string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Valdate all errors inside the local func via Expect()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

Expect(err).ToNot(HaveOccurred(), "Failed to clean test namespace")
}

func buildRoutesMapWithSpecificRoutes(podList []*pod.Builder, nextHopList []string) (map[string]string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Valdate all errors inside the local func via Expect()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

tests/cnf/core/network/metallb/tests/frrk8-tests.go Outdated Show resolved Hide resolved
context.TODO(), 3*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
metalLbDs, err = daemonset.Pull(APIClient, tsparams.MetalLbDsName, NetConfig.MlbOperatorNamespace)
if err != nil {
glog.V(90).Infof("Error pulling speakers in %s namespace %s, retry",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use By""

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed


metalLbDs, err = daemonset.Pull(APIClient, tsparams.FrrDsName, NetConfig.MlbOperatorNamespace)
if err != nil {
glog.V(90).Infof("Error pulling frrk8s in %s namespace %s, retry",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use By""

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

WithPort(179, 0, 0)

_, err := frrConfig.Create()
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Valdate all errors inside the local func via Expect()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

routesMap := make(map[string]string)

for _, frrPod := range podList {
if frrPod.Definition.Spec.NodeName == "worker-0" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't hardcode the worker name. Please pull the workers and use the first wotker name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

@gkopels gkopels force-pushed the add-metallb-frrk8-test-cases branch 4 times, most recently from 175e6ba to 42462ea Compare September 30, 2024 14:57
return routesMap
}

func verifyFrrWebHookServerRunning() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of this function. try to use something like:

			By("Waiting until the new frr-k8s-webhook-server deployment is in Ready state.")
			frrk8sWebhookDeployment, err := deployment.Pull(
				APIClient, "frr-k8s-webhook-server", NetConfig.MlbOperatorNamespace)
			Expect(frrk8sWebhookDeployment.IsReady(30 * time.Second)).To(BeTrue(), "frr-k8s-webhook-server deployment is not ready")

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

Copy link
Collaborator

@ajaggapa ajaggapa 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 0a354a6 into openshift-kni:main Oct 1, 2024
1 check passed
josclark42 pushed a commit to josclark42/eco-gotests that referenced this pull request Oct 3, 2024
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.

4 participants