Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure CosmosDB Components have enough testing #668

Open
eerhardt opened this issue Nov 2, 2023 · 11 comments
Open

Ensure CosmosDB Components have enough testing #668

eerhardt opened this issue Nov 2, 2023 · 11 comments
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-cosmosdb Issues related to Azure CosmosDB testing ☑️
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented Nov 2, 2023

#359 added support for CosmosDB components. We should ensure these components have all the necessary test coverage - for example logging and tracing tests.

The other components have 2 modes:

  • Can Connect to server
  • Can't Connect to server (typically this is run in CI)

I didn't see any tests that actually connect to a server. We should see what it takes to enable that class of tests.

cc @Pilchie

@eerhardt eerhardt added the area-integrations Issues pertaining to Aspire Integrations packages label Nov 2, 2023
@eerhardt eerhardt added this to the some time after preview milestone Nov 2, 2023
@danmoseley danmoseley added the help wanted Issue that is a good candidate for community contribution. label Nov 12, 2023
@danmoseley danmoseley removed this from the needs milestone (for GA) milestone Nov 13, 2023
@stbau04
Copy link
Contributor

stbau04 commented Jan 17, 2024

@eerhardt By the tests that actually connect to a server you mean the stuff in tests/testproject?
I think i would have some time to add further tests

@eerhardt
Copy link
Member Author

By the tests that actually connect to a server you mean the stuff in tests/testproject?

@mitchdenny added a test in #1668 for this.

My original intention was to follow the same pattern as we do in the other Azure components - if the test is configured to a service that can be connected to, it runs more tests.

For example, for Storage Blobs:

private static readonly Lazy<bool> s_canConnectToServer = new(GetCanConnect);

private static bool GetCanConnect()
{
BlobClientOptions clientOptions = new();
clientOptions.Retry.MaxRetries = 0; // don't enable retries (test runs few times faster)
BlobServiceClient tableClient = new(new Uri(ServiceUri), new DefaultAzureCredential(), clientOptions);
try
{
tableClient.GetBlobContainers().AsPages(pageSizeHint: 1).FirstOrDefault();
return true;

@stbau04
Copy link
Contributor

stbau04 commented Jan 19, 2024

@eerhardt Ok that seems quite logical, but where should the server run?
When looking at the Storage blob it seems like it connects to this service: https://aspirestoragetests.blob.core.windows.net/
MongoDb on the other hand is connecting to something local: mongodb://root:password@localhost:27017/test_db

Why is one of them running locally while the other uses a remote connection? What should be used for the cosmosdb? As there is an emulator (which is used in TestProject) i would guess it should be running locally?
This leads to my next question: If it should run locally, where should it be started? I couldn't figure that out looking at the other tests

@eerhardt
Copy link
Member Author

Getting component tests running against a local container / emulator is something that has been on our list. Weare actively working on figuring out how to do more and better testing here.

For this, my hope is that we can spin the local emulator up at the beginning of the tests and then run the suite of tests hitting it. However we don't have the test infrastructure to do this easily, yet.

@stbau04
Copy link
Contributor

stbau04 commented Jan 20, 2024

@eerhardt Isn't there an issue for that? I think i rember that i've read something about resuing parts of the app host logic or something similar for this?

Should i spend time on tests for the cosmosdb now? Or should we wait until the infrastructure is created?

@eerhardt
Copy link
Member Author

I think the CosmosDB tests can be written now like the rest of the tests are. That part doesn't need to wait until the infrastructure is created. The tests can follow the existing pattern.

@stbau04
Copy link
Contributor

stbau04 commented Jan 22, 2024

@eerhardt Where should the cosmosdb server be running? Locally as in the mongodb tests or some remote server as in the storage blob tests?

@eerhardt
Copy link
Member Author

For now, I'd do it as a remote server as in the storage blob tests.

@stbau04
Copy link
Contributor

stbau04 commented Jan 23, 2024

@eerhardt Ok, but what server should we use?

@davidfowl davidfowl added this to the preview TBD (but in 8.0) milestone Jan 27, 2024
@eerhardt
Copy link
Member Author

@eerhardt Ok, but what server should we use?

We started using "Test Containers" - See #2345. Can we use the local CosmosDB emulator using test containers?

@stbau04
Copy link
Contributor

stbau04 commented Mar 10, 2024

@eerhardt I tried adding the Testcontainers.CosmosDb to the test project. This breaks all nuget-Dependencies:

  • All dependencies were marked in the solution explorer (but no actual warnings were shown)
  • The usings in the code were shown as unused and the corresponding classes were not found

Did this also happen at the RabbitMQ tests?

@eerhardt eerhardt modified the milestones: preview 6 (Apr), Backlog Mar 25, 2024
@davidfowl davidfowl added azure Issues associated specifically with scenarios tied to using Azure azure-cosmosdb Issues related to Azure CosmosDB labels Sep 7, 2024
@davidfowl davidfowl removed the help wanted Issue that is a good candidate for community contribution. label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-cosmosdb Issues related to Azure CosmosDB testing ☑️
Projects
None yet
Development

No branches or pull requests

4 participants