Skip to content

Migrate ack and rtx timer tests to synctest - #514

Merged
JoTurk merged 2 commits into
mainfrom
synctest
Sep 24, 2026
Merged

JoTurk merged 2 commits into
mainfrom
synctest

Conversation

@lanc07

@lanc07 lanc07 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Description

Migrate to synctest to avoid flaky and slow tests

@lanc07
lanc07 requested a review from JoTurk September 23, 2026 03:28
@JoTurk

JoTurk commented Sep 23, 2026

Copy link
Copy Markdown
Member

thank you @lanc07 It's late for me right now and the CI seems to be slow today :) I'll look at this the first thing in the morning.

Thank you so much.

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.57%. Comparing base (3a22191) to head (3b321df).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #514      +/-   ##
==========================================
+ Coverage   89.55%   89.57%   +0.02%     
==========================================
  Files          56       56              
  Lines        4642     4642              
==========================================
+ Hits         4157     4158       +1     
+ Misses        485      484       -1     
Flag Coverage Δ
go 89.57% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lanc07
lanc07 force-pushed the synctest branch 2 times, most recently from 8691a05 to 784cf98 Compare September 23, 2026 05:12
Comment thread ack_timer_test.go
Comment on lines +43 to +59
ok = rt.start()
assert.False(t, ok, "start() should NOT succeed once closed")
assert.True(t, rt.isRunning(), "should be running")

select {
case <-timedOut:
case <-time.After(ackInterval * 2):
assert.Fail(t, "should be called once")
}

select {
case <-timedOut:
assert.Fail(t, "should be called once")
case <-time.After(ackInterval * 2):
}
}

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.

This looks like a good direction, thanks for working on moving these timer tests to synctest.

The missing thing is that it needs to lean a bit more on synctest itself rather than replacing the existing Sleep calls with select + time.After. Inside synctest.Test, fake time will advance automatically, and synctest.Wait() gives us the synchronization we need without having to actually wait, so for most of these tests, I think the simpler pattern would be:

time.Sleep(...)
synctest.Wait()
assert.Equal(t, expected, callbacks)

to just replace the original sleep and after stopping a timer, we can advance fake time past when it would have fired, call synctest.Wait() for that.

Happy to help and explain more

@JoTurk JoTurk 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.

thank you so much @lanc07

@JoTurk
JoTurk merged commit fbc4ff5 into main Sep 24, 2026
19 checks passed
@JoTurk
JoTurk deleted the synctest branch September 24, 2026 00:33
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