-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract Aspire.Hosting.Garnet.Tests project (#4871)
* extract Aspire.Hosting.Garnet.Tests project * Remove Garnet from Hosting and EndToEnd tests. --------- Co-authored-by: Eric Erhardt <[email protected]>
- Loading branch information
Showing
14 changed files
with
101 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/Aspire.Hosting.Garnet.Tests/Aspire.Hosting.Garnet.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(NetCurrent)</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Aspire.Hosting.AppHost\Aspire.Hosting.AppHost.csproj" /> | ||
<ProjectReference Include="..\..\src\Aspire.Hosting.Garnet\Aspire.Hosting.Garnet.csproj" /> | ||
<ProjectReference Include="..\..\src\Components\Aspire.StackExchange.Redis\Aspire.StackExchange.Redis.csproj" /> | ||
<ProjectReference Include="..\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj" /> | ||
|
||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="$(RepoRoot)src\Aspire.Hosting.Garnet\GarnetContainerImageTags.cs" /> | ||
<Compile Include="$(SharedDir)VolumeNameGenerator.cs" Link="Utils\VolumeNameGenerator.cs" /> | ||
</ItemGroup> | ||
|
||
</Project> |
70 changes: 70 additions & 0 deletions
70
tests/Aspire.Hosting.Garnet.Tests/GarnetFunctionalTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Aspire.Components.Common.Tests; | ||
using Aspire.Hosting.Utils; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Polly; | ||
using StackExchange.Redis; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Aspire.Hosting.Garnet.Tests; | ||
|
||
public class GarnetFunctionalTests(ITestOutputHelper testOutputHelper) | ||
{ | ||
[Fact] | ||
[RequiresDocker] | ||
public async Task VerifyGarnetResource() | ||
{ | ||
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5)); | ||
var pipeline = new ResiliencePipelineBuilder() | ||
.AddRetry(new() { MaxRetryAttempts = 10, Delay = TimeSpan.FromSeconds(3) }) | ||
.Build(); | ||
|
||
var builder = CreateDistributedApplicationBuilder(); | ||
|
||
var garnet = builder.AddGarnet("garnet"); | ||
|
||
using var app = builder.Build(); | ||
|
||
await app.StartAsync(); | ||
|
||
var hb = Host.CreateApplicationBuilder(); | ||
|
||
hb.Configuration.AddInMemoryCollection(new Dictionary<string, string?> | ||
{ | ||
[$"ConnectionStrings:{garnet.Resource.Name}"] = await garnet.Resource.ConnectionStringExpression.GetValueAsync(default) | ||
}); | ||
|
||
hb.AddRedisClient(garnet.Resource.Name); | ||
|
||
using var host = hb.Build(); | ||
|
||
await host.StartAsync(); | ||
|
||
var redisClient = host.Services.GetRequiredService<IConnectionMultiplexer>(); | ||
|
||
await pipeline.ExecuteAsync(async token => | ||
{ | ||
var db = redisClient.GetDatabase(); | ||
|
||
await db.StringSetAsync("key", "value"); | ||
|
||
var value = await db.StringGetAsync("key"); | ||
|
||
Assert.Equal("value", value); | ||
|
||
}, cts.Token); | ||
} | ||
|
||
private TestDistributedApplicationBuilder CreateDistributedApplicationBuilder() | ||
{ | ||
var builder = TestDistributedApplicationBuilder.Create(); | ||
builder.Services.AddXunitLogging(testOutputHelper); | ||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
tests/testproject/TestProject.IntegrationServiceA/Garnet/GarnetExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters