Skip to content

Commit

Permalink
Added github action to run a subset of tests (#7328)
Browse files Browse the repository at this point in the history
* Added github action to run a subset of tests

* SkipUnstableEmulators

* Fix pgweb test

* Try ci true

* Get the bin log

* Fix?

* ??

* Moar perms

* This?

* ContinuousIntegrationBuild

* Remove CIBuild property since this isn't running in AzDO

* Try using build.sh instead to restore arcade

* Remove from tests too

* Remove -ci

* create binlog to upload

* Try setting CI to false

* Fix

* Add missing projects parameter

* append githubworkspace to project path

* Add missing dollar sign

* Fix test step

* Skip Oracle tests that shouldn't run based on ActiveIssue

* Skipping Aspire.Hosting.Test

* Stop building all of the repo and try to fix test not being able to fetch basedirectory

* Debug Output for AzureFunctionsTest

* Enabling project reference which is currently disabled.

* Disable Azure Functions test from CI

* Disabling playground tests to investigate Azure Functions test

---------

Co-authored-by: Eric Erhardt <[email protected]>
Co-authored-by: Jose Perez Rodriguez <[email protected]>
  • Loading branch information
3 people authored Feb 1, 2025
1 parent e0079f9 commit d910655
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 7 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Run Integration Tests

on:
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- project: tests/Aspire.Hosting.Elasticsearch.Tests/Aspire.Hosting.Elasticsearch.Tests.csproj
name: Elasticsearch
- project: tests/Aspire.Hosting.PostgreSQL.Tests/Aspire.Hosting.PostgreSQL.Tests.csproj
name: PostgreSQL
- project: tests/Aspire.Hosting.Oracle.Tests/Aspire.Hosting.Oracle.Tests.csproj
name: Oracle
- project: tests/Aspire.Hosting.Kafka.Tests/Aspire.Hosting.Kafka.Tests.csproj
name: Kafka
- project: tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj
name: Hosting
- project: tests/Aspire.Hosting.Redis.Tests/Aspire.Hosting.Redis.Tests.csproj
name: Redis
- project: tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj
name: Azure
# - project: tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj
# name: Playground
# Add more projects as needed
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
9.x
- name: Trust HTTPS development certificate
run: dotnet dev-certs https --trust

- name: Verify Docker is running
run: docker info

- name: Install Azure Functions Core Tools
run: |
sudo apt-get update
sudo apt-get install -y azure-functions-core-tools-4
- name: Build test project
run: |
export CI=false && ./build.sh -restore -ci -build -projects ${{ github.workspace }}/${{ matrix.project }} /bl
- name: Run tests
id: run-tests
run: |
export CI=false && ./dotnet.sh test ${{ github.workspace }}/${{ matrix.project }} \
/p:ContinuousIntegrationBuild=true \
-s eng/testing/.runsettings \
--logger "console;verbosity=normal" \
--logger "trx" \
--logger html \
--blame \
--blame-hang-timeout 7m \
--results-directory testresults \
--no-restore \
--no-build
- name: Compress test results
if: always()
run: zip -r testresults.zip testresults

- name: Upload bin log artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: binlog-${{ matrix.name }}
path: "**/*.binlog"

- name: Upload test results artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: testresults-${{ matrix.name }}
path: testresults.zip
11 changes: 11 additions & 0 deletions src/Aspire.Hosting.PostgreSQL/PostgresBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ public static IResourceBuilder<PostgresServerResource> WithPgWeb(this IResourceB

pgwebContainerBuilder.WithRelationship(builder.Resource, "PgWeb");

pgwebContainerBuilder.WithHttpHealthCheck();

builder.ApplicationBuilder.Eventing.Subscribe<AfterEndpointsAllocatedEvent>(async (e, ct) =>
{
var adminResource = builder.ApplicationBuilder.Resources.OfType<PgWebContainerResource>().Single();
Expand All @@ -304,6 +306,15 @@ public static IResourceBuilder<PostgresServerResource> WithPgWeb(this IResourceB
Directory.CreateDirectory(serverFileMount.Source!);
}

if (!OperatingSystem.IsWindows())
{
var mode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute |
UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute |
UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.OtherExecute;

File.SetUnixFileMode(serverFileMount.Source!, mode);
}

foreach (var postgresDatabase in postgresInstances)
{
var user = postgresDatabase.Parent.UserNameParameter?.Value ?? "postgres";
Expand Down
8 changes: 4 additions & 4 deletions tests/Aspire.Hosting.Oracle.Tests/OracleFunctionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class OracleFunctionalTests(ITestOutputHelper testOutputHelper)

private const string DatabaseReadyText = "Completed: ALTER DATABASE OPEN";

[Fact]
[Fact(Skip = "https://github.com/dotnet/aspire/issues/5362")]
[RequiresDocker]
public async Task VerifyEfOracle()
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public async Task VerifyEfOracle()
Assert.Equal("BatMobile", cars[0].Brand);
}

[Theory]
[Theory(Skip = "https://github.com/dotnet/aspire/issues/5362")]
[InlineData(true)]
[InlineData(false, Skip = "https://github.com/dotnet/aspire/issues/5191")]
[RequiresDocker]
Expand Down Expand Up @@ -243,7 +243,7 @@ await pipeline.ExecuteAsync(async token =>
}
}

[Theory]
[Theory(Skip = "https://github.com/dotnet/aspire/issues/5362")]
[InlineData(true)]
[InlineData(false, Skip = "https://github.com/dotnet/aspire/issues/5190")]
[RequiresDocker]
Expand Down Expand Up @@ -346,7 +346,7 @@ await pipeline.ExecuteAsync(async token =>
}
}

[Fact]
[Fact(Skip = "https://github.com/dotnet/aspire/issues/5362")]
[RequiresDocker]
public async Task VerifyWaitForOnOracleBlocksDependentResources()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ public async Task VerifyWithPgWeb()

using var app = builder.Build();

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

await app.WaitForTextAsync("Starting server...", resourceName: pgWebBuilder.Resource.Name);
await app.StartAsync();

var client = app.CreateHttpClient(pgWebBuilder.Resource.Name, "http");

await resourceNotificationService.WaitForResourceHealthyAsync(pgWebBuilder.Resource.Name).DefaultTimeout(TestConstants.LongTimeoutTimeSpan);

var httpContent = new MultipartFormDataContent
{
{ new StringContent(dbName), "bookmark_id" }
Expand All @@ -177,6 +179,9 @@ public async Task VerifyWithPgWeb()

var response = await client.PostAsync("/api/connect", httpContent);
var d = await response.Content.ReadAsStringAsync();

testOutputHelper.WriteLine("RESPONSE: \r\n" + d);

response.EnsureSuccessStatusCode();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ await Assert.ThrowsAnyAsync<Exception>(async () =>
}).DefaultTimeout(TestConstants.DefaultOrchestratorTestTimeout);
}

[Fact]
[Fact(Skip = "https://github.com/dotnet/aspire/issues/4599")]
[ActiveIssue("https://github.com/dotnet/aspire/issues/4599", typeof(PlatformDetection), nameof(PlatformDetection.IsRunningOnCI))]
public async Task ProxylessAndProxiedEndpointBothWorkOnSameResource()
{
Expand Down

0 comments on commit d910655

Please sign in to comment.