-
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
add-metallb-nodeselector-tc #347
base: main
Are you sure you want to change the base?
Conversation
c92959e
to
1019bfe
Compare
|
||
// ValidateLocalPref verifies local pref from FRR is equal to configured Local Pref. | ||
func ValidateLocalPref(frrPod *pod.Builder, localPref uint32, ipFamily string) error { | ||
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.
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
err error | ||
) | ||
|
||
res, err = frrPod.ExecCommand(append(netparam.VtySh, |
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 getBGPStatus 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.
added
return fmt.Errorf("failed to parse route local preference %w", err) | ||
} | ||
|
||
for _, locPref := range toParse.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.
for _, locPref := range toParse.Routes { | |
for _, route := range toParse.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.
changed
} | ||
|
||
for _, locPref := range toParse.Routes { | ||
if locPref[0].LocalPref != localPref { |
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.
do we expect to validate only first route?
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.
It only has one route
} | ||
} | ||
|
||
return 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.
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.
changed
Expect(err).ToNot(HaveOccurred(), "Fail to validate local preference") | ||
|
||
By("Validate BGP Community exists with the node selector") | ||
output, err := frr.GetBGPCommunityStatus(frrPod0, noAdvertise, strings.ToLower(netparam.IPV4Family)) |
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.
output, err := frr.GetBGPCommunityStatus(frrPod0, noAdvertise, strings.ToLower(netparam.IPV4Family)) | |
bgpStatus, err := frr.GetBGPCommunityStatus(frrPod0, noAdvertise, strings.ToLower(netparam.IPV4Family)) |
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
Expect(len(output.Routes)).To(Equal(1)) | ||
|
||
By("Validate BGP Community does not exist without the node selector") | ||
output, err = frr.GetBGPCommunityStatus(frrPod1, customCommunity, strings.ToLower(netparam.IPV4Family)) |
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.
output, err = frr.GetBGPCommunityStatus(frrPod1, customCommunity, strings.ToLower(netparam.IPV4Family)) | |
bgpStatus, err = frr.GetBGPCommunityStatus(frrPod1, customCommunity, strings.ToLower(netparam.IPV4Family)) |
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 := metallb.NewBPGPeerBuilder(APIClient, name, NetConfig.MlbOperatorNamespace, | ||
peerIP, tsparams.LocalBGPASN, tsparams.LocalBGPASN).WithPassword(tsparams.BGPPassword).Create() | ||
|
||
return 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.
validate error here
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.
validating
return ipAddressPool | ||
} | ||
|
||
func createBGPPeer(name, peerIP 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.
why don't use createBGPPeerAndVerifyIfItsReady?
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.
using
setupMetalLbService("service-1", netparam.IPV4Family, ipAddressPool1, "Cluster") | ||
setupMetalLbService("service-2", netparam.IPV4Family, ipAddressPool2, "Cluster") |
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.
is that expected that you create 2 the same services with different name in case single IP addressPool?
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 are two different ipaddresspools
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 talking about line 112
frrPod0, frrPod1 := setupTestCase(ipAddressPool, ipAddressPool, frrk8sPods)
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.
Yes there is two services on a single IPaddressPool in the original test case but lets talk to make sure I understand your question.
c225bdf
to
876bc6e
Compare
toParse, err := getBgpStatus(frrPod, fmt.Sprintf("show ip bgp %s json", ipFamily)) | ||
|
||
if err != nil { | ||
return fmt.Errorf("failed to parse route local preference %w", err) | ||
} | ||
|
||
for _, route := range toParse.Routes { | ||
if route[0].LocalPref != localPref { | ||
return fmt.Errorf("incorrect localPref: %d", localPref) | ||
} | ||
} | ||
|
||
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.
toParse, err := getBgpStatus(frrPod, fmt.Sprintf("show ip bgp %s json", ipFamily)) | |
if err != nil { | |
return fmt.Errorf("failed to parse route local preference %w", err) | |
} | |
for _, route := range toParse.Routes { | |
if route[0].LocalPref != localPref { | |
return fmt.Errorf("incorrect localPref: %d", localPref) | |
} | |
} | |
return nil | |
bgpStatus, err := getBgpStatus(frrPod, fmt.Sprintf("show ip bgp %s json", ipFamily)) | |
if err != nil { | |
return fmt.Errorf("failed to get BGP status %w", err) | |
} | |
for _, route := range bgpStatus.Routes { | |
if route[0].LocalPref != localPref { | |
return fmt.Errorf("incorrect localPref: %d", localPref) | |
} | |
} | |
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.
changed
|
||
for _, route := range toParse.Routes { | ||
if route[0].LocalPref != localPref { | ||
return fmt.Errorf("incorrect localPref: %d", localPref) |
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 what local pref we expected
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
frrk8sPods, err = pod.List(APIClient, NetConfig.MlbOperatorNamespace, metav1.ListOptions{ | ||
LabelSelector: frrNodeLabel, | ||
}) | ||
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.
Expect(err).ToNot(HaveOccurred(), "Failed to list speaker pods") | |
Expect(err).ToNot(HaveOccurred(), "Failed to list frrk8s 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.
updated
Context("Single IPAddressPool", func() { | ||
|
||
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
err = metallbenv.CreateNewMetalLbDaemonSetAndWaitUntilItsRunning(tsparams.DefaultTimeout, workerLabelMap) | ||
Expect(err).ToNot(HaveOccurred(), "Failed to recreate metalLb daemonset") | ||
|
||
waitForWebHookRunning() |
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.
waitForWebHookRunning() | |
waitForFRRK8SWebHookRunning() |
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.
After I moved to general afterall no longer needed as a separate func. Removed
Expect(len(output.Routes)).To(Equal(1)) | ||
|
||
By("Validate BGP Community does not exist without the node selector") | ||
output, err = frr.GetBGPCommunityStatus(frrPod1, tsparams.CustomCommunity, strings.ToLower(netparam.IPV4Family)) |
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.
bgpStatus
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 collect bgp community status") | ||
Expect(len(output.Routes)).To(Equal(1)) | ||
|
||
By("Validate BGP Community does not exist without the node selector") |
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.
How do we check that the comunity doesn't exist?
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 changed the description. We can add a negitive check as well. But not sure it is needed. We are just validating the the correct community has been added to the route.
setupMetalLbService("service-1", netparam.IPV4Family, ipAddressPool1, "Cluster") | ||
setupMetalLbService("service-2", netparam.IPV4Family, ipAddressPool2, "Cluster") |
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 talking about line 112
frrPod0, frrPod1 := setupTestCase(ipAddressPool, ipAddressPool, frrk8sPods)
// BGPTestPeer is the bgppeer name. | ||
BGPTestPeer = "testpeer" | ||
// FrrK8WebHookServer is the web hook server running in namespace metallb-system. | ||
FrrK8WebHookServer = "frr-k8s-webhook-server" |
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.
If you created the variable, please replace it everywhere it is 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.
replaced
By("Creating a new instance of MetalLB Speakers on workers") | ||
err = metallbenv.CreateNewMetalLbDaemonSetAndWaitUntilItsRunning(tsparams.DefaultTimeout, workerLabelMap) | ||
Expect(err).ToNot(HaveOccurred(), "Failed to recreate metalLb daemonset") | ||
|
||
waitForWebHookRunning() |
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 to wait specifically for the frrk8s webhook? If so, it should be a part of metallbenv.CreateNewMetalLbDaemonSetAndWaitUntilItsRunning()
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 remember from the frrk8 test cases that the webhook was the took longer to come up. For those test cases I didnt add it to CreateNewMetalLbDaemonSetAndWaitUntilItsRunning but can.
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.
The webhook is the last to come up. I added it to the CreateNewMetalLbDaemonSetAndWaitUntilItsRunning. Without the check it fails
90eb7ab
to
87b31d6
Compare
nodeAddrList []string | ||
addressPool []string | ||
frrk8sPods []*pod.Builder | ||
frrNodeLabel = "app=frr-k8s" |
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.
const?
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 const.
_, err = frr.GetBGPCommunityStatus(frrPod1, tsparams.CustomCommunity, | ||
strings.ToLower(netparam.IPV4Family)) | ||
Expect(err).ToNot(HaveOccurred(), "Failed to collect bgp community status") | ||
Expect(len(bgpStatus.Routes)).To(Equal(2)) |
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.
_, err = frr.GetBGPCommunityStatus(frrPod1, tsparams.CustomCommunity, | |
strings.ToLower(netparam.IPV4Family)) | |
Expect(err).ToNot(HaveOccurred(), "Failed to collect bgp community status") | |
Expect(len(bgpStatus.Routes)).To(Equal(2)) | |
bgpStatus, err = frr.GetBGPCommunityStatus(frrPod1, tsparams.CustomCommunity, | |
strings.ToLower(netparam.IPV4Family)) | |
Expect(err).ToNot(HaveOccurred(), "Failed to collect bgp community status") | |
Expect(len(bgpStatus.Routes)).To(Equal(2)) |
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 to change
ipAddressPool1 := createIPAddressPool(ipaddressPoolName1, addressPool) | ||
ipAddressPool2 := createIPAddressPool(ipaddressPoolName2, addressPool2) | ||
|
||
frrPod0, frrPod1 := setupTestCase(ipAddressPool1, ipAddressPool2, frrk8sPods) |
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 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.
added
By("Create a single IPAddressPool") | ||
ipAddressPool := createIPAddressPool(ipaddressPoolName1, addressPool) | ||
|
||
frrPod0, frrPod1 := setupTestCase(ipAddressPool, ipAddressPool, frrk8sPods) |
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 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.
added
setupMetalLbService("service-1", netparam.IPV4Family, ipAddressPool1, "Cluster") | ||
setupMetalLbService("service-2", netparam.IPV4Family, ipAddressPool2, "Cluster") |
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.
?
87b31d6
to
c0bee71
Compare
c0bee71
to
b7c20ae
Compare
moving test cases from cnf-gotest to eco-gotest