ESD-1614-feat(mcr): add looking-glass ping and traceroute commands#508
ESD-1614-feat(mcr): add looking-glass ping and traceroute commands#508Phil-Browne wants to merge 6 commits into
Conversation
Bump megaportgo to v1.15.0 and add mcr looking-glass ping/traceroute subcommands for running ICMP ping and traceroute diagnostics from an MCR.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #508 +/- ##
==========================================
+ Coverage 78.57% 79.06% +0.48%
==========================================
Files 192 193 +1
Lines 18532 18750 +218
==========================================
+ Hits 14562 14825 +263
+ Misses 2904 2858 -46
- Partials 1066 1067 +1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds MCR Looking Glass diagnostic subcommands (ping and traceroute) to the CLI, wired through the existing cmdbuilder + action pattern and backed by a megaportgo SDK bump to support the new endpoints and polling behavior.
Changes:
- Add
mcr looking-glass pingandmcr looking-glass traceroutecommands with destination/source and ping packet options. - Implement ping/traceroute actions with SDK-backed async polling and a 5-minute default timeout.
- Add output shaping and tests (wrappers, action flows, and output conversion), plus generated docs updates.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/commands/mcr/mcr.go | Registers new Looking Glass ping/traceroute cobra commands and flags/examples. |
| internal/commands/mcr/mcr_looking_glass_actions.go | Implements ping/traceroute execution + polling with a 5-minute default timeout and flag validation. |
| internal/commands/mcr/mcr_looking_glass_output.go | Adds output structs and printers for ping results and traceroute hops. |
| internal/commands/mcr/mcr_looking_glass_utils.go | Adds wrapper vars for new SDK calls to simplify mocking in tests. |
| internal/commands/mcr/mcr_mock.go | Extends the Looking Glass mock service to support ping/traceroute methods and results. |
| internal/commands/mcr/mcr_looking_glass_test.go | Adds unit tests for wrappers, ping/traceroute actions, and output conversion helpers. |
| go.mod | Bumps github.com/megaport/megaportgo to v1.15.0. |
| go.sum | Updates sums for the megaportgo v1.15.0 bump. |
| docs/megaport-cli_mcr_looking-glass.md | Links new ping and traceroute subcommand docs from Looking Glass index. |
| docs/megaport-cli_mcr_looking-glass_ping.md | Adds generated documentation for mcr looking-glass ping. |
| docs/megaport-cli_mcr_looking-glass_traceroute.md | Adds generated documentation for mcr looking-glass traceroute. |
| docs/index.md | Regenerates docs index to include new commands and updated generation date. |
…esult duplication
…ooking-glass ping/traceroute
|
Small display bug worth fixing before merge: in host := probe.Host
if host == "" {
host = "*"
}
probeStrs[i] = fmt.Sprintf("%s (%.3fms)", host, probe.RTTMs)This renders as Suggested fix — treat empty host := probe.Host
if host == "" {
probeStrs[i] = "*"
continue
}
probeStrs[i] = fmt.Sprintf("%s (%.3fms)", host, probe.RTTMs)(and update the test's expected value accordingly). Everything else here looked good — context/timeout handling, nil-guarding, and the SDK-only call path (no local shell-out, so no injection surface on |
|
Fixed in ea807b6. An empty |
…ceroute # Conflicts: # internal/commands/mcr/mcr_mock.go
|
Three findings; the first is worth fixing before merge, the other two are low priority. 1. Error wraps use 2. Target addresses aren't format-validated ( 3. One nil hop discards the whole traceroute ( |
Wrap ping/traceroute start and wait errors with %w so classifyError can match megaport.ErrorResponse for correct exit codes. Validate --destination and --source as IPv4/IPv6 addresses before calling the API (matches the OpenAPI spec, which requires IP addresses, not hostnames). Render a nil traceroute hop as a bare "*" instead of aborting the whole result.
|
Fixed all three in c44cad1:
Added test coverage for the address validation, the |
Adds
mcr looking-glass pingandmcr looking-glass traceroutecommands, backed by a megaportgo bump to v1.15.0.--source,--packet-count(1-60), and--packet-size(1-9186) flags; traceroute supports--source.