From f7d0bce08e564daec8c4177d2ce2e1bbbdae2d14 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Tue, 26 Jul 2022 12:38:37 -0600 Subject: [PATCH 1/2] Fix EncryptDecrypt test --- .../System.IO.FileSystem/tests/File/EncryptDecrypt.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs b/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs index 0c70a0406678cb..e864f6b9225819 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs @@ -71,7 +71,14 @@ public void EncryptDecrypt_Read() Assert.Equal(fileContentRead, File.ReadAllText(tmpFileName)); Assert.Equal(FileAttributes.Encrypted, (FileAttributes.Encrypted & File.GetAttributes(tmpFileName))); - File.Decrypt(tmpFileName); + // Sometimes Decrypt will fail with, eg., + // System.IO.IOException : The process cannot access the file '...' because it is being used by another process. + // Assumption is that it just needs a little more time + RetryHelper.Execute(() => + { + File.Decrypt(tmpFileName); + }, maxAttempts: 5, backoffFunc: null, retryWhen: e => e.GetType() == typeof(IOException)); + Assert.Equal(fileContentRead, File.ReadAllText(tmpFileName)); Assert.NotEqual(FileAttributes.Encrypted, (FileAttributes.Encrypted & File.GetAttributes(tmpFileName))); } From a193f79546f530f791b9720e94130cf32ca5fee5 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Tue, 26 Jul 2022 12:41:44 -0600 Subject: [PATCH 2/2] more retries --- src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs b/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs index e864f6b9225819..8aa5f73acb0bf9 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/EncryptDecrypt.cs @@ -77,7 +77,7 @@ public void EncryptDecrypt_Read() RetryHelper.Execute(() => { File.Decrypt(tmpFileName); - }, maxAttempts: 5, backoffFunc: null, retryWhen: e => e.GetType() == typeof(IOException)); + }, maxAttempts: 30, backoffFunc: null, retryWhen: e => e.GetType() == typeof(IOException)); Assert.Equal(fileContentRead, File.ReadAllText(tmpFileName)); Assert.NotEqual(FileAttributes.Encrypted, (FileAttributes.Encrypted & File.GetAttributes(tmpFileName)));