Skip to content

Commit

Permalink
Make branch tests compare the original and copied schemas.
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetrovykh committed Feb 1, 2024
1 parent cb3d6ca commit 5179889
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions edb/testbase/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,12 +1542,14 @@ async def check_branching(self, include_data=False, *, check_method):

orig_branch = self.get_database_name()
new_branch = f'new_{orig_branch}'
# record the original schema
orig_schema = await self.con.query_single('describe schema as sdl')

# connect to a default branch so we can create a new branch
branch_type = 'DATA' if include_data else 'SCHEMA'
branch_type = 'data' if include_data else 'schema'
await self.con.execute(
f'CREATE {branch_type} BRANCH {new_branch} '
f'FROM {orig_branch}'
f'create {branch_type} branch {new_branch} '
f'from {orig_branch}'
)

try:
Expand All @@ -1559,6 +1561,21 @@ async def check_branching(self, include_data=False, *, check_method):
oldcon = self.con
self.__class__.con = con2
try:
# We cannot compare the SDL text of the new branch schema to the
# original because the order in which it renders all the
# components is not guaranteed. Instead we will use migrations to
# compare the new branch schema to the original. We expect there
# to be no difference and therefore a new migration to the
# original schema should have the "complete" status right away.
await self.con.execute(f'start migration to {{ {orig_schema} }}')
mig_status = json.loads(
await self.con.query_single_json(
'describe current migration as json'
)
)
self.assertTrue(mig_status.get('complete'))
await self.con.execute('abort migration')

# run the check_method on the copied branch
if include_data:
await check_method(self)
Expand Down

0 comments on commit 5179889

Please sign in to comment.