Open eddumelendez opened 5 months ago
I like the idea of bridging test containers as a custom resource type but I don't think we should aim to unify the API. Something like:
builder.AddTestContainerResource("name", () =>
{
return new RedisBuilder().WithImage("redis:7.0").Build();
});
Would need to give some more thought to how connection strings etc work in this mode.
Also, by looking at the issues, some of them are already handled by Testcontainers. For example:
That's great but I'm not sure we need to lean on test containers here, the resource model is pretty capable 😄. I'm looking forward to an experiment in this space to see what comes out!
Thanks for the issue!
fyi, I'm using test containers here not as a test, but for dev only : https://github.com/InfinityFlowApp/aspire-temporal/blob/main/src/InfinityFlow.Aspire.Temporal/TemporalServerContainerBuilderExtensions.cs#L31-L70
(yes, i later learned you can use temporal-admin
image which has temporal-cli
and many other things)
I do agree having a resource that can "speak test container" natively would be awesome.
Unrelated: @ElanHasson if you want to make your resource plug in a little more cleanly, you can write an IDistributedApplicationLifecycleHook that uses test containers to build container image.
This might be a very nice integration point between aspire and test containers.
I'm in big support for this issue, because it solves the problem of any custom integration (I was thinking about support for https://zitadel.com/ as IDP)
Hi, I landed in the project by looking at this issue to support Testcontainers for component tests.
I currently see this is how resources are provisioned:
For Redis container:
For Azure Redis:
Proposal
Provide an API to provide specific Resource definitions, let's say
AspireResource
. For the Redis example, it can use AzureRedisExtensions or Testcontainers Redis module. The API can be also used in case there are other ways to provision a Redis instance, so, developers can write their own implementation.For Testcontainers Redis:
where
TestcontainersAspireResource
will start the container.For Azure Redis:
Benefits
Also, by looking at the issues, some of them are already handled by Testcontainers. For example:
3052
PGvector is compatible with current Testcontainers PostgreSQL implementation. For more info can look at the module https://testcontainers.com/modules/pgvector/
2899
Ryuk is Testcontainers resource reaper, which is in charge of cleanup resources when the process is done.
1326
Keycloack also has a Testcontainers implementation https://testcontainers.com/modules/keycloak/
2247
Use RabbitMQ module with reuse functionality could help https://testcontainers.com/modules/rabbitmq/
2116
By using the Generic API users can enable it without waiting for this feature
All Testcontainers .NET are listed in the module catalog.
If there is no specific module the Testcontainers API is very fluent and allow the user to write their own definition.
References
In the Java world, this integration has been done in the three major frameworks (Quarkus devservices, Micronaut test-resources, Spring Boot service connection). I would be very happy to chat and share more about it in order to find a similar experience in .NET ecosystem with Aspire.