Skip to content

tests: Use show module to get bgp's pid - #22023

Merged
eqvinox merged 1 commit into
FRRouting:masterfrom
donaldsharp:pidof_problem
May 21, 2026
Merged

tests: Use show module to get bgp's pid#22023
eqvinox merged 1 commit into
FRRouting:masterfrom
donaldsharp:pidof_problem

Conversation

@donaldsharp

Copy link
Copy Markdown
Member

The topotest is using pidof bgpd which is ok
when you run a test by itself, but when you
are running the topotests in parallel, this
is a bit of a problem. Fix.

The topotest is using `pidof bgpd` which is ok
when you run a test by itself, but when you
are running the topotests in parallel, this
is a bit of a problem.  Fix.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
@frrbot frrbot Bot added the tests Topotests, make check, etc label May 21, 2026
@greptile-apps

greptile-apps Bot commented May 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR replaces pidof bgpd (a host-wide process search) with a new _daemon_pid() helper that queries show module via vtysh on the specific router object, scoping the PID lookup to the correct network namespace when tests run in parallel.

  • Introduces _daemon_pid(router, daemon) that parses the per-daemon \"Module information for <name>:\" sections from show module output to extract the running PID.
  • Replaces three call sites of router.net.cmd(\"pidof bgpd\").strip() with _daemon_pid(r1, \"bgpd\"), fixing false PID matches that could occur when multiple test instances run bgpd simultaneously.

Confidence Score: 4/5

Safe to merge β€” the change correctly scopes PID lookups to the individual router namespace, and the regex parsing matches the actual show modules output format in FRR.

The fix is logically sound and addresses a real parallel-test isolation problem. The only minor concern is using the abbreviated command show module instead of the full show modules string, which works today via FRR abbreviation matching but is slightly less explicit.

No files require special attention beyond the minor command-name abbreviation in _daemon_pid.

Important Files Changed

Filename Overview
tests/topotests/bgp_bmp/test_bgp_bmp_mirror.py Adds _daemon_pid() helper using vtysh_cmd("show module") to replace the host-global pidof bgpd; the command string is the abbreviated form of the registered show modules command.

Sequence Diagram

sequenceDiagram
    participant Test as test_bgp_bmp_mirror
    participant Helper as _daemon_pid()
    participant Router as router (vtysh)
    participant bgpd

    Note over Test: Before fix - host-wide
    Test->>Router: net.cmd("pidof bgpd")
    Router-->>Test: any bgpd PID on host

    Note over Test: After fix - router-scoped
    Test->>Helper: _daemon_pid(router, "bgpd")
    Helper->>Router: vtysh_cmd("show module")
    Router->>bgpd: show modules
    bgpd-->>Router: Module information for bgpd, pid: 1234
    Router-->>Helper: output text
    Helper-->>Test: 1234 (bgpd PID in this namespace)
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
tests/topotests/bgp_bmp/test_bgp_bmp_mirror.py:100
The vtysh command registered in `lib/lib_vty.c` and `vtysh/vtysh.c` is `"show modules"` (with a trailing `s`). FRR's CLI supports unambiguous abbreviations, so `"show module"` works today, but using the full command name avoids any future ambiguity if another `show module*` command is ever added.

```suggestion
    output = router.vtysh_cmd("show modules")
```

Reviews (1): Last reviewed commit: "tests: Use `show module` to get bgp's pi..." | Re-trigger Greptile

Return the pid (as a string) of ``daemon`` running on ``router``,
or an empty string if it is not running.
"""
output = router.vtysh_cmd("show module")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 The vtysh command registered in lib/lib_vty.c and vtysh/vtysh.c is "show modules" (with a trailing s). FRR's CLI supports unambiguous abbreviations, so "show module" works today, but using the full command name avoids any future ambiguity if another show module* command is ever added.

Suggested change
output = router.vtysh_cmd("show module")
output = router.vtysh_cmd("show modules")
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/topotests/bgp_bmp/test_bgp_bmp_mirror.py
Line: 100

Comment:
The vtysh command registered in `lib/lib_vty.c` and `vtysh/vtysh.c` is `"show modules"` (with a trailing `s`). FRR's CLI supports unambiguous abbreviations, so `"show module"` works today, but using the full command name avoids any future ambiguity if another `show module*` command is ever added.

```suggestion
    output = router.vtysh_cmd("show modules")
```

How can I resolve this? If you propose a fix, please make it concise.

@eqvinox
eqvinox merged commit b2c7b09 into FRRouting:master May 21, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master size/M tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants