Skip to content

Commit

Permalink
test: use new server for stats tests
Browse files Browse the repository at this point in the history
So that reset_query_stats() doesn't affect each other
  • Loading branch information
fantix committed Jan 3, 2025
1 parent 4472152 commit ca1d238
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tests/test_edgeql_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ async def _configure_track(self, option: str):
async def _bad_query_for_stats(self):
raise NotImplementedError

async def _test_sys_query_stats(self):
def _before_test_sys_query_stats(self):
if self.backend_dsn:
self.skipTest(
"can't run query stats test when extension isn't present"
)

async def _test_sys_query_stats(self):
stats_query = f'''
with stats := (
select
Expand Down Expand Up @@ -177,7 +178,15 @@ async def _bad_query_for_stats(self):
await self.con.query(f'select {self.stats_magic_word}_NoSuchType')

async def test_edgeql_sys_query_stats(self):
await self._test_sys_query_stats()
self._before_test_sys_query_stats()
async with tb.start_edgedb_server() as sd:
old_con = self.con
self.con = await sd.connect()
try:
await self._test_sys_query_stats()
finally:
await self.con.aclose()
self.con = old_con


class TestSQLSys(tb.SQLQueryTestCase, TestQueryStatsMixin):
Expand Down Expand Up @@ -215,4 +224,14 @@ async def _bad_query_for_stats(self):
)

async def test_sql_sys_query_stats(self):
await self._test_sys_query_stats()
self._before_test_sys_query_stats()
async with tb.start_edgedb_server() as sd:
old_cons = self.con, self.scon
self.con = await sd.connect()
self.scon = await sd.connect_pg()
try:
await self._test_sys_query_stats()
finally:
await self.scon.close()
await self.con.aclose()
self.con, self.scon = old_cons

0 comments on commit ca1d238

Please sign in to comment.