Skip to content

Commit

Permalink
connectivity: improve reporting for no-unexpected-packet-drops check
Browse files Browse the repository at this point in the history
Let's leverage the GenericAction construct to provide better progress
and error reporting for the given test, displaying the node associated
with any issue and ensuring that we continue checking for problems
also after that a first one has been found. Let's also configure it
to still capture a single sysdump regardless of the number of failures.

Signed-off-by: Marco Iorio <[email protected]>
  • Loading branch information
giorio94 authored and tklauser committed Feb 23, 2024
1 parent f161fcf commit 6553bca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion connectivity/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ func Run(ctx context.Context, ct *check.ConnectivityTest, extra Hooks) error {
}
}

ct.NewTest("no-unexpected-packet-drops").WithScenarios(tests.NoUnexpectedPacketDrops(ct.Params().ExpectedDropReasons))
ct.NewTest("no-unexpected-packet-drops").
WithScenarios(tests.NoUnexpectedPacketDrops(ct.Params().ExpectedDropReasons)).
WithSysdumpPolicy(check.SysdumpPolicyOnce)

// Run all tests without any policies in place.
noPoliciesScenarios := []check.Scenario{
Expand Down
18 changes: 10 additions & 8 deletions connectivity/tests/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ func (n *noUnexpectedPacketDrops) Run(ctx context.Context, t *check.Test) {

for _, pod := range ct.CiliumPods() {
pod := pod
stdout, err := pod.K8sClient.ExecInPod(ctx, pod.Pod.Namespace, pod.Pod.Name, defaults.AgentContainerName, cmd)
if err != nil {
t.Fatalf("Error fetching packet drop counts: %s", err)
}
countStr := strings.TrimSpace(stdout.String())
if countStr != "" {
t.Fatalf("Found unexpected packet drops:\n%s", countStr)
}
t.NewGenericAction(n, fmt.Sprintf("%s/%s", pod.K8sClient.ClusterName(), pod.NodeName())).Run(func(a *check.Action) {
stdout, err := pod.K8sClient.ExecInPod(ctx, pod.Pod.Namespace, pod.Pod.Name, defaults.AgentContainerName, cmd)
if err != nil {
a.Fatalf("Error fetching packet drop counts: %s", err)
}
countStr := strings.TrimSpace(stdout.String())
if countStr != "" {
a.Failf("Found unexpected packet drops:\n%s", countStr)
}
})
}
}

Expand Down

0 comments on commit 6553bca

Please sign in to comment.