Skip to content

tests: Fix time re in all_protocol_startup/test_all_protocol_startup - #21378

Merged
riw777 merged 1 commit into
FRRouting:masterfrom
hedrok:fix_frr_test
Mar 31, 2026
Merged

tests: Fix time re in all_protocol_startup/test_all_protocol_startup #21378
riw777 merged 1 commit into
FRRouting:masterfrom
hedrok:fix_frr_test

Conversation

@hedrok

@hedrok hedrok commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

There was failure in test with diff:

 -    Hello due in 932 usecs
 +    Hello due in XX.XXXs

Regular expression expected for format SECONDS.MSECs only.

Added usec support to regular expression.

ospf_timeval_dump can also output weeks, days, hours, but probably there is no need to support that.

Or should I add weeks, days, hours just in case?..

I couldn't reproduce failure, but tested regular expression with Hello due in 932 usecs and Hello due in 12.32s manually.

Failure URL: https://github.com/FRRouting/frr/pull/21376/checks?check_run_id=68874454155

Full output:

AssertionError: SHOW IP OSPF INTERFACE failed for router r1:
 --- actual SHOW IP OSPF INTERFACE
 +++ expected SHOW IP OSPF INTERFACE
 @@ -22,7 +22,7 @@
    No backup designated router on this network
    Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
    Timer intervals configured, Hello 1s, Dead 5s, Wait 5s, Retransmit 5
 -    Hello due in 932 usecs
 +    Hello due in XX.XXXs
    Neighbor Count is 0, Adjacent neighbor count is 0
    Graceful Restart hello delay: 10s
    LSA retransmissions: 0
assert 1 == 0
E   AssertionError: SHOW IP OSPF INTERFACE failed for router r1:
     --- actual SHOW IP OSPF INTERFACE
     +++ expected SHOW IP OSPF INTERFACE
     @@ -22,7 +22,7 @@
        No backup designated router on this network
        Multicast group memberships: OSPFAllRouters OSPFDesignatedRouters
        Timer intervals configured, Hello 1s, Dead 5s, Wait 5s, Retransmit 5
     -    Hello due in 932 usecs
     +    Hello due in XX.XXXs
        Neighbor Count is 0, Adjacent neighbor count is 0
        Graceful Restart hello delay: 10s
        LSA retransmissions: 0
   assert 1 == 0

There was failure in test with diff:

 -    Hello due in 932 usecs
 +    Hello due in XX.XXXs

Regular expression expected for format SECONDS.MSECs only.

Added `usec` support to regular expression.

`ospf_timeval_dump` can also output  weeks, days, hours, but probably
there is no need to support that.

Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
@frrbot frrbot Bot added the tests Topotests, make check, etc label Mar 27, 2026
@greptile-apps

greptile-apps Bot commented Mar 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a flaky test failure in test_ospfv2_interfaces by extending the regex that masks the "Hello due in" timer value to also match the usecs format output by ospf_timeval_dump when the remaining time is less than 1 ms (i.e., when tv_sec == 0 and tv_usec < 1000).\n\n- The original regex [-0-9\\.]+s only matched the X.XXXs (seconds + milliseconds) format.\n- ospf_timeval_dump falls into the \"%ld usecs\" branch when tv_sec == 0 and there are no whole milliseconds, producing output like 932 usecs.\n- The fix adds ( usec)? to the pattern so both 12.32s and 932 usecs are correctly normalized to XX.XXXs before comparison.\n- The regex correctly handles the space before usec since the space is part of the captured group ( usec).\n- The PR author notes that formats for weeks/days/hours are not covered, which is acceptable since those durations are unrealistic for a Hello timer (typically 1–10 s).

Confidence Score: 5/5

This PR is safe to merge β€” it is a minimal, targeted fix to a single test regex with no functional code changes.

The change is a single-line regex update in a test file with no ambiguity. The fix correctly handles the usecs branch of ospf_timeval_dump (verified against the source), all other existing format cases (X.XXXs) continue to work, and there are no logic or syntax errors introduced.

No files require special attention.

Important Files Changed

Filename Overview
tests/topotests/all_protocol_startup/test_all_protocol_startup.py One-line regex fix in test_ospfv2_interfaces to handle "Hello due in 932 usecs" output from ospf_timeval_dump, in addition to the existing "Hello due in XX.XXXs" format.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["ospf_timeval_dump(t)"] --> B{tv_sec > 0\nor ms > 0?}
    B -- Yes --> C["Format: '%ld.%03lus'\ne.g. '12.32s'"]
    B -- No --> D["Format: '%ld usecs'\ne.g. '932 usecs'"]
    C --> E["Matched by [-0-9\\.]+s\n(original & new regex)"]
    D --> F["NOT matched by original regex\n[-0-9\\.]+s"]
    F --> G["FIXED: matched by new regex\n[-0-9\\.]+( usec)?s"]
    E --> H["Replaced with 'Hello due in XX.XXXs'"]
    G --> H
Loading

Reviews (1): Last reviewed commit: "tests: Fix time re in all_protocol_start..." | Re-trigger Greptile

@riw777 riw777 left a comment

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.

looks good

@riw777
riw777 merged commit 9cce9c0 into FRRouting:master Mar 31, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master size/XS tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants