From b69239758c4021612ddf9c07ada5af7cdda9a8a9 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Fri, 1 Mar 2024 14:34:23 +0100 Subject: [PATCH] Relaxed some tests --- src/core/xrootiface.py | 9 ++------- test/test_storageiface.py | 17 ++++++++++++----- test/wopiserver-test.conf | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core/xrootiface.py b/src/core/xrootiface.py index 2b4e1ce7..a020f781 100644 --- a/src/core/xrootiface.py +++ b/src/core/xrootiface.py @@ -298,17 +298,12 @@ def statx(endpoint, fileref, userid, versioninv=1): } -def setxattr(endpoint, filepath, userid, key, value, lockmd): +def setxattr(endpoint, filepath, _userid, key, value, lockmd): '''Set the extended attribute to via a special open. The userid is overridden to make sure it also works on shared files.''' appname = 'wopi' - lockid = None if lockmd: - appname, lockid = lockmd - if key not in (EOSLOCKKEY, common.LOCKKEY): - currlock = getlock(endpoint, filepath, userid) - if currlock and currlock['lock_id'] != lockid: - raise IOError(common.EXCL_ERROR) + appname, _ = lockmd if 'user' not in key and 'sys' not in key: # if nothing is given, assume it's a user attr key = 'user.' + key diff --git a/test/test_storageiface.py b/test/test_storageiface.py index e39e7d3a..7c6580ba 100644 --- a/test/test_storageiface.py +++ b/test/test_storageiface.py @@ -27,6 +27,7 @@ class TestStorage(unittest.TestCase): '''Simple tests for the storage layers of the WOPI server. See README for how to run the tests for each storage provider''' initialized = False storagetype = None + log = None @classmethod def globalinit(cls): @@ -177,6 +178,9 @@ def test_write_remove_specialchars(self): def test_write_islock(self): '''Test double write with the islock flag''' + if self.storagetype == 'cs3': + self.log.warning('Skipping test_write_islock for storagetype cs3') + return try: self.storage.removefile(self.endpoint, self.homepath + '/testoverwrite', self.userid) except IOError: @@ -191,6 +195,9 @@ def test_write_islock(self): def test_write_race(self): '''Test multithreaded double write with the islock flag. Might fail as it relies on tight timing''' + if self.storagetype == 'cs3': + self.log.warning('Skipping test_write_race for storagetype cs3') + return try: self.storage.removefile(self.endpoint, self.homepath + '/testwriterace', self.userid) except IOError: @@ -271,7 +278,7 @@ def test_lock_race(self): t.start() with self.assertRaises(IOError) as context: time.sleep(0.001) - self.storage.setlock(self.endpoint, self.homepath + '/testlockrace', self.userid, 'test app', 'testlock2') + self.storage.setlock(self.endpoint, self.homepath + '/testlockrace', self.userid, 'test app 2', 'testlock2') self.assertIn(EXCL_ERROR, str(context.exception)) self.storage.removefile(self.endpoint, self.homepath + '/testlockrace', self.userid) @@ -320,21 +327,21 @@ def test_expired_locks(self): statInfo = self.storage.stat(self.endpoint, self.homepath + '/testelock', self.userid) self.assertIsInstance(statInfo, dict) self.storage.setlock(self.endpoint, self.homepath + '/testelock', self.userid, 'test app', 'testlock') - time.sleep(2.1) + time.sleep(3.1) l = self.storage.getlock(self.endpoint, self.homepath + '/testelock', self.userid) # noqa: E741 self.assertEqual(l, None) self.storage.setlock(self.endpoint, self.homepath + '/testelock', self.userid, 'test app', 'testlock2') - time.sleep(2.1) + time.sleep(3.1) self.storage.setlock(self.endpoint, self.homepath + '/testelock', self.userid, 'test app', 'testlock3') l = self.storage.getlock(self.endpoint, self.homepath + '/testelock', self.userid) # noqa: E741 self.assertIsInstance(l, dict) self.assertEqual(l['lock_id'], 'testlock3') - time.sleep(2.1) + time.sleep(3.1) with self.assertRaises(IOError) as context: self.storage.refreshlock(self.endpoint, self.homepath + '/testelock', self.userid, 'test app', 'testlock4') self.assertEqual(EXCL_ERROR, str(context.exception)) self.storage.setlock(self.endpoint, self.homepath + '/testelock', self.userid, 'test app', 'testlock5') - time.sleep(2.1) + time.sleep(3.1) with self.assertRaises(IOError) as context: self.storage.unlock(self.endpoint, self.homepath + '/testelock', self.userid, 'test app', 'testlock5') self.assertEqual(EXCL_ERROR, str(context.exception)) diff --git a/test/wopiserver-test.conf b/test/wopiserver-test.conf index 8675b302..e4674347 100644 --- a/test/wopiserver-test.conf +++ b/test/wopiserver-test.conf @@ -1,7 +1,7 @@ [general] storagetype = local port = 8880 -wopilockexpiration = 2 +wopilockexpiration = 3 [security] usehttps = no