Skip to content

Commit

Permalink
Use fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed May 1, 2024
1 parent 9488ba1 commit e726e89
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/migration/test_instance_init_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from palace.manager.core.config import Configuration
from palace.manager.scripts import InstanceInitializationScript
from palace.manager.sqlalchemy.session import SessionManager
from tests.fixtures.database import DatabaseFixture, DatabaseNameFixture
from tests.fixtures.database import DatabaseFixture
from tests.fixtures.services import ServicesFixture, mock_services_container


Expand Down Expand Up @@ -84,18 +84,19 @@ def _run_script(config_path: Path, worker_url: str) -> None:
def test_locking(
alembic_runner: MigrationContext,
alembic_config_path: Path,
database_name_func: DatabaseNameFixture,
instance_init_script_fixture: InstanceInitScriptFixture,
) -> None:
# Migrate to the initial revision
alembic_runner.migrate_down_to("base")
worker_url = instance_init_script_fixture.database.database_name.worker_url

# Spawn three processes, that will all try to migrate to head
# at the same time. One of them should do the migration, and
# the other two should wait, then do no migration since it
# has already been done.
process_kwargs = {
"config_path": alembic_config_path,
"worker_url": database_name_func.worker_url,
"worker_url": worker_url,
}
p1 = Process(target=_run_script, kwargs=process_kwargs)
p2 = Process(target=_run_script, kwargs=process_kwargs)
Expand Down

0 comments on commit e726e89

Please sign in to comment.