From 7f41b7a7f5dbf371e54dee54df62cd2644b90818 Mon Sep 17 00:00:00 2001 From: Alex <10480967+WakaToa@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:42:42 +0100 Subject: [PATCH 1/3] fix(CosmosDb): SSL connection could not be established (#1109) Co-authored-by: Alexander Zabel Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> --- .../CosmosDbBuilder.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs b/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs index b25393ab4..d40116625 100644 --- a/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs +++ b/src/Testcontainers.CosmosDb/CosmosDbBuilder.cs @@ -45,7 +45,7 @@ protected override CosmosDbBuilder Init() return base.Init() .WithImage(CosmosDbImage) .WithPortBinding(CosmosDbPort, true) - .WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Started\\r?\\n")); + .WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new WaitUntil())); } /// @@ -65,4 +65,33 @@ protected override CosmosDbBuilder Merge(CosmosDbConfiguration oldValue, CosmosD { return new CosmosDbBuilder(new CosmosDbConfiguration(oldValue, newValue)); } + + /// + private sealed class WaitUntil : IWaitUntil + { + /// + public async Task UntilAsync(IContainer container) + { + // CosmosDB's preconfigured HTTP client will redirect the request to the container. + const string requestUri = "https://localhost/_explorer/emulator.pem"; + + var httpClient = ((CosmosDbContainer)container).HttpClient; + + try + { + using var httpResponse = await httpClient.GetAsync(requestUri) + .ConfigureAwait(false); + + return httpResponse.IsSuccessStatusCode; + } + catch (Exception) + { + return false; + } + finally + { + httpClient.Dispose(); + } + } + } } \ No newline at end of file From 9764f337f59f8b938ce1cd77b2d3e77ed8fd94e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Sat, 10 Feb 2024 20:19:39 +0100 Subject: [PATCH 2/3] chore: Add Test Reporter GitHub Action (#1095) Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> --- .github/workflows/cicd.yml | 1 + .github/workflows/test-report.yml | 30 ++++++++++++++++++++++++++++++ build.cake | 1 - tests/Directory.Build.props | 3 +++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test-report.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 345faeea0..0f209beac 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -80,6 +80,7 @@ jobs: - name: Upload Test And Coverage Results uses: actions/upload-artifact@v4 + if: true with: name: ${{ matrix.os }} path: test-results diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 000000000..34aa448e6 --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,30 @@ +name: Test Report + +on: + workflow_run: + workflows: ['Continuous Integration & Delivery'] + types: + - completed + +jobs: + report: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-22.04, windows-2022 ] + + runs-on: ubuntu-22.04 + + permissions: + actions: read + checks: write + contents: read + + steps: + - name: Publish '${{ matrix.os }}' Test Report + uses: dorny/test-reporter@v1 + with: + artifact: ${{ matrix.os }} + name: ${{ matrix.os }} + path: '*.trx' + reporter: dotnet-trx diff --git a/build.cake b/build.cake index bf3673349..1d2e4aea2 100644 --- a/build.cake +++ b/build.cake @@ -80,7 +80,6 @@ Task("Tests") NoRestore = true, NoBuild = true, Collectors = new[] { "XPlat Code Coverage;Format=opencover" }, - Loggers = new[] { "trx" }, Filter = param.TestFilter, ResultsDirectory = param.Paths.Directories.TestResultsDirectoryPath, ArgumentCustomization = args => args diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 0fd5ad84a..d2f5aaa24 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -4,4 +4,7 @@ false + + trx%3BLogFileName=$(MSBuildProjectName).trx + \ No newline at end of file From d0cd643c4584a5dc6f5c94c1c1a09e41817130ce Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Sat, 10 Feb 2024 21:04:50 +0100 Subject: [PATCH 3/3] fix: Upload pipeline artifacts with v3 task --- .github/workflows/cicd.yml | 9 +++++++++ .github/workflows/test-report.yml | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0f209beac..4d88fe157 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -78,6 +78,15 @@ jobs: - name: Run Tests run: dotnet cake --target=Tests --test-filter=${{ startsWith(matrix.os, 'ubuntu') && 'FullyQualifiedName~Testcontainers' || 'DockerPlatform=Windows' }} + # The Test Reporter GH Action is not yet compatible with the recent + # actions/upload-artifact updates: https://github.com/dorny/test-reporter/issues/363. + - name: Upload Test And Coverage Results + uses: actions/upload-artifact@v3 + if: true + with: + name: ${{ matrix.os }}-v3 + path: test-results + - name: Upload Test And Coverage Results uses: actions/upload-artifact@v4 if: true diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index 34aa448e6..8a4b767c4 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [ ubuntu-22.04, windows-2022 ] - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.os }} permissions: actions: read @@ -21,10 +21,10 @@ jobs: contents: read steps: - - name: Publish '${{ matrix.os }}' Test Report - uses: dorny/test-reporter@v1 + - name: Publish Test Report + uses: dorny/test-reporter@v1.8.0 with: - artifact: ${{ matrix.os }} + artifact: ${{ matrix.os }}-v3 name: ${{ matrix.os }} path: '*.trx' reporter: dotnet-trx