Repository navigation
test: run upstream's unsafe tests in test-core - #260
utkarash2991 wants to merge 4 commits into
Conversation
|
Question: if the new pg_regress files are generated from the script then do we really need to store the generated scripts in VCS at all? We currently have .SQL.in files that are used to generate .SQL files but we only track the .SQL.in files in VCS. |
Good question: I added it bcoz the test matrix is bit different and provide ease to debug test failures . The If your worry is that tracked files can drift from the generator then we can add a check in the CI. WDYT? |
Do we even need assertions here? This whole exercise is basically trying to go through the entire parse tree and finding segfaults right? It would probably be sufficient to just run every sql and wait for crashes. Also another thing that surprises me the more I think about it: why was this not picked up in the core tests? I would image the |
@utkarash2991 Could you elaborate on the motivation here? Is it about running every feature (with its config turned on) against pg core? We already run core regress tests (ref), so I'm wondering if there's some overlap here. |
If it's about that, another option would be making the supautils configs |
@AndrewJackson2020 I think crashes are only one part. The other part is the hook taking a wrong decision on some odd form, like blocking something it should allow or elevating when it should not. The .out file records what the hook decides for each form + role, so if any branch changes we see it as a diff.
upstream does have
@steve-chavez Not exactly about features vs core. The gaps I see in core suite are:
The matrix covers these and the reset pass is to make sure the hook stays out of the way when nothing is configured. Configs are already on during test-core so IMO |
For reference:
So the above should not be unsafe for us since our test infra produces a disposable/temporary pg. We could run those tests.
We could use some instrumentation and run the hooks (even on superuser) just for testing. Overall what I'm finding is that the new python script and the generated SQL files are not looking maintainable: it's a lot of LOCs that have to be kept in sync with upstream. I think we should find a way to reuse pg core regress tests which should already contain the relevant SQL combinations. |
@steve-chavez Fair call. Let me give it a try. Will update here soon. |
|
I second Steve's opinion about maintainability. It looks like one of those cases where AI output can be really verbose without producing understandable code. When I tried to read the script, it just went over my head. |
15e8dc5 to
85eeb0c
Compare
f4fd383 to
13ca7c5
Compare
|
@utkarash2991 just a heads up, I notice that you are bumping xpg in this PR now. Supautils tests blow up with more recent postgres versions, specifically the hint functionality. See [0] for some discussion and [1] for my attempt to fix hints. I will say that deprecating hints may be on the table, either way some review/attention that will probably help move this PR along. |
13ca7c5 to
82b4758
Compare
82b4758 to
588f199
Compare
Postgres keeps src/test/modules/unsafe_tests out of installcheck because they change cluster-wide state. Our cluster is disposable, so stage the four files next to the core regress files when xpg provides them, and patch alter_system_table for the hint supautils adds.
The core tests run as a superuser, and the handlers return for superusers before reading the statement. Under TEST_CORE read the same role fields the handlers read, then return as usual.
xpg now installs src/test/modules/unsafe_tests into its regress output. Pinned to the commit until the next xpg tag.
588f199 to
1a6d090
Compare
The tag has the unsafe tests and the binary name fix.
|
@utkarash2991 Just saw the request for review, I think we need to first merge #267, which only needs some cleanup. cc @AndrewJackson2020 |
I merged #267 @utkarash2991 please rebase this PR, I believe the tests should be fixed after that. |
|
@utkarash2991 I think we should also merge #263 before this one. Bumps xpg from 2.5.0 -> 2.6.0 and so bundles any changes needed to the .out.patch files with that. I think it should be good to merge if you want to review. |
|
Looking at the macOS tests it looks like the asan/ubsan output is leaking to when running on clang. Need to fix this. |
|
The macOS errors should be fixable via this PR to xpg. Apologies for the inconvenience. |
| nixpkgs.url = "github:NixOS/nixpkgs/91c9a64ce2a84e648d0cf9671274bb9c2fb9ba60"; | ||
| xpg = { | ||
| url = "github:supabase/xpg/v2.5.0"; | ||
| url = "github:supabase/xpg/v2.7.0"; |
There was a problem hiding this comment.
Please bump this to v2.7.1 to get macOS CI working again. See below.
Postgres keeps a few regression files out of installcheck because they change cluster-wide state, for example
alter user all. Our test cluster is disposable, so we can run them. This stagessrc/test/modules/unsafe_testsnext to the core regress files and adds the four tests to the schedule.Those tests run as a superuser and the role handlers return for superusers before reading the statement. Under TEST_CORE the hook now reads the same role fields the handlers read, then returns as usual, so the core run exercises them too.
The files come from xpg's regress output as of supabase/xpg#17. xpg is pinned to v2.7.0, which ships those files and moves us to the current Postgres minors.
Stacked on #259.