Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions test/extended/networking/route_advertisements.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"regexp"
"slices"
"strings"
"sync"
"time"

g "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -137,9 +138,19 @@ var _ = g.Describe("[sig-network][OCPFeatureGate:RouteAdvertisements][Feature:Ro
v4PodIPSet map[string]string
v6PodIPSet map[string]string
clusterIPFamily IPFamily

gatherDebugInfoOnce sync.Once
)

doGatherDebugInfoOnce := func(oc *exutil.CLI, snifferDaemonset *v1.DaemonSet, targetNamespace string) {
gatherDebugInfoOnce.Do(
func() { gatherDebugInfo(oc, snifferDaemonset, targetNamespace) },
)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

g.BeforeEach(func() {
gatherDebugInfoOnce = sync.Once{}

g.By("Verifying that this cluster uses a network plugin that is supported for this test")
if networkPluginName() != OVNKubernetesPluginName {
skipper.Skipf("This cluster does not use OVNKubernetes")
Expand Down Expand Up @@ -204,9 +215,8 @@ var _ = g.Describe("[sig-network][OCPFeatureGate:RouteAdvertisements][Feature:Ro
})

g.JustAfterEach(func() {
specReport := g.CurrentSpecReport()
if specReport.Failed() {
gatherDebugInfo(oc, packetSnifferDaemonSet, targetNamespace, workerNodesOrderedNames)
if g.CurrentSpecReport().Failed() {
doGatherDebugInfoOnce(oc, packetSnifferDaemonSet, targetNamespace)
}
})

Expand Down Expand Up @@ -496,6 +506,9 @@ var _ = g.Describe("[sig-network][OCPFeatureGate:RouteAdvertisements][Feature:Ro
// cleanup the VRF-Lite configuration
defer func() {
o.Expect(func() error {
if g.CurrentSpecReport().Failed() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see both L3 and L2 VRF being tested in the same test, so we may not collect debug logs for one of it when it fails.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just ignore me, both are invoked with g.By, so it wouldn't proceed with 2nd one when first one fails.

doGatherDebugInfoOnce(oc, packetSnifferDaemonSet, targetNamespace)
}
err := runOcWithRetryIgnoreOutput(oc.AsAdmin(), "delete", "nncp", "extranet")
errors.Join(err, afterEach())
errors.Join(err, runOcWithRetryIgnoreOutput(oc.AsAdmin(), "delete", "ds", packetSnifferDaemonSet.Name, "-n", snifferNamespace))
Expand Down Expand Up @@ -1352,7 +1365,7 @@ func applyNNCP(oc *exutil.CLI, name, policy string) {
matches := nncpRenderedCompiledRegex.FindStringSubmatch(out)
g.Expect(matches).To(o.HaveLen(3))
g.Expect(matches[1]).To(o.Equal(matches[2]))
}).WithTimeout(300 * time.Second).WithPolling(5 * time.Second).Should(o.Succeed())
}).WithTimeout(600 * time.Second).WithPolling(5 * time.Second).Should(o.Succeed())
}

func runCommandInFrrPods(oc *exutil.CLI, command string) (map[string]string, error) {
Expand Down Expand Up @@ -1395,7 +1408,7 @@ func runCommandInFrrPods(oc *exutil.CLI, command string) (map[string]string, err
return results, nil
}

func gatherDebugInfo(oc *exutil.CLI, snifferDaemonset *v1.DaemonSet, targetNamespace string, workerNodesOrderedNames []string) {
func gatherDebugInfo(oc *exutil.CLI, snifferDaemonset *v1.DaemonSet, targetNamespace string) {
if out, err := runOcWithRetry(oc.AsAdmin().WithoutNamespace(), "get", "ra", "-o", "yaml"); err == nil {
framework.Logf("RouteAdvertisements:\n%s", out)
}
Expand All @@ -1418,7 +1431,7 @@ func gatherDebugInfo(oc *exutil.CLI, snifferDaemonset *v1.DaemonSet, targetNames
framework.Logf("FrrNodeStates:\n%s", out)
}
if out, err := runOcWithRetry(oc.AsAdmin().WithoutNamespace(), "get", "nncp", "-o", "yaml"); err == nil {
framework.Logf("FrrNodeStates:\n%s", out)
framework.Logf("NodeNetworkConfigurationPolicies:\n%s", out)
}
if snifferDaemonset != nil {
if out, err := runOcWithRetry(oc.AsAdmin().WithoutNamespace(), "get", "ds", "-n", snifferDaemonset.Namespace, "-o", "yaml"); err == nil {
Expand Down