Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functional tests for PgAdmin and RedisCommander. #5511

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/Aspire.Hosting.PostgreSQL.Tests/PostgresFunctionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Data;
using System.Net;
using Aspire.Components.Common.Tests;
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Postgres;
using Aspire.Hosting.Testing;
using Aspire.Hosting.Tests.Utils;
using Aspire.Hosting.Utils;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -138,6 +141,30 @@ public async Task VerifyWaitForOnPostgresDatabaseBlocksDependentResources()
await app.StopAsync();
}

[Fact]
[RequiresDocker]
public async Task VerifyPgAdminResource()
{
using var builder = TestDistributedApplicationBuilder.CreateWithTestContainerRegistry(testOutputHelper);

IResourceBuilder<PgAdminContainerResource>? adminBuilder = null;
var redis = builder.AddPostgres("postgres").WithPgAdmin(c => adminBuilder = c);
Assert.NotNull(adminBuilder);

using var app = builder.Build();

await app.StartAsync();

await app.WaitForTextAsync("Listening at", resourceName: adminBuilder.Resource.Name);

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

var endpoint = redis.GetEndpoint("tcp");
davidfowl marked this conversation as resolved.
Show resolved Hide resolved
davidfowl marked this conversation as resolved.
Show resolved Hide resolved
var path = $"/";
var response = await client.GetAsync(path);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
[RequiresDocker]
public async Task VerifyPostgresResource()
Expand Down
27 changes: 27 additions & 0 deletions tests/Aspire.Hosting.Redis.Tests/RedisFunctionalTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Net;
using Aspire.Components.Common.Tests;
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Testing;
using Aspire.Hosting.Tests.Utils;
using Aspire.Hosting.Utils;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -67,6 +70,30 @@ public async Task VerifyWaitForOnRedisBlocksDependentResources()
await app.StopAsync();
}

[Fact]
[RequiresDocker]
public async Task VerifyRedisCommanderResource()
{
using var builder = TestDistributedApplicationBuilder.CreateWithTestContainerRegistry(testOutputHelper);

IResourceBuilder<RedisCommanderResource>? commanderBuilder = null;
var redis = builder.AddRedis("redis").WithRedisCommander(c => commanderBuilder = c);
Assert.NotNull(commanderBuilder);

using var app = builder.Build();

await app.StartAsync();

await app.WaitForTextAsync("Redis Connection", resourceName: commanderBuilder.Resource.Name);

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

var endpoint = redis.GetEndpoint("tcp");
var path = $"/apiv2/server/R:{endpoint.ContainerHost}:{endpoint.Port}:0/info";
davidfowl marked this conversation as resolved.
Show resolved Hide resolved
var response = await client.GetAsync(path);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

[Fact]
[RequiresDocker]
public async Task VerifyRedisResource()
Expand Down
Loading