Conversation
17e9c0c to
b8bfeb7
Compare
eerhardt
left a comment
There was a problem hiding this comment.
Can we also remove MySql from the EndToEnd tests?
If we do, we should probably have 2 functional tests - one for the non-EF component and one for the EF component. It could be in a single test if we wanted.
| <Compile Include="$(SharedDir)SecretsStore.cs" Link="Utils\SecretsStore.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting\ApplicationModel\UserSecretsParameterDefault.cs" Link="Utils\UserSecretsParameterDefault.cs" /> |
There was a problem hiding this comment.
There are tests checking that this is the type of credential that is created with the resource.
For all DBs btw.
AddMySqlAddsGeneratedPasswordParameterWithUserSecretsParameterDefaultInRunMode
AddMySqlDoesNotAddGeneratedPasswordParameterWithUserSecretsParameterDefaultInPublishMode
These are adapted though since the actual instance type is from the internal type in the Hosting assembly, and not the local one. What would solve it would be to make the type public.
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.Nats\NatsContainerImageTags.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.Milvus\MilvusContainerImageTags.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.MongoDB\MongoDBContainerImageTags.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.MySql\MySqlContainerImageTags.cs" /> |
There was a problem hiding this comment.
What is this still used for? It seems like it should be removed. Aspire.Hosting.Tests shouldn't need to be testing all the extension resources we create.
There was a problem hiding this comment.
VerifyTestProgramFullManifest checks a manifest which has all these resources, and uses
"image": "{{TestConstants.AspireTestContainerRegistry}}/{{MySqlContainerImageTags.Image}}:{{MySqlContainerImageTags.Tag}}",There was a problem hiding this comment.
I think this line should be removed.
|
# Conflicts: # Aspire.sln
# Conflicts: # Aspire.sln
| <ItemGroup> | ||
| <Compile Include="$(SharedDir)SecretsStore.cs" Link="Utils\SecretsStore.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting\ApplicationModel\UserSecretsParameterDefault.cs" Link="Utils\UserSecretsParameterDefault.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.Testing\ResourceLoggerForwarderService.cs" Link="Utils\ResourceLoggerForwarderService.cs" /> |
There was a problem hiding this comment.
I don't think we should be compiling this into our tests. If we need this, we should just reference Aspire.Hosting.Testing.
There was a problem hiding this comment.
Applied in another PR, copied here.
| <ProjectReference Include="..\Aspire.Hosting.Tests.SharedShim\Aspire.Hosting.Tests.SharedShim.csproj" IsAspireProjectResource="false" Aliases="AspireHostingShared" /> | ||
| <ProjectReference Include="..\..\src\Components\Aspire.Microsoft.Data.SqlClient\Aspire.Microsoft.Data.SqlClient.csproj" IsAspireProjectResource="false" /> | ||
| <ProjectReference Include="..\..\src\Components\Aspire.MongoDB.Driver\Aspire.MongoDB.Driver.csproj" IsAspireProjectResource="false" /> | ||
| <ProjectReference Include="..\..\src\Components\Aspire.Npgsql\Aspire.Npgsql.csproj" IsAspireProjectResource="false" /> |
There was a problem hiding this comment.
Why are we adding Npgsql in a MySql PR?
I think this should be removed.
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.Nats\NatsContainerImageTags.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.Milvus\MilvusContainerImageTags.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.MongoDB\MongoDBContainerImageTags.cs" /> | ||
| <Compile Include="$(RepoRoot)src\Aspire.Hosting.MySql\MySqlContainerImageTags.cs" /> |
There was a problem hiding this comment.
I think this line should be removed.
| [$"ConnectionStrings:{db.Resource.Name}"] = await db.Resource.ConnectionStringExpression.GetValueAsync(default) | ||
| }); | ||
|
|
||
| hb.AddMySqlDataSource(db.Resource.Name); |
There was a problem hiding this comment.
Should we also have tests that use the EF component? That way we can remove MySql from the EndToEnd tests completely and not lose coverage.
There was a problem hiding this comment.
Moved the EF tests here. Very similar to the one I did with Oracle (creating the tables using EF too, not just a SELECT 1 like in E2E).
| var password = "p@ssw0rd1"; | ||
|
|
||
| var passwordParameter = builder1.AddParameter("pwd"); | ||
| builder1.Configuration["Parameters:pwd"] = password; | ||
| var mysql1 = builder1.AddMySql("mysql", passwordParameter).WithEnvironment("MYSQL_DATABASE", mySqlDbName); |
There was a problem hiding this comment.
Instead of hard-coding a password (and cause more cred scan issues), can we use ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter instead?
|
@eerhardt @radical fyi what was making the only test to fail was to use a bindmountpath which was not created before the container starts. It seems some containers are fine with that (Kafka?). But this would work locally just fine. Maybe some other kind of permissions, where locally the instance can create the folder, but not on the CI. |
radical
left a comment
There was a problem hiding this comment.
Other than the one comment, LGTM 👍
| .AddRetry(new() { MaxRetryAttempts = 10, BackoffType = DelayBackoffType.Linear, Delay = TimeSpan.FromSeconds(2), ShouldHandle = new PredicateBuilder().Handle<MySqlException>() }) | ||
| .Build(); | ||
|
|
||
| var bindMountPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); |
There was a problem hiding this comment.
Would it be better to use Directory.CreateTempSubdirectory().FullName here too, and skip the need to delete+create the directory below?
* Extract Aspire.Hosting.MySql.Tests * Improve reliability * Record Docker logs * Fix ResourceLoggerForwarderService link in Aspire.Hosting.PostgreSQL.csproj * Remove E2E tests * Fix manifest test * Fix tests * Increase delay between retries * Create mount path directory * Address PR feedback * Use Directory.Delete * Use Linear backoff --------- Co-authored-by: Ankit Jain <radical@gmail.com> Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com> (cherry picked from commit 5238a73)
Contributes to #4294
Microsoft Reviewers: Open in CodeFlow