-
Notifications
You must be signed in to change notification settings - Fork 290
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
Run postgres datastore tests with pgbouncer #1594
Conversation
c7cfd94
to
118ffa6
Compare
I'll take a look at the test failures as I have time |
64b89cc
to
97ad115
Compare
"POOL_MODE=session", // https://github.com/authzed/spicedb/issues/1217 | ||
"IGNORE_STARTUP_PARAMETERS=plan_cache_mode", // Tell pgbouncer to pass this param thru to postgres. |
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.
These are the two pgbouncer settings that need to be documented.
The spanner tests failed, but that feels like an unrelated flaky test |
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.
@bradengroom this is cool! I think we would want to retain the tests talking directly to Postgres too, would you mind redesigning this so it's an option? then we can run this as another datastore GitHub Action in parallel with the non-pgbouncer enabled test suite.
Sure thing. Makes sense! |
magefiles/util.go
Outdated
testArgs := append([]string{"test", "-failfast", "-count=1"}, args...) | ||
return RunSh(goCmdForTests(), WithV(), WithDir(dir), WithArgs(testArgs...))(path) | ||
testArgs := append([]string{"test", path, "-failfast", "-count=1"}, args...) | ||
return RunSh(goCmdForTests(), WithV(), WithDir(dir))(testArgs...) |
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 tests were unable to access the -enablePgbouncer
flag if it came before the path for some reason. After looking at this, it didn't feel like there was any reason that the path needed to be treated as a unique argument. Now I treat them similarly and place path at the front.
d8023cb
to
897c00b
Compare
I didn't want to structure this like all of the other datastore tests by creating a new folder for pgbouncer tests. I wanted to run all existing postgres tests through the pgbouncer setup. So I enabled this by adding an I'm open to other ideas in supporting this. |
fbdbb35
to
cc18f99
Compare
Rebased. I think the currently failing test is possibly flaky. (unrelated? ) |
@bradengroom 🤔 The way this is tested seems to introduce a new pattern into the codebase instead of using the ones in place. The way I imagined we would implement is by adding a new parameter to
You can see that spicedb/internal/datastore/postgres/postgres_test.go Lines 62 to 91 in 2094b82
|
cc18f99
to
2165659
Compare
2165659
to
a08027b
Compare
@vroldanbet Thanks for the review!
I think I over-indexed on this comment in order to get the separate CI steps. I've updated the postgres steps to include pgbouncer tests. Let me know if I've still misunderstood something. I don't mind iterating on it until the preferred patterns are met. |
There is a failing CI step, but it looks like a vulnerable dependency that should be addressed in a separate PR. |
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 changes look good to me! I left a few questions. I think my main concern is that CI time has increased greatly, making the postgres datastore test now the slowest of the CI jobs:
This is not surprising given we are greatly increasing the combination of parallel tasks to run, and please note we are using beefier runners here.
Sorry for the back and forth - I think the foundation is the right one. We can certainly run these tests on our local machines but CI may need more granular jobs. Another alternative would be to reduce the number of combinations, although I think being exhaustive here is a good thing. I think that for now adding a new pgbouncer
datastore as you did initially may be a good compromise, but hopefully we can now avoid using specific environment variables to tweak the behaviour.
The failed trivy is yet another gRPC vulnerability (we fixed one just 2 weeks ago) that is triggered via grpc-health-check
. I see they have updated to a new version but it hasn't been released yet, so we will need to build from a specific commit. I'll open a PR. EDIT: I've opened #1613
"AUTH_TYPE=md5", // use the same auth type as postgres | ||
"MAX_CLIENT_CONN=" + POSTGRES_TEST_MAX_CONNECTIONS, | ||
// params needed for spicedb | ||
"POOL_MODE=session", // https://github.com/authzed/spicedb/issues/1217 |
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.
I'm aware this is advice provided by the community (I certainly didn't verify this myself) but it's surprising given session
is the default. I wonder if this is related to the zalando operator mentioned by the user in Discord not setting session
as the default. Anyway, it does not hurt adding it.
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.
Yeah it looks like the Zalando operator chooses a different default (transaction
) for some reason:
https://github.com/zalando/postgres-operator/blob/409e4c78344f397d2c771129bcfb6968f84c1972/docs/reference/operator_parameters.md?plain=1#L998
By the way, we don't have to specify this setting here. I was just trying to explicitly document it in the test. I can remove this line and the tests continue to run successfully though. I'm happy to remove it if you prefer
@vroldanbet Do you have thoughts on what that'd look like? I think maybe I'm missing an alternate pattern that you're seeing. My goal is to avoid writing new tests specifically for pgbouncer. (Every test for postgres should be a valid test for pgbouncer). I'd like to just point all of the existing tests at both options. So I need to signal to the test suite somehow that we care about testing pgbouncer vs postgres in the current run. Each github action points to a function in the magefile setup. Each function invokes this Line 85 in aec1c86
Since we have to go through a Sorry if I'm overlooking something obvious and making this more complicated than it should be 😅 |
This is done solely so that CI builds don't take too long. As a solution this is run as a separate datastore test leveraging build tags consistency tests are left out of scope for now
@bradengroom I've pushed 8d1dc41 with what I think is a sensible approach to have those tests run in different CI jobs. Thoughts? |
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.
LGTM! Kudos for all the clean up and being willing to look into all suggestions! 🎉
I suspect the tests were already slow the moment I added the PR to test multiple PG versions 😢 They continue to take the same amount of time. I think we can work on that on a follow up if needed.
I think there may be a race happening with database creation, but I think it predated this PR:
|
Fixes #1217