Skip to content

Commit

Permalink
connectivity test: Add --numeric option
Browse files Browse the repository at this point in the history
Add command line option '--numeric' to print hubble flows without IP
translation. This helps in matching flow requirements to flows when
debugging failing flow validation, as the flow requirements are printed
(and executed) with IP addresses without translation.

Signed-off-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
jrajahalme committed Nov 29, 2023
1 parent 85d3ca0 commit 5afb60f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion connectivity/check/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,13 @@ func (a *Action) printFlows(peer TestPeer) {
}

a.Logf("📄 Flow logs for peer %s:", peer.Name())
printer := hubprinter.New(hubprinter.Compact(), hubprinter.WithIPTranslation())
var printer *hubprinter.Printer
if a.test.ctx.Numeric() {
printer = hubprinter.New(hubprinter.Compact())
} else {
printer = hubprinter.New(hubprinter.Compact(), hubprinter.WithIPTranslation())
}

defer printer.Close()

r := a.flowResults[peer]
Expand Down
1 change: 1 addition & 0 deletions connectivity/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Parameters struct {
TestNamespace string
SingleNode bool
PrintFlows bool
Numeric bool
ForceDeploy bool
Hubble bool
HubbleServer string
Expand Down
4 changes: 4 additions & 0 deletions connectivity/check/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,10 @@ func (ct *ConnectivityTest) PrintFlows() bool {
return ct.params.PrintFlows
}

func (ct *ConnectivityTest) Numeric() bool {
return ct.params.Numeric
}

func (ct *ConnectivityTest) AllFlows() bool {
return ct.params.AllFlows
}
Expand Down
1 change: 1 addition & 0 deletions internal/cli/cmd/connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func newCmdConnectivityTest(hooks Hooks) *cobra.Command {

cmd.Flags().BoolVar(&params.SingleNode, "single-node", false, "Limit to tests able to run on a single node")
cmd.Flags().BoolVar(&params.PrintFlows, "print-flows", false, "Print flow logs for each test")
cmd.Flags().BoolVar(&params.Numeric, "numeric", false, "Print IP addresses in flow logs instead of pod names")
cmd.Flags().DurationVar(&params.PostTestSleepDuration, "post-test-sleep", 0, "Wait time after each test before next test starts")
cmd.Flags().BoolVar(&params.ForceDeploy, "force-deploy", false, "Force re-deploying test artifacts")
cmd.Flags().BoolVar(&params.Hubble, "hubble", true, "Automatically use Hubble for flow validation & troubleshooting")
Expand Down

0 comments on commit 5afb60f

Please sign in to comment.