From 5838d61b131389d9dd660e8ed810becafe701969 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 1 May 2024 16:57:21 +0200 Subject: [PATCH] test: retry smb notify test a few times Signed-off-by: Robin Appelman --- apps/files_external/tests/Storage/SmbTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php index 30040e499c89b..d700f676b75e9 100644 --- a/apps/files_external/tests/Storage/SmbTest.php +++ b/apps/files_external/tests/Storage/SmbTest.php @@ -33,6 +33,7 @@ use OC\Files\Notify\RenameChange; use OCA\Files_External\Lib\Storage\SMB; use OCP\Files\Notify\IChange; +use PHPUnit\Framework\ExpectationFailedException; /** * Class SmbTest @@ -96,6 +97,22 @@ public function testStorageId() { } public function testNotifyGetChanges() { + $lastError = null; + for($i = 0; $i < 5; $i++) { + try { + $this->tryTestNotifyGetChanges(); + return; + } catch (ExpectationFailedException $e) { + $lastError = $e; + $this->tearDown(); + $this->setUp(); + sleep(1); + } + } + throw $lastError; + } + + private function tryTestNotifyGetChanges(): void { $notifyHandler = $this->instance->notify(''); sleep(1); //give time for the notify to start $this->instance->file_put_contents('/newfile.txt', 'test content');