Skip to content

Improve macOS development experience, improve tests, and address data races#199

Open
maxmoehl wants to merge 4 commits into
masterfrom
maxmoehl/enhance
Open

Improve macOS development experience, improve tests, and address data races#199
maxmoehl wants to merge 4 commits into
masterfrom
maxmoehl/enhance

Conversation

@maxmoehl

Copy link
Copy Markdown
Member

See individual commits for detailed descriptions.

maxmoehl added 3 commits June 29, 2026 07:50
To allow running the test suite which does not depend on netlink we need
to exclude the files which do as the netlink library only works on
Linux. The test suite itself only relies on platform independent go code
and can be run on any platform.

The added build tags only prevent building packages on platforms where
it anyway would've failed.

Signed-off-by: Maximilian Moehl <maximilian@moehl.eu>
The test suite used differing loopback addresses from the 127.0.0.0/8
range to differentiate clients. Since the client port is already
selected at random we do not need to specify a different bind address.
Selecting a different bind address breaks the tests on macOS since it
only has one loopback address.

This commit switches all occurrences where a bind address was passed to
be the empty string which lets the OS pick the bind address. The
parameter is no longer used by any caller and should be removed, but
since it is part of the public API that is a breaking change which will
be done separately.

Signed-off-by: Maximilian Moehl <maximilian@moehl.eu>
The tests are using time.Sleep liberally which have to be conservative
to ensure the condition is met before testing it causing the tests to
take longer than needed.

This commit reworks the test cases to rely on Eventually and
Consistently instead which pass as soon as the condition is met
significantly reducing the test runtime.

Signed-off-by: Maximilian Moehl <maximilian@moehl.eu>
Running the tests with the race detector enabled flagged multiple cases
in which concurrent access was not properly synchronized. This commit
addresses those cases.

What remains to be done is a comprehensive review of all locks and their
usage. It seems like some of them could be simplified and there are some
cases in which deadlocks may occur due to multiple locks being held at
the same time.

Signed-off-by: Maximilian Moehl <maximilian@moehl.eu>
@maxmoehl maxmoehl requested a review from a team June 29, 2026 06:00

@mkalcok mkalcok left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overall LGTM, thank you, these are some fine QOL changes. I left some comments in-line, but none of them are blocking, I'll leave it up to you whether to address them or not.

Regarding merging strategy, this PR contains a bunch of logically separate commits (connected by a theme), so I'd suggest rebase rather than squash.

Comment thread peer_test.go
err := mbClient.AddPeer(serverAddress, "")
Expect(err).NotTo(HaveOccurred())

time.Sleep(5 * time.Second)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'll cheer every time there's a hardcoded sleep removed from tests 🎉

Comment thread peer_test.go
RetryIntervalMax = savedRetryMax
}()

totalClients := 50

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why was this changed from 600 to 50? It seems slightly out of scope for this commit. If it's relevant for this commit, it should probably be mentioned in the commit message, a it's a significant change.

Comment thread peer.go
timeout := time.Duration(p.keepaliveInterval) * time.Second * 5 / 2
p.log().Infof("KEEPALIVE timeout: %v", timeout)
p.keepaliveTimer = time.NewTimer(timeout)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What was the motivation for pulling this block from keepaliveLoop?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants