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

Add workload garbage collection tests for side-by-side manifests #35857

Merged
merged 4 commits into from
Oct 19, 2023

Conversation

dsplaisted
Copy link
Member

No description provided.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Oct 4, 2023
@dsplaisted dsplaisted requested a review from a team October 4, 2023 19:15
Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the test changes look good to me, thanks for keeping up on them :)
I have a few nits that I've added below, however.

}
}

private void CreateInstallState(string featureBand, string installStateContents)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these functions have been duplicated a lot across tests, such as this one. There is a function CreateMockInstallState in SdkDirectoryWorkloadManifestProviderTests which is nearly identical, however, it does not use the featureBand parameter correctly. I do understand the simplicity of using these functions per test file, though I think it would be best for maintenance's sake to try to coalesce them into one WorkloadTestUtilities.cs file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I copied this from SdkDirectoryWorkloadManifestProviderTests, and noticed the bug so I fixed it in this PR.

I think most of the helper methods use private fields of the class so that they're less verbose to call. So it's not so simple to factor them out into a shared file, I think you'd need a base class for workload tests. I'd be happy to see someone try that, but I didn't want to tackle that here.

Overall, I don't like duplicated code, but I think I'm a lot more OK with it in tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I did not even notice that you had fixed CreateMockInstallState. I would also be happy to have some of this compressed down together, though it doesn't have to be in this PR. I will give it a 👍, though I would be more pleased once these get cleaned up in the future ;)

{
foreach (var pack in packsToKeep.Concat(packsToCollect))
{
CreateInstalledPack(pack, sdkVersion);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you have cleaned up the tests quite a bit, I quite like this CreateInstalledPack function to de-duplicate the logic. 😄

return new PackInfo(new WorkloadPackId(id), version, kind, path, resolvedPackageId);
}

FileInfo PackRecord(PackInfo pack, string sdkFeatureBand)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we parameterize the v1 and default it to "v1" in case we ever need v2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The v1 in the path is a future-proofing mechanism that we may never need. If we do need it, then we would probably be changing more about how the records are stored, so the test code would have to update anyway with more than just a change from v1 to v2.

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, thanks for refactoring a bit :) Ideally, some of the utility-function duplication gets removed down the road in another PR. Anywho, I am happy to have these new tests to improve our code coverage for garbage collection!

@dsplaisted dsplaisted merged commit a078288 into dotnet:release/8.0.1xx Oct 19, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants