Skip to content

Conversation

@quettabit
Copy link
Member

No description provided.

@quettabit quettabit requested a review from a team as a code owner January 4, 2026 20:47
@quettabit quettabit merged commit 2d2146b into main Jan 4, 2026
3 checks passed
@quettabit quettabit deleted the qb/fix-lexi-order branch January 4, 2026 20:47
@greptile-apps
Copy link

greptile-apps bot commented Jan 4, 2026

Greptile Summary

Fixed lexicographical ordering bug in test helper functions by zero-padding counter values to 4 digits.

  • Changed format strings from "stream-{}-{}" to "stream-{}-{:04}" and "basin-{}-{:04}" in unique_stream_name() and unique_basin_name()
  • Ensured sequential counters (0, 1, 2, ..., 10, 11) sort correctly as "0000", "0001", "0002", ..., "0010", "0011" instead of incorrect string ordering where "10" < "2"
  • Removed unnecessary 100ms sleep workaround in list_streams_with_limit test that was attempting to ensure timestamp differences between stream creations
  • The list_streams_with_limit test expects stream_name_1 to be returned first when listing with limit=1, which requires proper lexicographical ordering

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are minimal, well-focused, and directly address a clear bug in test infrastructure. Zero-padding ensures predictable lexicographical sorting, and removing the sleep workaround makes tests more robust and faster
  • No files require special attention

Important Files Changed

Filename Overview
tests/common/mod.rs Fixed lexicographical ordering by zero-padding counters to 4 digits in unique name generators
tests/basin_ops.rs Removed unnecessary 100ms sleep workaround now that lexicographical ordering is properly ensured

Sequence Diagram

sequenceDiagram
    participant Test as list_streams_with_limit Test
    participant Counter as TEST_COUNTER (AtomicU32)
    participant Generator as unique_stream_name()
    participant Basin as S2Basin API
    
    Test->>Counter: fetch_add(1) → 0
    Counter-->>Test: counter = 0
    Test->>Generator: format with timestamp + counter
    Note over Generator: "stream-{timestamp}-{:04}"<br/>becomes "stream-123456-0000"
    Generator-->>Test: stream_name_1
    
    Test->>Counter: fetch_add(1) → 1
    Counter-->>Test: counter = 1
    Test->>Generator: format with timestamp + counter
    Note over Generator: "stream-{timestamp}-{:04}"<br/>becomes "stream-123456-0001"
    Generator-->>Test: stream_name_2
    
    Test->>Counter: fetch_add(1) → 2
    Counter-->>Test: counter = 2
    Test->>Generator: format with timestamp + counter
    Note over Generator: "stream-{timestamp}-{:04}"<br/>becomes "stream-123456-0002"
    Generator-->>Test: stream_name_3
    
    Note over Test: Names now sort correctly:<br/>"0000" < "0001" < "0002"<br/>Previously: "0" < "1" < "2" BUT<br/>"10" would come before "2"
    
    Test->>Basin: create_stream(stream_name_1)
    Basin-->>Test: stream_info_1
    
    Test->>Basin: create_stream(stream_name_2)
    Basin-->>Test: stream_info_2
    
    Test->>Basin: create_stream(stream_name_3)
    Basin-->>Test: stream_info_3
    
    Test->>Basin: list_streams(limit=1)
    Note over Basin: Returns lexicographically first stream
    Basin-->>Test: [stream_info_1]
    
    Test->>Test: assert_eq!(page.values, vec![stream_info_1])
    Note over Test: ✓ Test passes with correct ordering
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants