-
Notifications
You must be signed in to change notification settings - Fork 905
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Also add some more comments to improve readability 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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: implemented only
} | ||
ctx, logger, db := setup(t) | ||
// SETUP | ||
ctx, logger, db := setupInMemory(t) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 as TestBackpressure
, TestRetries
, and TestExpiredLeaseIsRequeued
. 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.
There was a problem hiding this 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>
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 ~functioning |
…include state sync Signed-off-by: Danny Kopping <danny@coder.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go 👍
Blocks #13799