Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: improve notifications tests#13863

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dannykopping merged 7 commits intomainfromdk/system-notifications-improve-tests
Jul 10, 2024

Conversation

dannykopping
Copy link
Contributor

Blocks#13799

  • only use Postgres when necessary
  • add some more comments to improve readability

Also add some more comments to improve readabilitySigned-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
if !dbtestutil.WillUsePostgres() {
t.Skip("This test requires postgres")
t.Skip("This test requires postgres; it relies on business-logic implemented in the database")
Copy link
Member

Choose a reason for hiding this comment

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

nit: implementedonly

dannykopping reacted with thumbs up emoji
}
ctx, logger, db := setup(t)
// SETUP
ctx, logger, db := setupInMemory(t)
Copy link
Member

Choose a reason for hiding this comment

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

The problem with this approach is that we are not testing against the real database. I'm convinced if it is a truly safe way to go. Which parts of the implementation are missing in dbmem?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

dbmem doesn't actually perform the bulk updates, and along with that comes the retry logic; nor does it handle leases or locking.

There still are some tests which test the real database such asTestBackpressure,TestRetries, andTestExpiredLeaseIsRequeued. Each of those test the full scope of enqueue -> dequeue -> update -> requeue -> update.

In this test specifically, the database is not required to be tested - provided the observed behaviour of having a notification be dispatched to a webhook endpoint is achieved; so it's safe to use a mock database.

mtojek reacted with thumbs up emoji
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

What's the pro of no longer using Postgres for these tests? I'm unsure of how may PostgreSQL tests remain, but I'd feel a bit uncomfortable if all our testing was in dbmem.

Otherwise changes look good 👍🏻

Signed-off-by: Danny Kopping <danny@coder.com>
@dannykopping
Copy link
ContributorAuthor

dannykopping commentedJul 10, 2024
edited
Loading

What's the pro of no longer using Postgres for these tests? I'm unsure of how may PostgreSQL tests remain, but I'd feel a bit uncomfortable if all our testing was in dbmem.

Otherwise changes look good 👍🏻

The main benefit of not using Postgres really is just speed. See also#13863 (comment) for further explanation about the tests still using the database.

It's also useful to have a ~functioningdbmem implementation (at least for the happy path) for use in integration tests.

…include state syncSigned-off-by: Danny Kopping <danny@coder.com>
@dannykopping
Copy link
ContributorAuthor

@mafredri@mtojek I've modifiedTestBasicNotificationRoundtrip inedc4e7a to use Postgres, so that we have at least 1 test which isexplicitly testing the full roundtrip with the database, not implicitly like the others I mentioned.

Would you mind re-reviewing? I'll merge if you're happy.

mtojek reacted with eyes emoji

Signed-off-by: Danny Kopping <danny@coder.com>
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

Good to go 👍

@dannykoppingdannykopping merged commit542fff7 intomainJul 10, 2024
28 checks passed
@dannykoppingdannykopping deleted the dk/system-notifications-improve-tests branchJuly 10, 2024 13:25
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 10, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@mtojekmtojekmtojek approved these changes

Assignees

@dannykoppingdannykopping

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@dannykopping@mafredri@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp