Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: wait for the dbus-daemon to be ready using its output #152

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

3v1n0
Copy link
Collaborator

@3v1n0 3v1n0 commented Dec 13, 2023

dbus-daemon can print out its listen address when it's ready, by waiting so instead of just guessing how much to wait.

Doing this through some goroutines although being this test code we could very likely just hang.

PS: Since these two functions were already pretty much the same, can we just maybe move them in a common place? If so, which one should I pick?

@3v1n0 3v1n0 requested a review from a team as a code owner December 13, 2023 21:00
@3v1n0 3v1n0 force-pushed the cleaner-dbus-wait branch from bdfe5c0 to 371e6f1 Compare December 14, 2023 01:52
@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.62%. Comparing base (6323fbd) to head (fafc8bd).
Report is 1291 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #152   +/-   ##
=======================================
  Coverage   88.62%   88.62%           
=======================================
  Files          34       34           
  Lines        2532     2532           
=======================================
  Hits         2244     2244           
  Misses        221      221           
  Partials       67       67           

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

Copy link
Contributor

@GabrielNagy GabrielNagy left a comment

Choose a reason for hiding this comment

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

Good catch, I think we can be more idiomatic in our implementation - I've left some comments inline.

PS: Since these two functions were already pretty much the same, can we just maybe move them in a common place? If so, which one should I pick?

The testutils package would be a good candidate for this IMO

internal/brokers/withexamples.go Outdated Show resolved Hide resolved
internal/brokers/withexamples.go Outdated Show resolved Hide resolved
@3v1n0
Copy link
Collaborator Author

3v1n0 commented Dec 14, 2023

The testutils package would be a good candidate for this IMO

IIRC when I tried that it didn't work because of an import loop.

❯ go build -C ~/Dev/authd/cmd/authd -tags withexamplebroker
package github.com/ubuntu/authd/cmd/authd
	imports github.com/ubuntu/authd/cmd/authd/daemon
	imports github.com/ubuntu/authd/internal/services
	imports github.com/ubuntu/authd/internal/brokers
	imports github.com/ubuntu/authd/internal/testutils
	imports github.com/ubuntu/authd/internal/brokers: import cycle not allowed

@3v1n0 3v1n0 force-pushed the cleaner-dbus-wait branch 2 times, most recently from b1affe8 to 1b8ff32 Compare December 14, 2023 20:12
3v1n0 and others added 3 commits December 14, 2023 21:22
…g cycle

When using testutils inside internal/brokers we were getting this:

❯ go build -C ~/Dev/authd/cmd/authd -tags withexamplebroker
package github.com/ubuntu/authd/cmd/authd
	imports github.com/ubuntu/authd/cmd/authd/daemon
	imports github.com/ubuntu/authd/internal/services
	imports github.com/ubuntu/authd/internal/brokers
	imports github.com/ubuntu/authd/internal/testutils
	imports github.com/ubuntu/authd/internal/brokers: import cycle not allowed
dbus-daemon can print out its listen address when it's ready, by waiting
so instead of just guessing how much to wait.

Doing this through some goroutines although being this test code we
could very likely just hang.

Co-authored-by: Gabriel Nagy <[email protected]>
@3v1n0 3v1n0 force-pushed the cleaner-dbus-wait branch from 1b8ff32 to fafc8bd Compare December 14, 2023 20:22
@3v1n0 3v1n0 requested a review from GabrielNagy December 14, 2023 20:25
@GabrielNagy GabrielNagy changed the title dbus: Wait for the dbus-daemon to be ready using its output perf: wait for the dbus-daemon to be ready using its output Dec 15, 2023
Copy link
Contributor

@GabrielNagy GabrielNagy left a comment

Choose a reason for hiding this comment

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

This is really nice, thanks @3v1n0! I did a smoke test with the new implementation and confirm it works 🎉

@GabrielNagy GabrielNagy merged commit 06c32ac into ubuntu:main Dec 15, 2023
4 checks passed
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