Skip to content

Commit

Permalink
Merge branch 'main' into swa-component
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpowell committed Aug 19, 2024
2 parents 8724d8a + 3eb45bd commit 4e1a307
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 9 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
DCP_PRESERVE_EXECUTABLE_LOGS: "yes"
DCP_DIAGNOSTICS_LOG_FOLDER: ${{ github.workspace }}/diagnostics

steps:
- uses: actions/checkout@v4
Expand All @@ -35,4 +38,10 @@ jobs:
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal

- name: Upload build artifact
uses: actions/upload-artifact@v3
if: failure()
with:
name: build-output
path: |
${{ github.workspace }}/diagnostics/**
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ obj
*.user
.azure
appsettings.*.json
*.orig
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<AspireVersion>8.0.2</AspireVersion>
<AspireVersion>8.1.0</AspireVersion>
<AspNetCoreVersion>8.0.7</AspNetCoreVersion>
<OpenTelemetryVersion>1.9.0</OpenTelemetryVersion>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<PackageVersion Include="Aspire.Hosting.Testing" Version="$(AspireVersion)" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.4.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="MartinCostello.Logging.XUnit" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
using System.Net;
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;

namespace CommunityToolkit.Aspire.Java.Hosting.EndToEndTests;

public class ProgramTests
public class ProgramTests(ITestOutputHelper testOutput)
{
[Fact(Skip = "Unable to run on CI. Waiting to find out how to get better diagnostics.")]
[Fact]
public async Task Given_Container_Resource_When_Invoked_Then_Root_Returns_OK()
{
// Arrange
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.CommunityToolkit_Aspire_Java_Hosting_EndToEndTests>();
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.CommunityToolkit_Aspire_Java_AppHost>();

appHost.Services
.AddLogging(builder =>
{
builder.AddXUnit(testOutput);
builder.SetMinimumLevel(LogLevel.Trace);
})
.ConfigureHttpClientDefaults(clientBuilder => clientBuilder.AddStandardResilienceHandler());

await using var app = await appHost.BuildAsync();
var resourceNotificationService = app.Services.GetRequiredService<ResourceNotificationService>();
await app.StartAsync();

// Act
var httpClient = app.CreateHttpClient("containerapp");

await Task.Delay(TimeSpan.FromSeconds(30));
await resourceNotificationService.WaitForResourceAsync("containerapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

var response = await httpClient.GetAsync("/");

// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Fact(Skip = "Unable to run on CI. Waiting to find out how to get better diagnostics.")]
[Fact]
public async Task Given_Executable_Resource_When_Invoked_Then_Root_Returns_OK()
{
// Arrange
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.CommunityToolkit_Aspire_Java_Hosting_EndToEndTests>();
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.CommunityToolkit_Aspire_Java_AppHost>();

appHost.Services
.AddLogging(builder =>
{
builder.AddXUnit(testOutput);
builder.SetMinimumLevel(LogLevel.Trace);
})
.ConfigureHttpClientDefaults(clientBuilder => clientBuilder.AddStandardResilienceHandler());

await using var app = await appHost.BuildAsync();
var resourceNotificationService = app.Services.GetRequiredService<ResourceNotificationService>();
await app.StartAsync();

// Act
var httpClient = app.CreateHttpClient("executableapp");

await Task.Delay(TimeSpan.FromSeconds(30));
await resourceNotificationService.WaitForResourceAsync("executableapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

var response = await httpClient.GetAsync("/");

Expand Down

0 comments on commit 4e1a307

Please sign in to comment.