Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/set-create…
Browse files Browse the repository at this point in the history
…d-started-stopped-container-timestamp-pass-wait-strategy
  • Loading branch information
HofmeisterAn committed Feb 10, 2024
2 parents 727e35a + d0cd643 commit 8eddcac
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,18 @@ 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
with:
name: ${{ matrix.os }}
path: test-results
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -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: ${{ matrix.os }}

permissions:
actions: read
checks: write
contents: read

steps:
- name: Publish Test Report
uses: dorny/[email protected]
with:
artifact: ${{ matrix.os }}-v3
name: ${{ matrix.os }}
path: '*.trx'
reporter: dotnet-trx
1 change: 0 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 30 additions & 1 deletion src/Testcontainers.CosmosDb/CosmosDbBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}

/// <inheritdoc />
Expand All @@ -65,4 +65,33 @@ protected override CosmosDbBuilder Merge(CosmosDbConfiguration oldValue, CosmosD
{
return new CosmosDbBuilder(new CosmosDbConfiguration(oldValue, newValue));
}

/// <inheritdoc cref="IWaitUntil" />
private sealed class WaitUntil : IWaitUntil
{
/// <inheritdoc />
public async Task<bool> 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();
}
}
}
}
3 changes: 3 additions & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<VSTestLogger>trx%3BLogFileName=$(MSBuildProjectName).trx</VSTestLogger>
</PropertyGroup>
</Project>

0 comments on commit 8eddcac

Please sign in to comment.