Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
51 changes: 51 additions & 0 deletions docs/test-ghcr-tag-aspire/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#:sdk Aspire.AppHost.Sdk@13.4.0
#:package Particular.Aspire.Hosting.ServicePlatform@1.*
#:package Aspire.Hosting.RabbitMQ@13.4.0

using Aspire.Hosting;
using Particular.Aspire.Hosting.ServicePlatform.Transport;

var builder = DistributedApplication.CreateBuilder(args);

var transportUserName = builder.AddParameter("transportUserName", "guest", secret: true);
var transportPassword = builder.AddParameter("transportPassword", "guest", secret: true);

var transport = builder.AddRabbitMQ("transport", transportUserName, transportPassword)
.WithManagementPlugin(15672)
.WithUrlForEndpoint("management", url => url.DisplayText = "RabbitMQ Management");

builder
.AddParticularPlatform("particular")
.WithTransportRabbitMQ(RabbitMqRouting.QuorumConventionalRouting, transport)
.AddDefaultComponents();

//using positional param for now since there's only one
if (args.Length > 1)
{
UsePrereleaseImage(builder, args[1]);
} else {
Console.WriteLine("No arguments provided, defaulting to published 'latest' images'");
}
Comment thread
rbev marked this conversation as resolved.

var app = builder.Build();

await app.RunAsync();

static void UsePrereleaseImage(IDistributedApplicationBuilder builder, string tag)
{
Console.WriteLine($"Using prerelease image tag: {tag}");
foreach (var c in builder.Resources.OfType<ContainerResource>())
{
if (!c.TryGetLastAnnotation<ContainerImageAnnotation>(out var image))
{
continue;
}

if (image.Image.StartsWith("particular/servicecontrol"))
{
builder
.CreateResourceBuilder(c)
.WithImage($"ghcr.io/{image.Image}", tag);
}
}
}
5 changes: 5 additions & 0 deletions docs/test-ghcr-tag-aspire/aspire.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"appHost": {
"path": "AppHost.cs"
}
}
19 changes: 19 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,22 @@ Containers built by a PR and stored on GitHub Container Registry can be tested l
* [Monitoring API](http://localhost:33633)
* [ServicePulse (latest from Docker Hub)](http://localhost:9090)
6. Tear down services using `docker compose down`.


## Container tests using Aspire

The [Particular.Aspire.Hosting.ServicePlatform](https://github.com/Particular/Particular.Aspire.Hosting.ServicePlatform) package integrates the Particular Platform with the Aspire hosting platform. This package configures environment variables to attach the platform. There is a single file apphost in [`test-ghcr-tag-aspire`](/docs/test-ghcr-tag-aspire) to start up serviceconrol from a prerelease container image.

Containers built by a PR and stored on GitHub Container Registry can be tested locally:
Comment thread
rbev marked this conversation as resolved.

1. Set up your github container registry credentials as described in the [Container tests](#container-tests) section above.
2. Make sure you have the [Aspire CLI installed](https://aspire.dev/get-started/install-cli/).
3. Run `aspire run docs/test-ghcr-tag-aspire/AppHost.cs -- tag` to start the application, where `tag` is the PR-based tag (in the form `pr-####`) to test. If no tag is provided, it will default to the `latest` tag.
4. Once running you can open the dashboard from the link in the terminal, this dashboard will provide the assigned ports for each service.
* RabbitMQ Management (Login: `guest`/`guest`)
* RavenDB
* ServiceControl API
* Audit API
* Monitoring API
* ServicePulse (latest from Docker Hub)
5. Aspire will automatically tear down the application when you exit the CLI process.
Loading