-
Notifications
You must be signed in to change notification settings - Fork 816
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have a test in 9.5, in which I needed to run an in memory server on a port, and make sure a dependency connects to it. (Specifically the otel connector)
After upgrading to 13.0, the endpoint is not being resolved correctly, and rather than failing, is ending up with an empty host and port http://:.
Whilst this could be a problem with my test code, it does feel like WithEnvironment() should never be able to resolve with an empty port/host, so maybe something else is wrong.
Expected Behavior
The reference should contain the port & host from the allocated endpoint.
But even more so, I wouldn't expect the final environment value to end up with missing host or port - I'd expect some kind of error to be thrown if either of these evaluated to null/empty.
Steps To Reproduce
[Test]
public async Task test()
{
var builder = DistributedApplicationTestingBuilder.Create();
var dependency = builder
.AddResource(new FakeResource())
.WithHttpEndpoint();
var consumer = builder
.AddContainer("test", "redis")
.WithImageRegistry("docker.io")
.WithReference(dependency.GetEndpoint("http"));
var endpointAnnotation = dependency.Resource.Annotations.OfType<EndpointAnnotation>().Single();
endpointAnnotation.AllocatedEndpoint = new AllocatedEndpoint(endpointAnnotation, "localhost", 1234);
using var app = builder.Build();
await app.StartAsync();
var envVars = await consumer.Resource.GetEnvironmentVariableValuesAsync();
Assert.That(envVars["services__fake__http__0"], Is.EqualTo("http://localhost:1234"));
// Actual: `http://:`
}
public class FakeResource() : Resource("fake"), IResourceWithEndpoints { }Exceptions (if any)
Assert.That(envVars["services__fake__http__0"], Is.EqualTo("http://localhost:1234"))
Expected string length 21 but was 8. Strings differ at index 7.
Expected: "http://localhost:1234"
But was: "http://:"
.NET Version info
No response
Anything else?
No response