Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/SignalR/server/StackExchangeRedis/test/Docker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class Docker
{
private static readonly string _exeSuffix = OperatingSystem.IsWindows() ? ".exe" : string.Empty;

private static readonly string _dockerContainerName = "redisTestContainer";
private static readonly string _redisImageName = "dotnetdhmirror-f8bzbjakh8cga6ab.azurecr.io/library/redis:7.4";
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

The hardcoded Azure Container Registry URL makes the code less maintainable. Consider extracting this to a configuration value or environment variable to allow easier updates when the registry URL changes.

Suggested change
private static readonly string _redisImageName = "dotnetdhmirror-f8bzbjakh8cga6ab.azurecr.io/library/redis:7.4";
private static readonly string _redisImageName = Environment.GetEnvironmentVariable("REDIS_IMAGE_NAME")
?? "dotnetdhmirror-f8bzbjakh8cga6ab.azurecr.io/library/redis:7.4";

Copilot uses AI. Check for mistakes.

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 we need this, this is a good suggestion though

Copy link
Member

Choose a reason for hiding this comment

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

maybe also extract the ACR host URL into a separate property

private static readonly string _dockerContainerName = "redisTestContainer74";
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

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

The container name hardcodes the Redis version '74' which will need manual updates when the Redis version changes. Consider deriving the container name from the image version or using a more generic naming approach.

Suggested change
private static readonly string _dockerContainerName = "redisTestContainer74";
private static readonly string _redisVersion = _redisImageName.Split(':')[1]; // Extract version from image name
private static readonly string _dockerContainerName = $"redisTestContainer{_redisVersion.Replace('.', '_')}"; // Replace '.' with '_' for valid container name

Copilot uses AI. Check for mistakes.

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 this is worth the complexity

private static readonly string _dockerMonitorContainerName = _dockerContainerName + "Monitor";
private static readonly Lazy<Docker> _instance = new Lazy<Docker>(Create);

Expand Down Expand Up @@ -112,7 +113,7 @@ void Run()
// use static name 'redisTestContainer' so if the container doesn't get removed we don't keep adding more
// use redis base docker image
// 30 second timeout to allow redis image to be downloaded, should be a rare occurrence, only happening when a new version is released
RunProcessAndThrowIfFailed(_path, $"run --rm -p 6379:6379 --name {_dockerContainerName} -d redis", "redis", logger, TimeSpan.FromMinutes(1));
RunProcessAndThrowIfFailed(_path, $"run --rm -p 6379:6379 --name {_dockerContainerName} -d {_redisImageName}", "redis", logger, TimeSpan.FromMinutes(1));
}
}

Expand Down
Loading