Skip to content

Conversation

@akrem-chabchoub
Copy link
Contributor

@akrem-chabchoub akrem-chabchoub commented Oct 29, 2025

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Add synctest package in blocker tests to prevent flakiness.
Remove parallel execution from tests.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

#5232

Screenshots (if appropriate):

@akrem-chabchoub akrem-chabchoub self-assigned this Oct 29, 2025
@akrem-chabchoub akrem-chabchoub added this to the v2.7.0 milestone Oct 29, 2025
@akrem-chabchoub akrem-chabchoub marked this pull request as ready for review October 29, 2025 07:05
Copilot AI review requested due to automatic review settings October 29, 2025 07:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors blocker tests to use Go's testing/synctest package for more reliable time-based testing. The changes wrap existing test logic in synctest.Test() calls, which provides deterministic control over time during testing.

  • Wraps three test functions with synctest.Test() for deterministic time control
  • Temporarily restricts CI test scope to pkg/blocker to speed up testing during development

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
pkg/blocker/blocker_test.go Wrapped TestBlocksAfterFlagTimeout, TestUnflagBeforeBlock, and TestPruneBeforeBlock with synctest.Test() for deterministic time-based testing
Makefile Temporarily narrowed test scope from ./... to ./pkg/blocker in CI test targets with TODO comment indicating this should be reverted before merge

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Makefile Outdated
Comment on lines 124 to 125
# TODO: should be ./... before merging, temporary change to pkg/blocker to speed up CI while testing blocker changes
$(GO) test -run "[^FLAKY]$$" -coverprofile=cover.out ./pkg/blocker
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The test scope has been temporarily narrowed to ./pkg/blocker only. As noted in the TODO comment, this should be reverted to ./... before merging to ensure full test coverage across the codebase.

Copilot uses AI. Check for mistakes.
Makefile Outdated
$(GO) test -run "[^FLAKY]$$" -coverprofile=cover.out ./pkg/blocker
else
$(GO) test -run "[^FLAKY]$$" ./...
$(GO) test -run "[^FLAKY]$$" ./pkg/blocker
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The test scope has been temporarily narrowed to ./pkg/blocker only. This should be reverted to ./... before merging to ensure full test coverage across the codebase.

Copilot uses AI. Check for mistakes.
Makefile Outdated
test-ci-race:
ifdef cover
$(GO) test -race -run "[^FLAKY]$$" -coverprofile=cover.out ./...
$(GO) test -race -run "[^FLAKY]$$" -coverprofile=cover.out ./pkg/blocker
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The test scope has been temporarily narrowed to ./pkg/blocker only. This should be reverted to ./... before merging to ensure full test coverage across the codebase.

Copilot uses AI. Check for mistakes.
Makefile Outdated
$(GO) test -race -run "[^FLAKY]$$" -coverprofile=cover.out ./pkg/blocker
else
$(GO) test -race -run "[^FLAKY]$$" ./...
$(GO) test -race -run "[^FLAKY]$$" ./pkg/blocker
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The test scope has been temporarily narrowed to ./pkg/blocker only. This should be reverted to ./... before merging to ensure full test coverage across the codebase.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@akrem-chabchoub please revert this

if len(blockedC) != 0 {
t.Fatal("blocker did not wait flag duration")
}
time.Sleep(flagTime / 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

it appears that the idiomatic way to use the synctest package is to use the synctest.Wait() call inside the tests rather than reverting to the inlined time.Sleep. WDYT about changing those sleep calls to the wait call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it makes sense.
I will change them.
Thanks for the review 🙂

time.Sleep(flagTime * 3)
// Suspending current goroutine expect that in this interval
// block listener was not called to block flagged address
time.Sleep(flagTime * 3)
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if this is really needed. if it is, then it could probably also be replaced with synctest.Wait

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, i forget it.
I updated it, thanks

@akrem-chabchoub akrem-chabchoub merged commit 72ed53f into master Nov 23, 2025
15 checks passed
@akrem-chabchoub akrem-chabchoub deleted the migrate-to-synctest-part1 branch November 23, 2025 21:35
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.

Use the new testing/synctest package from golang 1.25 in tests

5 participants