AntaresSimulatorTeam / AntaREST

API REST and WebUI for Antares_Simulator
Apache License 2.0
12 stars 7 forks source link

TestStudyUpgrade.test_upgrade_study__target_version can fail on Windows #1416

Open MartinBelthle opened 1 year ago

MartinBelthle commented 1 year ago

Logs

self = <test_studies_upgrade.TestStudyUpgrade object at 0x000001878632F280> client = <starlette.testclient.TestClient object at 0x000001878684DD30> user_access_token = '***' study_id = '23b38929-7ee5-4e6d-b742-ddce53d3df4b'

def test_upgrade_study__target_version(
    self, client: TestClient, user_access_token: str, study_id: str
):
    target_version = "720"
    res = client.put(
        f"/v1/studies/{study_id}/upgrade",
        headers={"Authorization": f"***"},
        params={"target_version": target_version},
    )
    assert res.status_code == 200
    task_id = res.json()
    assert task_id
    task = wait_task_completion(client, user_access_token, task_id)
  assert task.status == TaskStatus.COMPLETED

E assert <TaskStatus.FAILED: 4> == <TaskStatus.COMPLETED: 3> E + where <TaskStatus.FAILED: 4> = TaskDTO(id='a7d626b3-bba6-4a24-8854-f3e4b45716da', name='Upgrade study STA-mini (23b38929-7ee5-4e6d-b742-ddce53d3df4b)... error traceback.", return_value=None), logs=None, type='UPGRADE_STUDY', ref_id='23b38929-7ee5-4e6d-b742-ddce53d3df4b').status E + and <TaskStatus.COMPLETED: 3> = TaskStatus.COMPLETED

------------------------------ Captured log call ------------------------------ INFO antarest.study.web.studies_blueprint:studies_blueprint.py:168 Upgrade study 23b38929-7ee5-4e6d-b742-ddce53d3df4b to the version 720 INFO antarest.core.tasks.service:service.py:368 Starting task a7d626b3-bba6-4a24-8854-f3e4b45716da INFO antarest.core.tasks.service:service.py:373 Task a7d626b3-bba6-4a24-8854-f3e4b45716da set to RUNNING ERROR antarest.core.tasks.service:service.py:405 Task a7d626b3-bba6-4a24-8854-f3e4b45716da failed: Unhandled exception [WinError 5] Access is denied: 'C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_upgrade_studytarget_ver0\ext_workspace\~goh6uui2.upgrade.tmp' -> 'C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_upgrade_studytarget_ver0\ext_workspace\STA-mini' Traceback (most recent call last): File "D:\a\AntaREST\AntaREST\antarest\core\tasks\service.py", line 376, in _run_task result = callback(self._task_logger(task_id)) File "D:\a\AntaREST\AntaREST\antarest\study\service.py", line 260, in run_task self._upgrade_study() File "D:\a\AntaREST\AntaREST\antarest\study\service.py", line 226, in _upgrade_study upgrade_study(study_path, target_version) File "D:\a\AntaREST\AntaREST\antarest\study\storage\study_upgrader__init.py", line 95, in upgrade_study tmp_dir.rename(study_path) File "c:\hostedtoolcache\windows\python\3.8.10\x64\lib\pathlib.py", line 1359, in rename self._accessor.rename(self, target) PermissionError: [WinError 5] Access is denied: 'C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_upgrade_studytarget_ver0\ext_workspace\~goh6uui2.upgrade.tmp' -> 'C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\test_upgrade_study__target_ver0\ext_workspace\STA-mini'

Possible explanation and solution:

The path could already be used by another thread therefore it is locked and .rename cannot have access to it

laurent-laporte-pro commented 1 year ago

Sous Windows, lorsque l'utilisateur fait un upgrade, il a des répertoires temporaires :

2023-04-05

Les trois répertoires sont les résultats des trois mises à niveau pour passer de la version v8.2 à v8.5