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

[tests] use test container registry in WaitFor hosting tests #5743

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

radical
Copy link
Member

@radical radical commented Sep 17, 2024

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
      • Link to aspire-docs issue:
    • No
Microsoft Reviewers: Open in CodeFlow

@radical
Copy link
Member Author

radical commented Sep 17, 2024

Adding this for the hosting tests would be useful - (

internal sealed class ContainerRegistryHook : IDistributedApplicationLifecycleHook
{
public const string AspireTestContainerRegistry = "netaspireci.azurecr.io";
public Task BeforeStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken = default)
{
var resourcesWithContainerImages = appModel.Resources
.SelectMany(r => r.Annotations.OfType<ContainerImageAnnotation>()
.Select(cia => new { Resource = r, Annotation = cia }));
foreach (var resourceWithContainerImage in resourcesWithContainerImages)
{
string? registry = resourceWithContainerImage.Annotation.Registry;
if (registry is null || registry.Contains("docker.io"))
{
resourceWithContainerImage.Annotation.Registry = AspireTestContainerRegistry;
}
}
return Task.CompletedTask;
}
}

@radical radical merged commit 3a4528a into dotnet:main Sep 17, 2024
11 checks passed
@radical radical deleted the tests-use-test-registry branch September 17, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants