-
Notifications
You must be signed in to change notification settings - Fork 28
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
cnf network: add ffrk8 metallb test cases #213
Conversation
5d53f97
to
4424d8b
Compare
@@ -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, |
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.
Typo. With
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.
fixed
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] | ||
} | ||
} | ||
|
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.
Does this loop need coverage for 3 worker cluster ?
I assume this covers when frr pods are only on worker-0 and worker-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.
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) |
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.
Use constant for 64500 LocalBGPASN
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.
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. |
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 comment
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.
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]) + |
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 did you get 172.16.0.10 and 172.16.0.11. Make it as a func atribute or general parameter
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 as func attribute
} | ||
|
||
// VerifyBGPReceivedRoutes verifies routes were received via BGP. | ||
func VerifyBGPReceivedRoutes(frrk8sPods []*pod.Builder) (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.
Incorrect name, this function does more than just verify the routes.
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.
Its only verifying the routes received on the frr nodes.
return allRoutes.String(), nil | ||
} | ||
|
||
func parseBGPAdvertisedRoutes(jsonData string) (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 move all func to the enf of the file
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
} | ||
|
||
// Store the result for the current nodeIP | ||
allRoutes.WriteString(fmt.Sprintf("Node IP: %s\n", nodeIP)) |
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 are you working with string not with maps?
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 to maps
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.
nothing changed
|
||
By("Checking that BGP session is established and up") | ||
verifyMetalLbBGPSessionsAreUPOnFrrPod(frrPod, removePrefixFromIPList(ipv4NodeAddrList)) | ||
time.Sleep(30 * time.Second) |
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.
?
Use Eventually if needed
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
|
||
for _, frrk8sPod := range frrk8sPods { | ||
out, err := frr.SetStaticRoute(frrk8sPod, "del", "172.16.0.1", speakerRoutesMap) | ||
fmt.Println("OUT", out) |
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
|
||
func createNewMetalLbDaemonSetAndWaitUntilItsRunningWithAlwaysBlock(timeout time.Duration, | ||
nodeLabel map[string]string, prefixes []string) error { | ||
glog.V(90).Infof("Verifying if metalLb daemonset is running") |
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.
Use BY instead of glog
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
frrPod := createFrrPod( | ||
masterNodeList[0].Object.Name, masterConfigMap.Definition.Name, []string{}, staticIPAnnotation) | ||
|
||
Eventually(func() 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.
??
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
} | ||
|
||
func deployTestPods(addressPool []string) *pod.Builder { | ||
var err 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.
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
54ed23f
to
6c10dc8
Compare
} | ||
|
||
// Store the result for the current nodeIP | ||
allRoutes.WriteString(fmt.Sprintf("Node IP: %s\n", nodeIP)) |
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.
nothing changed
Please rebase Rebased. |
7214d2c
to
2dd2db7
Compare
}, 60*time.Second, 5*time.Second).Should(ContainSubstring(externalAdvertisedIPv4Routes[1]), | ||
"Fail to find received routes") | ||
}) |
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.
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)?
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 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" |
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.
nit: frrk8
-> frrk8s
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
|
||
By("Create a frrconfiguration with prefix filter") | ||
err := createFrrConfiguration("frrconfig-filtered", ipv4metalLbIPList[0], | ||
64500, []string{externalAdvertisedIPv4Routes[0], externalAdvertisedIPv6Routes[0]}, 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.
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?
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.
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 | ||
} | ||
|
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.
wdyt about also verifying that the frr-k8s daemonset is ready?
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
), "Fail to find all expected received routes") | ||
}) | ||
|
||
It("Verify that a FRR speaker rejects a contrasting FRRConfiguration merge", |
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.
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
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 agree. Removed the peering.
2dd2db7
to
9933d86
Compare
|
||
By("Creating a new instance of MetalLB Speakers on workers blocking specific incoming prefixes") | ||
err := createNewMetalLbDaemonSetAndWaitUntilItsRunningWithAlwaysBlock(tsparams.DefaultTimeout, | ||
workerLabelMap, []string{externalAdvertisedIPv4Routes[0]}) |
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.
use prefixToBlock
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
}) | ||
Expect(err).ToNot(HaveOccurred(), "Fail to list speaker pods") | ||
|
||
By("Collecting information before test") |
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.
removed
|
||
By("Collecting information before test") | ||
|
||
Expect(err).ToNot(HaveOccurred(), "Failed to list speaker pods") |
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.
removed
} | ||
} | ||
|
||
glog.V(90).Infof("Create new metalLb speaker's daemonSet.") |
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.
change to By
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 err | ||
} | ||
|
||
glog.V(90).Infof("Waiting until the new metalLb daemonset is in Ready state.") |
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.
change to By
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
_, err := frrConfig.Create() | ||
|
||
if err != nil { | ||
glog.V(90).Infof("failed to create a frrconfiugration") |
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
|
||
}) | ||
|
||
func createNewMetalLbDaemonSetAndWaitUntilItsRunningWithAlwaysBlock(timeout time.Duration, |
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.
Valdate all errors inside the local func via Expect()
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 masterConfigMap | ||
} | ||
|
||
func verifyExternalAdvertisedRoutes(frrPod *pod.Builder, ipv4NodeAddrList, externalExpectedRoutes []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.
Valdate all errors inside the local func via Expect()
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
Expect(err).ToNot(HaveOccurred(), "Failed to clean test namespace") | ||
} | ||
|
||
func buildRoutesMapWithSpecificRoutes(podList []*pod.Builder, nextHopList []string) (map[string]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.
Valdate all errors inside the local func via Expect()
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
9933d86
to
f629208
Compare
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", |
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.
Use By""
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
|
||
metalLbDs, err = daemonset.Pull(APIClient, tsparams.FrrDsName, NetConfig.MlbOperatorNamespace) | ||
if err != nil { | ||
glog.V(90).Infof("Error pulling frrk8s in %s namespace %s, retry", |
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.
Use By""
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
WithPort(179, 0, 0) | ||
|
||
_, err := frrConfig.Create() | ||
if err != nil { |
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.
Valdate all errors inside the local func via Expect()
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
routesMap := make(map[string]string) | ||
|
||
for _, frrPod := range podList { | ||
if frrPod.Definition.Spec.NodeName == "worker-0" { |
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 don't hardcode the worker name. Please pull the workers and use the first wotker 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
175e6ba
to
42462ea
Compare
return routesMap | ||
} | ||
|
||
func verifyFrrWebHookServerRunning() { |
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.
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")
42462ea
to
e6de986
Compare
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.
/lgtm
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.
lgtm
Co-authored-by: Gregory Kopels <[email protected]>
Add 7 of the 9 test cases for epic metallb-frrk8