Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Restructure tests into their own shards to speed up parallel execution (#233)

Leendert de Borstd471a61fbf15
diff --git a/.github/workflows/dotnet-e2e-client-tests.yml b/.github/workflows/dotnet-e2e-client-tests.yml
index 13b0d8ac7..c2a34e7e2 100644
--- a/.github/workflows/dotnet-e2e-client-tests.yml
+++ b/.github/workflows/dotnet-e2e-client-tests.yml
@@ -1,4 +1,4 @@
-name: .NET E2E Client Tests (Playwright)
+name: .NET E2E Client Tests (Playwright with Sharding)
on:
push:
@@ -10,6 +10,10 @@ jobs:
client-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ shard: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v4
@@ -27,16 +31,32 @@ jobs:
- name: Ensure browsers are installed
run: pwsh src/Tests/AliasVault.E2ETests/bin/Debug/net8.0/playwright.ps1 install --with-deps
- - name: Run ClientTests with retry
+ - name: Run ClientTests with retry (Shard ${{ matrix.shard }})
uses: nick-fields/retry@v3
with:
timeout_minutes: 60
max_attempts: 3
- command: dotnet test src/Tests/AliasVault.E2ETests --no-build --verbosity normal --filter "Category=ClientTests"
+ command: dotnet test src/Tests/AliasVault.E2ETests --no-build --verbosity normal --filter "FullyQualifiedName~.ClientTests.Shard${{ matrix.shard }}."
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
- name: client-test-results
- path: TestResults-Client.xml
+ name: client-test-results-shard-${{ matrix.shard }}
+ path: TestResults-Client-Shard-${{ matrix.shard }}.xml
+
+ publish-test-results:
+ name: "Publish Test Results"
+ needs: client-tests
+ runs-on: ubuntu-latest
+ if: always()
+ steps:
+ - name: Download Artifacts
+ uses: actions/download-artifact@v3
+ with:
+ path: artifacts
+
+ - name: Publish Test Results
+ uses: EnricoMi/publish-unit-test-result-action@v2
+ with:
+ nunit_files: "artifacts/**/*.xml"
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/README.md b/src/Tests/AliasVault.E2ETests/Tests/Client/README.md
new file mode 100644
index 000000000..3c509f7ca
--- /dev/null
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/README.md
@@ -0,0 +1,25 @@
+# Client Tests
+This folder contains tests separated in their own "Shard" folder.
+
+During CI/CD pipeline, each shard (and all tests assigned to it) executed in a separate VM.
+This is done to speed up the execution of the tests.
+
+When adding new tests, you can add them to an existing shard or create a new shard.
+
+## Creating a new shard
+To create a new shard, follow these steps:
+
+1. Create a new folder in the `Tests` folder with the name of the shard. E.g. `Shard5`.
+2. Change GitHub Actions workflow file for client tests:
+ 1. Open the file `.github/workflows/dotnet-e2e-client-tests.yml`.
+ 2. Find the `strategy` section. Add a new shard to the `matrix` section. E.g. when adding shard 5 update the line to the following:
+ ```
+ matrix:
+ shard: [1, 2, 3, 4, 5]
+ ```
+3. The GitHub actions looks at the namespace of each test to know in what shard they should be executed in. Since the
+ tests are placed in a folder with the shard name, the namespace should already be correct. However if there
+ are any issues, verify that the namespace of the test is correct. E.g. for shard 5 the namespace of the test class should be:
+```
+namespace AliasVault.E2ETests.Tests.Client.Shard5;
+```
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/ApiLoggingTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/ApiLoggingTests.cs
similarity index 97%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/ApiLoggingTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/ApiLoggingTests.cs
index cc312b0f7..d33995180 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/ApiLoggingTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/ApiLoggingTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard1;
using Microsoft.EntityFrameworkCore;
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/CredentialTests.cs
similarity index 99%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/CredentialTests.cs
index f97f5c34f..0c16a2122 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/CredentialTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard1;
/// <summary>
/// End-to-end tests for the credential management.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/EmailDecryptionTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/EmailDecryptionTests.cs
similarity index 99%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/EmailDecryptionTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/EmailDecryptionTests.cs
index 61f982c8b..bcc83b981 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/EmailDecryptionTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/EmailDecryptionTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard1;
using AliasVault.IntegrationTests.SmtpServer;
using MailKit.Net.Smtp;
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/GeneralSettingsTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/GeneralSettingsTests.cs
similarity index 97%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/GeneralSettingsTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/GeneralSettingsTests.cs
index 832f736c9..9e1535715 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/GeneralSettingsTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/GeneralSettingsTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard1;
/// <summary>
/// End-to-end tests for general settings.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/JwtTokenTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/JwtTokenTests.cs
similarity index 98%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/JwtTokenTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/JwtTokenTests.cs
index c34ca205c..381205530 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/JwtTokenTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/JwtTokenTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard1;
/// <summary>
/// End-to-end tests for JWT token handling.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/SearchTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/SearchTests.cs
similarity index 97%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/SearchTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/SearchTests.cs
index 2fa22c4d3..b96418e36 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/SearchTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/SearchTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard1;
/// <summary>
/// End-to-end tests for searching.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbCleanupTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbCleanupTests.cs
similarity index 97%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/DbCleanupTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbCleanupTests.cs
index 81462cab0..53e9c0689 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbCleanupTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbCleanupTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard2;
/// <summary>
/// End-to-end tests for the client database persistence.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbPersistTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbPersistTests.cs
similarity index 98%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/DbPersistTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbPersistTests.cs
index 92b320697..5e8824f75 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbPersistTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbPersistTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard2;
using Microsoft.EntityFrameworkCore;
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbSyncTests.cs
similarity index 99%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbSyncTests.cs
index f3dd1568d..b0bd1015e 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbSyncTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard2;
using Microsoft.EntityFrameworkCore;
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbUpgradeTests.cs
similarity index 98%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbUpgradeTests.cs
index daf194ba8..bf3920b1d 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbUpgradeTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard2;
using AliasServerDb;
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/Abstracts/TwoFactorAuthBase.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/Abstracts/TwoFactorAuthBase.cs
similarity index 98%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/Abstracts/TwoFactorAuthBase.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/Abstracts/TwoFactorAuthBase.cs
index eb5abed41..6852b90b9 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/Abstracts/TwoFactorAuthBase.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/Abstracts/TwoFactorAuthBase.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client.TwoFactorAuth.Abstracts;
+namespace AliasVault.E2ETests.Tests.Client.Shard3.Abstracts;
/// <summary>
/// Abstract base class for two factor auth test which contains common methods.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/CodeLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs
similarity index 95%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/CodeLockoutTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs
index 6cf583962..ffd3a6dbc 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/CodeLockoutTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs
@@ -5,9 +5,9 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client.TwoFactorAuth;
+namespace AliasVault.E2ETests.Tests.Client.Shard3;
-using AliasVault.E2ETests.Tests.Client.TwoFactorAuth.Abstracts;
+using AliasVault.E2ETests.Tests.Client.Shard3.Abstracts;
/// <summary>
/// End-to-end tests for user two-factor authentication code lockout behavior.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/RecoveryLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/RecoveryLockoutTests.cs
similarity index 95%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/RecoveryLockoutTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/RecoveryLockoutTests.cs
index 4f91a4270..3e16197ad 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/RecoveryLockoutTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/RecoveryLockoutTests.cs
@@ -5,9 +5,9 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client.TwoFactorAuth;
+namespace AliasVault.E2ETests.Tests.Client.Shard3;
-using AliasVault.E2ETests.Tests.Client.TwoFactorAuth.Abstracts;
+using AliasVault.E2ETests.Tests.Client.Shard3.Abstracts;
/// <summary>
/// End-to-end tests for user two-factor authentication recovery code lockout behavior.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/TwoFactorAuthTests.cs
similarity index 97%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/TwoFactorAuthTests.cs
index 876a4b941..4a49727ba 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/TwoFactorAuth/TwoFactorAuthTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/TwoFactorAuthTests.cs
@@ -5,9 +5,9 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client.TwoFactorAuth;
+namespace AliasVault.E2ETests.Tests.Client.Shard3;
-using AliasVault.E2ETests.Tests.Client.TwoFactorAuth.Abstracts;
+using AliasVault.E2ETests.Tests.Client.Shard3.Abstracts;
/// <summary>
/// End-to-end tests for user two-factor authentication.
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/AuthTests.cs
similarity index 99%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/AuthTests.cs
index 321ddb85e..d815acc42 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/AuthTests.cs
@@ -5,7 +5,7 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard4;
using AliasVault.Shared.Models.Enums;
using Microsoft.EntityFrameworkCore;
@@ -15,6 +15,7 @@ using Microsoft.EntityFrameworkCore;
/// </summary>
[Parallelizable(ParallelScope.Self)]
[Category("ClientTests")]
+
[TestFixture]
public class AuthTests : ClientPlaywrightTest
{
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/AuthPasswordChangeTest.cs
similarity index 98%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/AuthPasswordChangeTest.cs
index e78d22a44..be2e207c0 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/AuthPasswordChangeTest.cs
@@ -5,13 +5,14 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.E2ETests.Tests.Client;
+namespace AliasVault.E2ETests.Tests.Client.Shard5;
/// <summary>
/// End-to-end tests for authentication.
/// </summary>
[Parallelizable(ParallelScope.Self)]
[Category("ClientTests")]
+
[TestFixture]
public class AuthPasswordChangeTest : ClientPlaywrightTest
{
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/UnlockTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/UnlockTests.cs
similarity index 100%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/UnlockTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/UnlockTests.cs