Skip to content

Commit

Permalink
Add testing for the patch system
Browse files Browse the repository at this point in the history
We test actually applying all of our real patches on release branches,
but this adds testing on the master branch of the patch system itself.

It works in basically the same way as our inplace upgrade tests: by
creating a database, and then applying a diff that makes some
synthetic testing changes to the server/compiler.

I (re)discovered some various frustrating limitations of the patch system
while doing this, but haven't fixed those yet.

Fixes #5804.
  • Loading branch information
msullivan committed Feb 5, 2025
1 parent f266343 commit c595f7a
Show file tree
Hide file tree
Showing 5 changed files with 707 additions and 5 deletions.
15 changes: 13 additions & 2 deletions .github/workflows.src/tests-inplace.tpl.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% from "tests.inc.yml" import build, calc_cache_key, restore_cache -%>

name: Tests of in-place upgrades
name: Tests of in-place upgrades and patching

on:
schedule:
Expand All @@ -22,7 +22,7 @@ jobs:
<< calc_cache_key()|indent >>
<%- endcall %>

test:
test-inplace:
runs-on: ubuntu-latest
needs: build
strategy:
Expand All @@ -47,6 +47,17 @@ jobs:
run: |
./tests/inplace-testing/test.sh ${{ matrix.flags }} vt ${{ matrix.tests }}
test-patches:
runs-on: ubuntu-latest
needs: build

steps:
<<- restore_cache() >>

- name: Test performing in-place upgrades
run: |
./tests/patch-testing/test.sh -k test_link_on_target_delete -k test_edgeql_select -k test_edgeql_scope -k test_dump
workflow-notifications:
if: failure() && github.event_name != 'pull_request'
name: Notify in Slack on failures
Expand Down
166 changes: 164 additions & 2 deletions .github/workflows/tests-inplace.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion edb/server/compiler/ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,9 +1405,10 @@ def administer_repair_schema(

return dbstate.DDLQuery(
sql=sql,
user_schema=current_tx.get_user_schema_if_updated(), # type: ignore
user_schema=current_tx.get_user_schema_if_updated(),
global_schema=current_tx.get_global_schema_if_updated(),
config_ops=config_ops,
feature_used_metrics={},
)


Expand Down
48 changes: 48 additions & 0 deletions tests/patch-testing/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash -ex

while [[ $# -gt 0 ]]; do
case $1 in
--save-tarballs)
SAVE_TARBALLS=1
shift
;;
*)
break
;;
esac
done


DIR="$1"
shift

if ! git diff-index --quiet HEAD --; then
set +x
echo Refusing to run patching upgrade test with dirty git state.
echo "(The test makes local modifications.)"
exit 1
fi

make parsers

# Setup the test database
edb inittestdb -D "$DIR" "$@"


if [ "$SAVE_TARBALLS" = 1 ]; then
tar cf "$DIR".tar "$DIR"
fi


# Upgrade to the new version
patch -f -p1 < tests/patch-testing/upgrade.patch
make parsers

edb server --bootstrap-only --data-dir "$DIR"

if [ "$SAVE_TARBALLS" = 1 ]; then
tar cf "$DIR"-upgraded.tar "$DIR"
fi

# Test!
edb test --data-dir "$DIR" --use-data-dir-dbs -v "$@"
Loading

0 comments on commit c595f7a

Please sign in to comment.