Skip to content

Commit 02c84da

Browse files
committed
Restored pg downgrade and described fix
1 parent 93cf40a commit 02c84da

File tree

4 files changed

+27
-32
lines changed

4 files changed

+27
-32
lines changed

packages/pytest-simcore/src/pytest_simcore/postgres_service.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,10 @@ def postgres_engine(
5656
engine.dispose()
5757

5858

59-
@pytest.fixture(scope="module")
60-
def migration_downgrade_disabled() -> bool:
61-
""" Override to enable migration downgrade step in postgres_db teardown """
62-
return True
63-
64-
6559
@pytest.fixture(scope="module")
6660
def postgres_db(
6761
postgres_dsn: Dict,
6862
postgres_engine: sa.engine.Engine,
69-
migration_downgrade_disabled: bool,
7063
) -> sa.engine.Engine:
7164

7265
# upgrades database from zero
@@ -76,17 +69,18 @@ def postgres_db(
7669

7770
yield postgres_engine
7871

79-
if not migration_downgrade_disabled:
80-
# NOTE: After discussion with ANE, this step delays tests and do not bring much as a fixture
81-
# therefore it is added as optional
82-
83-
pg_cli.downgrade.callback("base")
84-
pg_cli.clean.callback()
85-
# FIXME: migration downgrade fails to remove all tables!!, added drop_all as tmp fix
86-
metadata.drop_all(postgres_engine)
87-
88-
else:
89-
metadata.drop_all(postgres_engine)
72+
# downgrades database to zero ---
73+
#
74+
# NOTE: This step CANNOT be avoided since it would leave the db in an invalid state
75+
# E.g. 'alembic_version' table is not deleted and keeps head version or routines
76+
# like 'notify_comp_tasks_changed' remain undeleted
77+
#
78+
pg_cli.downgrade.callback("base")
79+
pg_cli.clean.callback() # just cleans discover cache
80+
81+
# FIXME: migration downgrade fails to remove User types SEE https://github.com/ITISFoundation/osparc-simcore/issues/1776
82+
# Added drop_all as tmp fix
83+
metadata.drop_all(postgres_engine)
9084

9185

9286
@pytest.fixture(scope="module")

services/web/server/tests/integration/computation/test_computation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242

4343
ops_services = [
4444
"minio",
45-
# 'adminer',
46-
# 'portainer'
47-
]
45+
] # + ["adminer", "portainer"]
4846

4947

5048
@pytest.fixture
5149
def client(
52-
loop, aiohttp_client, app_config, ## waits until swarm with *_services are up
50+
loop,
51+
aiohttp_client,
52+
app_config, ## waits until swarm with *_services are up
5353
):
5454
assert app_config["rest"]["version"] == API_VERSION
5555

services/web/server/tests/integration/computation/test_rabbit.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import aio_pika
1313
import pytest
14+
import sqlalchemy as sa
1415
from mock import call
15-
from pytest_simcore.postgres_service import postgres_db
1616

1717
from servicelib.application import create_safe_application
1818
from servicelib.application_keys import APP_CONFIG_KEY
@@ -36,8 +36,6 @@
3636

3737
ops_services = []
3838

39-
import sqlalchemy as sa
40-
4139

4240
@pytest.fixture
4341
def client(
@@ -184,7 +182,12 @@ async def _wait_until(pred: Callable, timeout: int):
184182

185183

186184
@pytest.mark.parametrize(
187-
"user_role", [(UserRole.GUEST), (UserRole.USER), (UserRole.TESTER),]
185+
"user_role",
186+
[
187+
(UserRole.GUEST),
188+
(UserRole.USER),
189+
(UserRole.TESTER),
190+
],
188191
)
189192
async def test_rabbit_websocket_computation(
190193
loop,

services/web/server/tests/integration/test_project_workflow.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
"redis",
4242
]
4343

44-
ops_services = [
45-
# 'adminer'
46-
]
44+
ops_services = [] # + ["adminer"]
4745

4846

4947
@pytest.fixture
@@ -122,7 +120,7 @@ def fake_project_data(fake_data_dir: Path) -> Dict:
122120

123121
@pytest.fixture
124122
async def logged_user(client): # , role: UserRole):
125-
""" adds a user in db and logs in with client
123+
"""adds a user in db and logs in with client
126124
127125
NOTE: role fixture is defined as a parametrization below
128126
"""
@@ -150,9 +148,9 @@ def computational_system_mock(mocker):
150148
@pytest.fixture
151149
async def storage_subsystem_mock(loop, mocker):
152150
"""
153-
Patches client calls to storage service
151+
Patches client calls to storage service
154152
155-
Patched functions are exposed within projects but call storage subsystem
153+
Patched functions are exposed within projects but call storage subsystem
156154
"""
157155
# requests storage to copy data
158156
mock = mocker.patch(

0 commit comments

Comments
 (0)