MSS icon indicating copy to clipboard operation
MSS copied to clipboard

test_activate_operation_updates_active_users needs a review

Open ReimarBauer opened this issue 1 year ago • 9 comments

I see this sometimes on my local tests

[gw5] [100%] PASSED tests/_test_msui/test_mscolab.py::Test_Mscolab::test_activate_operation_updates_active_users 

Exception ignored in: <function WMSControlWidget.__del__ at 0x718a67ac9120>
Traceback (most recent call last):
  File "/home/reimar/MAIN/MSS/mslib/msui/wms_control.py", line 550, in __del__
    self.service_cache()
  File "/home/reimar/MAIN/MSS/mslib/msui/wms_control.py", line 1455, in service_cache
    files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] Datei oder Verzeichnis nicht gefunden: '/tmp/tmpnodr4uwv/msui/wms_cache/'

ReimarBauer avatar Oct 04 '24 05:10 ReimarBauer

happens also sometimes here https://github.com/Open-MSS/MSS/actions/runs/11200358961/job/31133900608?pr=2554#step:6:1165

ReimarBauer avatar Oct 06 '24 08:10 ReimarBauer

import os

class WMSControlWidget: def init(self, wms_cache): self.wms_cache = wms_cache os.makedirs(self.wms_cache, exist_ok=True) # Ensure the cache directory exists

def service_cache(self):
    if os.path.exists(self.wms_cache):
        files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)]
        # ... process files
    else:
        files = []  # Handle the case where the directory does not exist

def __del__(self):
    # Consider removing any critical logic here or checking for existence
    try:
        self.service_cache()
    except Exception as e:
        # Log the exception if necessary
        pass

Pavanbhagi avatar Oct 07 '24 16:10 Pavanbhagi

Not each test is failing. On production I don't have seen that problem. We need to investigate why in this order of tests the problem occures and likly improve a test.

ReimarBauer avatar Oct 08 '24 13:10 ReimarBauer

Hey @ReimarBauer , I could not reproduce the issue. Can you please help with this.

When I ran pytest test_mscolab.py I got these results Screenshot 2024-11-30 144816 Screenshot 2024-11-30 144842

Abhisek-exe avatar Nov 30 '24 09:11 Abhisek-exe

just a follow up mention @ReimarBauer can you look into this please!

Abhisek-exe avatar Dec 03 '24 07:12 Abhisek-exe

This error happens randomly in parallel testing. It is not easy to catch.

ReimarBauer avatar Dec 03 '24 08:12 ReimarBauer

Modify the service_cache method to check if the directory exists before trying to list its files.

import os

def service_cache(self): if os.path.exists(self.wms_cache) and os.path.isdir(self.wms_cache): files = [os.path.join(self.wms_cache, f) for f in os.listdir(self.wms_cache)] # proceed with your logic here else: print(f"Directory {self.wms_cache} does not exist.")

sagarrrr21 avatar Dec 06 '24 14:12 sagarrrr21

That is not the solution because the problem seems only to occure in the tests on parallel testing. I believe we need to find the test which is the reason for this.

ReimarBauer avatar Dec 08 '24 13:12 ReimarBauer

We have to set wms_cache https://github.com/Open-MSS/MSS/blob/stable/tests/_test_msui/test_wms_control.py#L500

similiar as here https://github.com/Open-MSS/MSS/blob/stable/tests/_test_msui/test_wms_control.py#L69

On the MBP I got today

Failed: An unhandled message box popped up during your test!
E       PyQt5.QtWidgets.QMessageBox.critical(): [call(<mslib.msui.wms_control.HSecWMSControlWidget object at 0x34be62950>, 'Web Map Service', "ERROR: Cannot delete file '/Users/reimarbauer/Library/Caches/msui/wms_cache/6a69a349092204e79ecfb3fabe12998a.png'. (<class 'FileNotFoundError'>: [Errno 2] No such file or directory: '/Users/reimarbauer/Library/Caches/msui/wms_cache/6a69a349092204e79ecfb3fabe12998a.png')")]

that looks like a test does not use a tmp dir. It is not clear yet if it is the same problem.

ReimarBauer avatar Apr 02 '25 18:04 ReimarBauer

it is maybe fixed by https://github.com/Open-MSS/MSS/pull/2829

reopen when not

ReimarBauer avatar Jul 18 '25 06:07 ReimarBauer