-
Notifications
You must be signed in to change notification settings - Fork 731
Create functional tests #1217
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
Merged
Merged
Create functional tests #1217
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
344b6f9
Add smoke tests for mongodb
sebastienros 1ccbfa0
Rename ConfigureMongoDB to MapMongoMovieApi
sebastienros 76375dd
Use XUnit fixture to share same app host
sebastienros 677295c
Don't run MongoDB code on startup
sebastienros 30d7745
Update tests/Aspire.Hosting.Tests/TestProgramFixture.cs
sebastienros 88c337f
Update tests/Aspire.Hosting.Tests/TestProgramFixture.cs
sebastienros 6891e92
Make mongo apis idempotent
sebastienros a89ff93
Add remaining functional tests
sebastienros d06f701
Merge remote-tracking branch 'origin/main' into sebros/functionalmongo
sebastienros bdf78e2
Run functional tests on Linux
sebastienros ed4016c
Make database queries idempotent
sebastienros 6c6ffa0
Disable runs on Linux CI
sebastienros 6eb7a46
Remove unrelated loop comments
sebastienros 33dc3b6
Simplify MongoDB tests
sebastienros 3a5c29b
Test functional tests on windows
sebastienros 950d2fe
Bool logic is hard
sebastienros 6ba5814
Limit Console usage that would slow down TestServicesWithMultipleRepl…
sebastienros 448651d
Merge branch 'main' into sebros/functionalmongo
sebastienros 71a8ec3
Don't run on CI for now
sebastienros df7c3c7
Fix build
sebastienros 24c7105
Add code comment
sebastienros b6ce547
Log problem details
sebastienros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Aspire.Hosting.Tests.Helpers; | ||
| using Xunit; | ||
|
|
||
| namespace Aspire.Hosting.Tests; | ||
|
|
||
| [Collection("IntegrationServices")] | ||
| public class IntegrationServicesTests | ||
| { | ||
| private readonly IntegrationServicesFixture _integrationServicesFixture; | ||
|
|
||
| public IntegrationServicesTests(IntegrationServicesFixture integrationServicesFixture) | ||
| { | ||
| _integrationServicesFixture = integrationServicesFixture; | ||
| } | ||
|
|
||
| [LocalOnlyFact] | ||
| public async Task VerifyHealthyOnIntegrationServiceA() | ||
| { | ||
| var testProgram = _integrationServicesFixture.TestProgram; | ||
| var client = _integrationServicesFixture.HttpClient; | ||
|
|
||
| using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1)); | ||
|
|
||
| // Make sure all services are running | ||
| await testProgram.ServiceABuilder.HttpGetPidAsync(client, "http", cts.Token); | ||
| await testProgram.ServiceBBuilder.HttpGetPidAsync(client, "http", cts.Token); | ||
| await testProgram.ServiceCBuilder.HttpGetPidAsync(client, "http", cts.Token); | ||
| await testProgram.IntegrationServiceABuilder!.HttpGetPidAsync(client, "http", cts.Token); | ||
|
|
||
| // We wait until timeout for the /health endpoint to return successfully. We assume | ||
| // that components wired up into this project have health checks enabled. | ||
| await testProgram.IntegrationServiceABuilder!.WaitForHealthyStatusAsync(client, "http", cts.Token); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
tests/Aspire.Hosting.Tests/MongoDB/MongoDBFunctionalTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Aspire.Hosting.Tests.Helpers; | ||
| using Xunit; | ||
|
|
||
| namespace Aspire.Hosting.Tests.MongoDB; | ||
|
|
||
| [Collection("IntegrationServices")] | ||
| public class MongoDBFunctionalTests | ||
| { | ||
| private readonly IntegrationServicesFixture _integrationServicesFixture; | ||
|
|
||
| public MongoDBFunctionalTests(IntegrationServicesFixture integrationServicesFixture) | ||
| { | ||
| _integrationServicesFixture = integrationServicesFixture; | ||
| } | ||
|
|
||
| [LocalOnlyFact()] | ||
| public async Task VerifyMongoWorks() | ||
| { | ||
| var testProgram = _integrationServicesFixture.TestProgram; | ||
| var client = _integrationServicesFixture.HttpClient; | ||
|
|
||
| using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1)); | ||
|
|
||
| var response = await testProgram.IntegrationServiceABuilder!.HttpGetAsync(client, "http", "/mongodb/verify", cts.Token); | ||
| var responseContent = await response.Content.ReadAsStringAsync(); | ||
|
|
||
| Assert.True(response.IsSuccessStatusCode, responseContent); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.