Skip to content

Commit

Permalink
tests: Fix test isolation on object storage
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Feb 9, 2023
1 parent 0b25e61 commit 6473d0d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/files_sharing/tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ protected static function loginHelper($user, $create = false, $password = false)
\OC::$server->getUserSession()->setUser(null);
\OC\Files\Filesystem::tearDown();
\OC::$server->getUserSession()->login($user, $password);
\OC::$server->getUserFolder($user);
// We need to get the directory listing to trigger the lazy user folder
// to create the files directory. Since the filecache might get cleared
// in the cache, any follow up test case may fail as with object storage
// the filecache represents the file structure
\OC::$server->getUserFolder($user)->getDirectoryListing();

\OC_Util::setupFS($user);
}
Expand Down
17 changes: 17 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,23 @@ public static function registerCleanupHooks(\OC\SystemConfig $systemConfig): voi
$throttler = Server::get(\OC\Security\Bruteforce\Throttler::class);
$throttler->resetDelay($request->getRemoteAddress(), 'login', ['user' => $uid]);
}

try {
$cache = new \OC\Cache\File();
$cache->gc();
} catch (\OC\ServerNotAvailableException $e) {
// not a GC exception, pass it on
throw $e;
} catch (\OC\ForbiddenException $e) {
// filesystem blocked for this request, ignore
} catch (\Exception $e) {
// a GC exception should not prevent users from using OC,
// so log the exception
Server::get(LoggerInterface::class)->warning('Exception when running cache gc.', [
'app' => 'core',
'exception' => $e,
]);
}
});
}
}
Expand Down

0 comments on commit 6473d0d

Please sign in to comment.