Skip to content

Commit

Permalink
L2 E2E tests: Flake fix: metrics validation of wrong speaker
Browse files Browse the repository at this point in the history
In this test sometimes we get the wrong node when looking
for the advertising node of a service.
A newly created service can get the same IP the service from
the previous test got (since it was already deleted).
While the previous service is down it can take time for the
running host ARP table to be updated.

The solution for such situation is to look for the advertising
node of a service inside an eventually.

Fixing issue #1195.

An example of the failing test can be found here:
https://github.com/metallb/metallb/runs/4911555260?check_suite_focus=true
  • Loading branch information
sabinaaledort authored and fedepaol committed Mar 7, 2022
1 parent 5e06635 commit 051e276
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions e2etest/l2tests/l2.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,21 @@ var _ = ginkgo.Describe("L2", func() {
allNodes, err := cs.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
framework.ExpectNoError(err)

advNode, err := advertisingNodeFromMAC(allNodes.Items, ingressIP, executor.Host)
framework.ExpectNoError(err)
advSpeaker, ok := speakerPods[advNode.Name]
framework.ExpectEqual(ok, true, fmt.Sprintf("could not find speaker pod on announcing node %s", advNode.Name))
delete(speakerPods, advSpeaker.Spec.NodeName)

var advNode *corev1.Node
var advSpeaker *corev1.Pod
gomega.Eventually(func() error {
var ok bool

advNode, err = advertisingNodeFromMAC(allNodes.Items, ingressIP, executor.Host)
if err != nil {
return err
}

advSpeaker, ok = speakerPods[advNode.Name]
if !ok {
return fmt.Errorf("could not find speaker pod on announcing node %s", advNode.Name)
}

speakerMetrics, err := metrics.ForPod(controllerPod, advSpeaker, metallb.Namespace)
if err != nil {
return err
Expand Down Expand Up @@ -464,6 +472,8 @@ var _ = ginkgo.Describe("L2", func() {
}, 2*time.Minute, 1*time.Second).Should(gomega.BeNil())

// Negative - validate that the other speakers don't publish layer2 metrics
delete(speakerPods, advSpeaker.Spec.NodeName)

for _, p := range speakerPods {
speakerMetrics, err := metrics.ForPod(controllerPod, p, metallb.Namespace)
framework.ExpectNoError(err)
Expand Down

0 comments on commit 051e276

Please sign in to comment.