-
Notifications
You must be signed in to change notification settings - Fork 543
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
[tests] Refactor SqlServer tests to use testcontainers #3034
Conversation
@eerhardt Are there any tests that I missed here? |
ce9227e
to
b88d79a
Compare
b88d79a
to
26d02c8
Compare
tests/Aspire.Microsoft.EntityFrameworkCore.SqlServer.Tests/SqlServerContainerFixture.cs
Outdated
Show resolved
Hide resolved
// TODO | ||
protected override string[] RequiredLogCategories => Array.Empty<string>(); | ||
protected override string[] RequiredLogCategories => [ | ||
"Microsoft.Extensions.Hosting.Internal.ApplicationLifetime", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were tests failing if we don't do this? We don't have these categories elsewhere.
The issue is that Microsoft.Data.SqlClient doesn't support logging. See Aspire.Microsoft.Data.SqlClient:
in https://github.com/dotnet/aspire/blob/main/src/Components/Telemetry.md.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the tests weren't failing because they didn't check for any required categories.
From your link:
Aspire.Microsoft.EntityFrameworkCore.SqlServer:
Log categories:
"Microsoft.EntityFrameworkCore.ChangeTracking"
"Microsoft.EntityFrameworkCore.Database.Command"
"Microsoft.EntityFrameworkCore.Database.Connection"
"Microsoft.EntityFrameworkCore.Database.Transaction"
"Microsoft.EntityFrameworkCore.Infrastructure"
"Microsoft.EntityFrameworkCore.Migrations"
"Microsoft.EntityFrameworkCore.Model"
"Microsoft.EntityFrameworkCore.Model.Validation"
"Microsoft.EntityFrameworkCore.Query"
"Microsoft.EntityFrameworkCore.Update"
Shouldn't we check for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, you were talking about SqlClient
:
Aspire.Microsoft.Data.SqlClient:
Log categories:
none (the client does not provide an easy way to integrate it with logger factory)
- move SqlServerContainerFixture to `Aspire.Microsoft.Data.SqlClient.Tests` - Instead of using `InternalsVisibleTo`, compile the relevant file with the project.
…rumentation.SqlClient to Aspire.Microsoft.EntityFrameworkCore.SqlServer
… src/Components/Telemetry.md
I made the suggested changes. And also had to update - protected override string ActivitySourceName => "OpenTelemetry.Instrumentation.SqlClient";
+ protected override string ActivitySourceName => "Aspire.Microsoft.Data.SqlClient"; - protected override string ActivitySourceName => "OpenTelemetry.Instrumentation.SqlClient";
+ protected override string ActivitySourceName => "Aspire.Microsoft.EntityFrameworkCore.SqlServer"; does that change look correct? |
tests/Aspire.Microsoft.Data.SqlClient.Tests/ConformanceTests.cs
Outdated
Show resolved
Hide resolved
@@ -71,5 +81,26 @@ protected override void SetMetrics(MicrosoftDataSqlClientSettings options, bool | |||
=> options.Metrics = enabled; | |||
|
|||
protected override void TriggerActivity(SqlConnection service) | |||
=> service.Open(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just opening a connection not enough to trigger an activity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, nothing was emitted with just that, and the tests would fail:
[xUnit.net 00:00:23.52] Aspire.Microsoft.Data.SqlClient.Tests.ConformanceTests.TracingEnablesTheRightActivitySource [FAIL]
Failed Aspire.Microsoft.Data.SqlClient.Tests.ConformanceTests.TracingEnablesTheRightActivitySource [7 s]
Error Message:
Microsoft.DotNet.RemoteExecutor.RemoteExecutionException : Remote process failed with an unhandled exception.
Stack Trace:
Child exception:
Xunit.Sdk.NotEmptyException: Assert.NotEmpty() Failure
at Aspire.Components.ConformanceTests.ConformanceTests`2.ActivitySourceTest(String key) in /Users/ankj/dev/a3/tests/Aspire.Components.Common.Tests/ConformanceTests.cs:line 405
at Aspire.Microsoft.Data.SqlClient.Tests.ConformanceTests.<>c.<TracingEnablesTheRightActivitySource>b__24_1(ConformanceTests obj) in /Users/ankj/dev/a3/tests/Aspire.Microsoft.Data.SqlClient.Tests/ConformanceTests.cs:line 94
at Aspire.Microsoft.Data.SqlClient.Tests.ConformanceTests.RunWithFixtureAsync(Action`1 test) in /Users/ankj/dev/a3/tests/Aspire.Microsoft.Data.SqlClient.Tests/ConformanceTests.cs:line 104
at Aspire.Microsoft.Data.SqlClient.Tests.ConformanceTests.RunWithFixtureAsync(Action`1 test) in /Users/ankj/dev/a3/tests/Aspire.Microsoft.Data.SqlClient.Tests/ConformanceTests.cs:line 104
at Microsoft.DotNet.RemoteExecutor.Program.Main(String[] args) in /_/src/Microsoft.DotNet.RemoteExecutor/src/Program.cs:line 65
Child process:
Aspire.Microsoft.Data.SqlClient.Tests, Version=42.42.42.42, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 Aspire.Microsoft.Data.SqlClient.Tests.ConformanceTests+<>c System.Threading.Tasks.Task <TracingEnablesTheRightActivitySource>b__24_0()
* Change how resources expose urls to the dashboard - The resource server used to have a services and endpoints split, that is now a single object called a url which has a name, a full url (uri format) and a bool for if that endpoint is internal (or an implementation detail). - Clean up the way we extract urls from the dcp information by mapping the app model resource and endpoint within each service resource in DCP. - Mark fields as deprecated in the proto file - Moved from Tuples to records for CustomResourceSnapshot
* Enable basic certificate auth for resource service This adds the ability to configured the gRPC connection from the dashboard to a resource service to use certificates for authentication. Such auth is not used in the local dev scenario, so the app host is changed to suppress auth via the `DOTNET_RESOURCE_SERVICE_DISABLE_AUTH` environment variable. The dashboard will now require certificates unless this variable is set to `1`. This discourages self-hosting the dashboard in an insecure manner. * Support loading client cert from keystore * Use enum for resource service auth mode * Dashboard web app supports OpenID Connect * Use a single authentication call for both the web app and OTLP Use explicit policies and configure those policies with the authentication schemes required. Also rejig some config settings for consistency. * Remove redundant configuration key * Rename "web app" to "frontend" * Reorder readme sections and adjust headings and their levels * Seal class * Simplify frontend auth implementation * Add docs * More thorough enum validation * Remove unused config key * Change exception type
…et#3140) [main] Update dependencies from dotnet/arcade
…et#3148) [main] Update dependencies from dotnet/arcade
This was missed in dotnet#3033.
* Fix SqlClient component activity name * Update instructions
Follow up to dotnet#3120
# Conflicts: # eng/Versions.props # src/Aspire.Hosting/Dcp/ApplicationExecutor.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Also add tracing tests for
Aspire.Microsoft.Data.SqlClient.Tests
Microsoft Reviewers: Open in CodeFlow