diff --git a/edb/testbase/server.py b/edb/testbase/server.py index 8527601beb68..fe1855c6f19d 100644 --- a/edb/testbase/server.py +++ b/edb/testbase/server.py @@ -1482,12 +1482,13 @@ class StableDumpTestCase(QueryTestCase, CLITestCaseMixin): PARALLELISM_GRANULARITY = 'suite' async def check_dump_restore_single_db(self, check_method): - with tempfile.NamedTemporaryFile() as f: + with tempfile.TemporaryDirectory() as f: + fname = os.path.join(f, 'dump') dbname = edgedb_defines.EDGEDB_SUPERUSER_DB - await asyncio.to_thread(self.run_cli, '-d', dbname, 'dump', f.name) + await asyncio.to_thread(self.run_cli, '-d', dbname, 'dump', fname) await self.tearDownSingleDB() await asyncio.to_thread( - self.run_cli, '-d', dbname, 'restore', f.name + self.run_cli, '-d', dbname, 'restore', fname ) # Cycle the connection to avoid state mismatches @@ -1503,15 +1504,16 @@ async def check_dump_restore(self, check_method): src_dbname = self.get_database_name() tgt_dbname = f'{src_dbname}_restored' q_tgt_dbname = qlquote.quote_ident(tgt_dbname) - with tempfile.NamedTemporaryFile() as f: + with tempfile.TemporaryDirectory() as f: + fname = os.path.join(f, 'dump') await asyncio.to_thread( - self.run_cli, '-d', src_dbname, 'dump', f.name + self.run_cli, '-d', src_dbname, 'dump', fname ) await self.con.execute(f'CREATE DATABASE {q_tgt_dbname}') try: await asyncio.to_thread( - self.run_cli, '-d', tgt_dbname, 'restore', f.name + self.run_cli, '-d', tgt_dbname, 'restore', fname ) con2 = await self.connect(database=tgt_dbname) except Exception: diff --git a/tests/test_dump_basic.py b/tests/test_dump_basic.py index 33b6ab70542b..28ac5205a3e1 100644 --- a/tests/test_dump_basic.py +++ b/tests/test_dump_basic.py @@ -87,12 +87,13 @@ async def test_dump_fuzz_01(self): dbname = self.get_database_name() restored_dbname = f'{dbname}_restored' - with tempfile.NamedTemporaryFile() as f: - self.run_cli('-d', dbname, 'dump', f.name) + with tempfile.TemporaryDirectory() as f: + fname = os.path.join(f, 'dump') + self.run_cli('-d', dbname, 'dump', fname) await self.con.execute(f'CREATE DATABASE {restored_dbname}') try: - self.run_cli('-d', restored_dbname, 'restore', f.name) + self.run_cli('-d', restored_dbname, 'restore', fname) con2 = await self.connect(database=restored_dbname) except Exception: await tb.drop_db(self.con, restored_dbname) diff --git a/tests/test_server_ops.py b/tests/test_server_ops.py index bd4415931599..558994d1321a 100644 --- a/tests/test_server_ops.py +++ b/tests/test_server_ops.py @@ -1095,9 +1095,10 @@ async def _test_server_ops_restore_with_schema_signal(self, sd1, sd2): try: # Dump and restore should trigger a re-introspection in sd2 - with tempfile.NamedTemporaryFile() as f: + with tempfile.TemporaryDirectory() as f: + fname = os.path.join(f, 'dump') await asyncio.to_thread( - self.run_cli_on_connection, conn_args, "dump", f.name + self.run_cli_on_connection, conn_args, "dump", fname ) await asyncio.to_thread( self.run_cli_on_connection, @@ -1105,7 +1106,7 @@ async def _test_server_ops_restore_with_schema_signal(self, sd1, sd2): "-d", "restore_signal", "restore", - f.name + fname ) # The re-introspection has a delay, but should eventually happen