Skip to content

Conversation

@mkysel
Copy link
Collaborator

@mkysel mkysel commented Jul 1, 2025

Fix flaky registry tests by removing TestStopOnContextCancel and modifying TestContractRegistryChangedNodes to use validator functions with CountChannel

  • Removes the TestStopOnContextCancel test function entirely from contractRegistry_test.go
  • Modifies TestContractRegistryChangedNodes in contractRegistry_test.go to use a validator function with CountChannel instead of a separate goroutine for processing subscription channels
  • Updates the CountChannel function in notifier_test.go to accept optional validator functions that validate each value received from the channel before incrementing the count

📍Where to Start

Start with the modified CountChannel function in notifier_test.go to understand the new validator functionality, then review the changes to TestContractRegistryChangedNodes in contractRegistry_test.go.


Macroscope summarized c8ed51a.

@mkysel mkysel requested a review from a team as a code owner July 1, 2025 18:15
@graphite-app
Copy link

graphite-app bot commented Jul 1, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.


sub := registry.OnChangedNode(1)
getCurrentCount := r.CountChannel(sub)
go func() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there was a race. If this goroutine got the message, it would check the http address and the test would fail. In about 99% of the cases the countChannel would win and this check never got executed.

require.Equal(t, getCurrentCount(), 1)
}

func TestStopOnContextCancel(t *testing.T) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand the idea behind the test but since it does not generate new changes after shutdown, it does not test the stop.

Also, we rely on GC to close the channels so we can't even check that the channel got closed (which would probably do some nasty things to CountChannel) while we are holding a pointer to it.,

@mkysel mkysel merged commit 5974094 into main Jul 7, 2025
9 checks passed
@mkysel mkysel deleted the mkysel/fix-tests branch July 7, 2025 16:31
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.

3 participants