Wrong CosmosDB port when running API tests on top of Aspire #9896
Unanswered
dilyandimitrov
asked this question in
Q&A
Replies: 2 comments 4 replies
-
I think you're going to need to share a sample so we can see all of the code. |
Beta Was this translation helpful? Give feedback.
4 replies
-
Not sure if this is what you want, but I am sending you all the logs regarding the spinning up the cosmos in aspire in the tests |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an Aspire setup with CosmosDB and on top of that I run API tests using the
DistributedApplicationTestingBuilder
.I have a POST/PUT endpoint that puts some data into CosmosDB, I want to make a test verifying that the data ended up in the DB as it is expected.
Inside the endpoint logic I am using the
CosmosClient
that the Aspire is putting available into the Services (DI container):To verify if my data is in the DB I am creating a new
CosmosClient
manually inside the test which I am going to use to query the DB.From the
DistributedApplication
I can use theawait Fixture.App.GetConnectionStringAsync("cosmosdb")
to fetch the connection string with the correct PORT where the CosmosDB is running on (AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==;AccountEndpoint=http://localhost:60980/
)But when I try to query the DB I get the following error:
When I create the
CosmosClient
inside the test I also get some useful debug logs like:from which you can see that the Read and Write endpoints are not pointing to the right port (60980 in this case)
The code that I use to create the
CosmosClient
inside the tests:What am I missing? Why the port for the Read and Write cosmosdb endpoints on my manually created
CosmosClient
is not pointing to the port I am giving it via the connection string? (The endpoint property inside the cosmos client actually has the right port)Beta Was this translation helpful? Give feedback.
All reactions