From 3701b50430fea92f1bc0a1348549811c8c250903 Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Sun, 18 Aug 2024 09:08:30 -0400 Subject: [PATCH] Build: Simplify Docker layout, fix Envoy, and upgrade tests (#2774) It seems the Envoy apts have gone missing breaking out build, so instead of relying on the install let's docker compose their image as a proxy against the Redis supervisor instance as a simpler and faster-to-start setup that also works. This rearranged some things to simplify the Docker story overall. A move to AzDO or just GitHub builds would simplify everything further, but we need to figure out Windows testing against a Docker setup in CI. Note: we still can't use Linux containers on a Windows GitHub Actions host (https://github.com/actions/runner/issues/904), so this remains much more complicated and not-really-testing-the-real-thing in the Windows front. --- .github/workflows/CI.yml | 11 +++-- Directory.Packages.props | 16 +++--- .../Maintenance/AzureMaintenanceEvent.cs | 2 +- src/StackExchange.Redis/ResultProcessor.cs | 2 +- tests/RedisConfigs/.docker/Envoy/Dockerfile | 6 +++ tests/RedisConfigs/.docker/Envoy/envoy.yaml | 35 +++++++++++++ tests/RedisConfigs/.docker/Redis/Dockerfile | 23 +++++++++ .../Redis}/docker-entrypoint.sh | 0 .../Redis}/supervisord.conf | 7 --- tests/RedisConfigs/Docker/install-envoy.sh | 9 ---- tests/RedisConfigs/Dockerfile | 27 ---------- tests/RedisConfigs/Envoy/envoy.yaml | 49 ------------------- tests/RedisConfigs/docker-compose.yml | 28 ++++++++--- .../AzureMaintenanceEventTests.cs | 2 +- .../StackExchange.Redis.Tests/ClusterTests.cs | 2 +- tests/StackExchange.Redis.Tests/EnvoyTests.cs | 10 ++-- .../Helpers/Attributes.cs | 12 ++--- .../Issues/Issue2653.cs | 2 +- .../StackExchange.Redis.Tests/PubSubTests.cs | 2 +- .../RespProtocolTests.cs | 4 +- .../ScriptingTests.cs | 2 +- .../SentinelFailoverTests.cs | 2 +- .../ServerSnapshotTests.cs | 2 + .../TransactionTests.cs | 8 +-- .../WithKeyPrefixTests.cs | 2 +- .../xunit.runner.json | 3 ++ 26 files changed, 130 insertions(+), 138 deletions(-) create mode 100644 tests/RedisConfigs/.docker/Envoy/Dockerfile create mode 100644 tests/RedisConfigs/.docker/Envoy/envoy.yaml create mode 100644 tests/RedisConfigs/.docker/Redis/Dockerfile rename tests/RedisConfigs/{Docker => .docker/Redis}/docker-entrypoint.sh (100%) rename tests/RedisConfigs/{Docker => .docker/Redis}/supervisord.conf (95%) delete mode 100644 tests/RedisConfigs/Docker/install-envoy.sh delete mode 100644 tests/RedisConfigs/Dockerfile delete mode 100644 tests/RedisConfigs/Envoy/envoy.yaml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5e0b81ea7..58856abbc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -24,12 +24,12 @@ jobs: with: dotnet-version: | 6.0.x - 7.0.x + 8.0.x - name: .NET Build run: dotnet build Build.csproj -c Release /p:CI=true - name: Start Redis Services (docker-compose) working-directory: ./tests/RedisConfigs - run: docker compose -f docker-compose.yml up -d + run: docker compose -f docker-compose.yml up -d --wait - name: StackExchange.Redis.Tests run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger trx --logger GitHubActions --results-directory ./test-results/ /p:CI=true - uses: dorny/test-reporter@v1 @@ -49,6 +49,7 @@ jobs: NUGET_CERT_REVOCATION_MODE: offline # Disabling signing because of massive perf hit, see https://github.com/NuGet/Home/issues/11548 DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: "1" # Note this doesn't work yet for Windows - see https://github.com/dotnet/runtime/issues/68340 TERM: xterm + DOCKER_BUILDKIT: 1 steps: - name: Checkout code uses: actions/checkout@v1 @@ -57,9 +58,13 @@ jobs: # with: # dotnet-version: | # 6.0.x - # 7.0.x + # 8.0.x - name: .NET Build run: dotnet build Build.csproj -c Release /p:CI=true + # We can't do this combination - see https://github.com/actions/runner/issues/904 + # - name: Start Redis Services (docker-compose) + # working-directory: .\tests\RedisConfigs + # run: docker compose -f docker-compose.yml up -d --wait - name: Start Redis Services (v3.0.503) working-directory: .\tests\RedisConfigs\3.0.503 run: | diff --git a/Directory.Packages.props b/Directory.Packages.props index 49d37a3ae..c8a4189e6 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,21 +10,21 @@ - + - - - - - + + + + + - - + + \ No newline at end of file diff --git a/src/StackExchange.Redis/Maintenance/AzureMaintenanceEvent.cs b/src/StackExchange.Redis/Maintenance/AzureMaintenanceEvent.cs index 75bcb6de9..4e32afa5a 100644 --- a/src/StackExchange.Redis/Maintenance/AzureMaintenanceEvent.cs +++ b/src/StackExchange.Redis/Maintenance/AzureMaintenanceEvent.cs @@ -15,7 +15,7 @@ public sealed class AzureMaintenanceEvent : ServerMaintenanceEvent { private const string PubSubChannelName = "AzureRedisEvents"; - internal AzureMaintenanceEvent(string azureEvent) + internal AzureMaintenanceEvent(string? azureEvent) { if (azureEvent == null) { diff --git a/src/StackExchange.Redis/ResultProcessor.cs b/src/StackExchange.Redis/ResultProcessor.cs index 7a69f7429..648387b87 100644 --- a/src/StackExchange.Redis/ResultProcessor.cs +++ b/src/StackExchange.Redis/ResultProcessor.cs @@ -526,7 +526,7 @@ internal sealed class ScriptLoadProcessor : ResultProcessor private static readonly Regex sha1 = new Regex("^[0-9a-f]{40}$", RegexOptions.Compiled | RegexOptions.IgnoreCase); - internal static bool IsSHA1(string script) => script is not null && script.Length == SHA1Length && sha1.IsMatch(script); + internal static bool IsSHA1(string? script) => script is not null && script.Length == SHA1Length && sha1.IsMatch(script); internal const int Sha1HashLength = 20; internal static byte[] ParseSHA1(byte[] value) diff --git a/tests/RedisConfigs/.docker/Envoy/Dockerfile b/tests/RedisConfigs/.docker/Envoy/Dockerfile new file mode 100644 index 000000000..5c20d350c --- /dev/null +++ b/tests/RedisConfigs/.docker/Envoy/Dockerfile @@ -0,0 +1,6 @@ +FROM envoyproxy/envoy:v1.31-latest + +COPY envoy.yaml /etc/envoy/envoy.yaml +RUN chmod go+r /etc/envoy/envoy.yaml + +EXPOSE 7015 diff --git a/tests/RedisConfigs/.docker/Envoy/envoy.yaml b/tests/RedisConfigs/.docker/Envoy/envoy.yaml new file mode 100644 index 000000000..fe57c8c1f --- /dev/null +++ b/tests/RedisConfigs/.docker/Envoy/envoy.yaml @@ -0,0 +1,35 @@ +admin: + address: { socket_address: { protocol: TCP, address: 0.0.0.0, port_value: 8001 } } +static_resources: + listeners: + - name: redis_listener + address: { socket_address: { protocol: TCP, address: 0.0.0.0, port_value: 7015 } } + filter_chains: + - filters: + - name: envoy.filters.network.redis_proxy + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.redis_proxy.v3.RedisProxy + stat_prefix: envoy_redis_stats + settings: + op_timeout: 3s + dns_cache_config: + name: dynamic_forward_proxy_cache_config + dns_lookup_family: V4_ONLY + prefix_routes: + catch_all_route: + cluster: redis_cluster + clusters: + - name: redis_cluster + connect_timeout: 3s + type: STRICT_DNS + dns_lookup_family: V4_ONLY + load_assignment: + cluster_name: redis_cluster + endpoints: + - lb_endpoints: + - endpoint: { address: { socket_address: { address: redis, port_value: 7000 } } } + - endpoint: { address: { socket_address: { address: redis, port_value: 7001 } } } + - endpoint: { address: { socket_address: { address: redis, port_value: 7002 } } } + - endpoint: { address: { socket_address: { address: redis, port_value: 7003 } } } + - endpoint: { address: { socket_address: { address: redis, port_value: 7004 } } } + - endpoint: { address: { socket_address: { address: redis, port_value: 7005 } } } \ No newline at end of file diff --git a/tests/RedisConfigs/.docker/Redis/Dockerfile b/tests/RedisConfigs/.docker/Redis/Dockerfile new file mode 100644 index 000000000..d4c7dec7c --- /dev/null +++ b/tests/RedisConfigs/.docker/Redis/Dockerfile @@ -0,0 +1,23 @@ +FROM redis:7.4-rc1 + +COPY --from=configs ./Basic /data/Basic/ +COPY --from=configs ./Failover /data/Failover/ +COPY --from=configs ./Cluster /data/Cluster/ +COPY --from=configs ./Sentinel /data/Sentinel/ +COPY --from=configs ./Certs /Certs/ + +RUN chown -R redis:redis /data +RUN chown -R redis:redis /Certs + +COPY docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + +RUN apt-get -y update && apt-get install supervisor -y + +RUN apt-get clean + +ADD supervisord.conf /etc/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +EXPOSE 6379 6380 6381 6382 6383 6384 7000 7001 7002 7003 7004 7005 7010 7011 26379 26380 26381 diff --git a/tests/RedisConfigs/Docker/docker-entrypoint.sh b/tests/RedisConfigs/.docker/Redis/docker-entrypoint.sh similarity index 100% rename from tests/RedisConfigs/Docker/docker-entrypoint.sh rename to tests/RedisConfigs/.docker/Redis/docker-entrypoint.sh diff --git a/tests/RedisConfigs/Docker/supervisord.conf b/tests/RedisConfigs/.docker/Redis/supervisord.conf similarity index 95% rename from tests/RedisConfigs/Docker/supervisord.conf rename to tests/RedisConfigs/.docker/Redis/supervisord.conf index 21fe45f1b..e0bd20571 100644 --- a/tests/RedisConfigs/Docker/supervisord.conf +++ b/tests/RedisConfigs/.docker/Redis/supervisord.conf @@ -99,13 +99,6 @@ stdout_logfile=/var/log/supervisor/%(program_name)s.log stderr_logfile=/var/log/supervisor/%(program_name)s.log autorestart=true -[program:redis-7015] -command=/usr/bin/envoy -c /envoy/envoy.yaml -directory=/envoy -stdout_logfile=/var/log/supervisor/%(program_name)s.log -stderr_logfile=/var/log/supervisor/%(program_name)s.log -autorestart=true - [program:sentinel-26379] command=/usr/local/bin/redis-server /data/Sentinel/sentinel-26379.conf --sentinel directory=/data/Sentinel diff --git a/tests/RedisConfigs/Docker/install-envoy.sh b/tests/RedisConfigs/Docker/install-envoy.sh deleted file mode 100644 index 9bf7c9863..000000000 --- a/tests/RedisConfigs/Docker/install-envoy.sh +++ /dev/null @@ -1,9 +0,0 @@ -# instructions from https://www.envoyproxy.io/docs/envoy/latest/start/install -apt update -apt -y install debian-keyring debian-archive-keyring apt-transport-https curl lsb-release -curl -sL 'https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key' | gpg --dearmor -o /usr/share/keyrings/getenvoy-keyring.gpg -echo "deb [arch=amd64 signed-by=/usr/share/keyrings/getenvoy-keyring.gpg] https://deb.dl.getenvoy.io/public/deb/debian $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/getenvoy.list -apt update -apt install getenvoy-envoy - - diff --git a/tests/RedisConfigs/Dockerfile b/tests/RedisConfigs/Dockerfile deleted file mode 100644 index ab0f76e6c..000000000 --- a/tests/RedisConfigs/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM redis:7.4-rc1 - -COPY Basic /data/Basic/ -COPY Failover /data/Failover/ -COPY Cluster /data/Cluster/ -COPY Sentinel /data/Sentinel/ -COPY Certs /Certs/ - -RUN chown -R redis:redis /data -RUN chown -R redis:redis /Certs - -COPY Docker/docker-entrypoint.sh /usr/local/bin/ -RUN chmod +x /usr/local/bin/docker-entrypoint.sh - -RUN apt-get -y update && apt-get install -y git gcc make supervisor - -COPY Docker/install-envoy.sh /usr/local/bin -RUN sh /usr/local/bin/install-envoy.sh - -RUN apt-get clean - -COPY Envoy/envoy.yaml /envoy/envoy.yaml -ADD Docker/supervisord.conf /etc/ - -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 6379 6380 6381 6382 6383 6384 7000 7001 7002 7003 7004 7005 7010 7011 7015 26379 26380 26381 diff --git a/tests/RedisConfigs/Envoy/envoy.yaml b/tests/RedisConfigs/Envoy/envoy.yaml deleted file mode 100644 index 3f1c5c1a9..000000000 --- a/tests/RedisConfigs/Envoy/envoy.yaml +++ /dev/null @@ -1,49 +0,0 @@ -admin: - access_log_path: "/dev/null" - address: - socket_address: - protocol: TCP - address: 0.0.0.0 - port_value: 8001 -static_resources: - listeners: - - name: redis_listener - address: - socket_address: - address: 0.0.0.0 - port_value: 7015 - filter_chains: - - filters: - - name: envoy.filters.network.redis_proxy - typed_config: - "@type": type.googleapis.com/envoy.extensions.filters.network.redis_proxy.v3.RedisProxy - stat_prefix: envoy_redis_stats - settings: - op_timeout: 5s - enable_redirection: true - prefix_routes: - catch_all_route: - cluster: redis_cluster - clusters: - - name: redis_cluster - connect_timeout: 1s - dns_lookup_family: V4_ONLY - lb_policy: CLUSTER_PROVIDED - load_assignment: - cluster_name: redis_cluster - endpoints: - - lb_endpoints: - - endpoint: - address: - socket_address: - address: 127.0.0.1 - port_value: 7000 - cluster_type: - name: envoy.clusters.redis - typed_config: - "@type": type.googleapis.com/google.protobuf.Struct - value: - cluster_refresh_rate: 30s - cluster_refresh_timeout: 0.5s - redirect_refresh_interval: 10s - redirect_refresh_threshold: 10 diff --git a/tests/RedisConfigs/docker-compose.yml b/tests/RedisConfigs/docker-compose.yml index e27bec0b8..84cb3cc75 100644 --- a/tests/RedisConfigs/docker-compose.yml +++ b/tests/RedisConfigs/docker-compose.yml @@ -1,16 +1,28 @@ -version: '2.6' +version: '2.7' services: redis: build: - context: . - image: stackexchange/redis-tests:latest + context: .docker/Redis + additional_contexts: + configs: . platform: linux ports: - - 6379-6384:6379-6384 - - 7000-7006:7000-7006 - - 7010-7011:7010-7011 - - 7015:7015 - - 26379-26381:26379-26381 + - 6379-6384:6379-6384 # Misc + - 7000-7006:7000-7006 # Cluster + - 7010-7011:7010-7011 # Sentinel Controllers + - 26379-26381:26379-26381 # Sentinel Data sysctls : net.core.somaxconn: '511' + envoy: + build: + context: .docker/Envoy + platform: linux + environment: + loglevel: warning + depends_on: + redis: + condition: service_started + ports: + - 7015:7015 # Cluster + - 8001:8001 # Admin diff --git a/tests/StackExchange.Redis.Tests/AzureMaintenanceEventTests.cs b/tests/StackExchange.Redis.Tests/AzureMaintenanceEventTests.cs index 4e3bdcbd6..852ab9af7 100644 --- a/tests/StackExchange.Redis.Tests/AzureMaintenanceEventTests.cs +++ b/tests/StackExchange.Redis.Tests/AzureMaintenanceEventTests.cs @@ -29,7 +29,7 @@ public AzureMaintenanceEventTests(ITestOutputHelper output) : base(output) { } [InlineData("NonSSLPort |", AzureNotificationType.Unknown, null, false, null, 0, 0)] [InlineData("StartTimeInUTC|thisisthestart", AzureNotificationType.Unknown, null, false, null, 0, 0)] [InlineData(null, AzureNotificationType.Unknown, null, false, null, 0, 0)] - public void TestAzureMaintenanceEventStrings(string message, AzureNotificationType expectedEventType, string expectedStart, bool expectedIsReplica, string expectedIP, int expectedSSLPort, int expectedNonSSLPort) + public void TestAzureMaintenanceEventStrings(string? message, AzureNotificationType expectedEventType, string? expectedStart, bool expectedIsReplica, string? expectedIP, int expectedSSLPort, int expectedNonSSLPort) { DateTime? expectedStartTimeUtc = null; if (expectedStart != null && DateTime.TryParseExact(expectedStart, "s", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out DateTime startTimeUtc)) diff --git a/tests/StackExchange.Redis.Tests/ClusterTests.cs b/tests/StackExchange.Redis.Tests/ClusterTests.cs index fcab7bb14..742ce51bb 100644 --- a/tests/StackExchange.Redis.Tests/ClusterTests.cs +++ b/tests/StackExchange.Redis.Tests/ClusterTests.cs @@ -365,7 +365,7 @@ public void TransactionWithSameSlotKeys() [InlineData(null, 100)] [InlineData("abc", 10)] [InlineData("abc", 100)] - public void Keys(string pattern, int pageSize) + public void Keys(string? pattern, int pageSize) { using var conn = Create(allowAdmin: true); diff --git a/tests/StackExchange.Redis.Tests/EnvoyTests.cs b/tests/StackExchange.Redis.Tests/EnvoyTests.cs index 5015a660d..6d669a6db 100644 --- a/tests/StackExchange.Redis.Tests/EnvoyTests.cs +++ b/tests/StackExchange.Redis.Tests/EnvoyTests.cs @@ -35,15 +35,15 @@ public void TestBasicEnvoyConnection() } catch (TimeoutException ex) when (ex.Message == "Connect timeout" || sb.ToString().Contains("Returned, but incorrectly")) { - Skip.Inconclusive("Envoy server not found."); + Skip.Inconclusive($"Envoy server not found: {ex}."); } - catch (AggregateException) + catch (AggregateException ex) { - Skip.Inconclusive("Envoy server not found."); + Skip.Inconclusive($"Envoy server not found: {ex}."); } - catch (RedisConnectionException) when (sb.ToString().Contains("It was not possible to connect to the redis server(s)")) + catch (RedisConnectionException ex) when (sb.ToString().Contains("It was not possible to connect to the redis server(s)")) { - Skip.Inconclusive("Envoy server not found."); + Skip.Inconclusive($"Envoy server not found: {ex}."); } } } diff --git a/tests/StackExchange.Redis.Tests/Helpers/Attributes.cs b/tests/StackExchange.Redis.Tests/Helpers/Attributes.cs index 1fab56cbb..ab0583764 100644 --- a/tests/StackExchange.Redis.Tests/Helpers/Attributes.cs +++ b/tests/StackExchange.Redis.Tests/Helpers/Attributes.cs @@ -251,16 +251,14 @@ public static IEnumerable Expand(this ITestMethod testMethod, Fu { protocols = RunPerProtocol.AllProtocols; } - var results = new List(); foreach (var protocol in protocols) { - results.Add(generator(protocol)); + yield return generator(protocol); } - return results; } else { - return new[] { generator(RedisProtocol.Resp2) }; + yield return generator(RedisProtocol.Resp2); } } } @@ -270,7 +268,7 @@ public static IEnumerable Expand(this ITestMethod testMethod, Fu /// and with another culture. /// /// -/// Based on: https://bartwullems.blogspot.com/2022/03/xunit-change-culture-during-your-test.html +/// Based on: https://bartwullems.blogspot.com/2022/03/xunit-change-culture-during-your-test.html. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class TestCultureAttribute : BeforeAfterTestAttribute @@ -288,7 +286,7 @@ public class TestCultureAttribute : BeforeAfterTestAttribute /// Stores the current and /// and replaces them with the new cultures defined in the constructor. /// - /// The method under test + /// The method under test. public override void Before(MethodInfo methodUnderTest) { originalCulture = Thread.CurrentThread.CurrentCulture; @@ -299,7 +297,7 @@ public override void Before(MethodInfo methodUnderTest) /// /// Restores the original to . /// - /// The method under test + /// The method under test. public override void After(MethodInfo methodUnderTest) { if (originalCulture is not null) diff --git a/tests/StackExchange.Redis.Tests/Issues/Issue2653.cs b/tests/StackExchange.Redis.Tests/Issues/Issue2653.cs index 973a01da5..d304ff44a 100644 --- a/tests/StackExchange.Redis.Tests/Issues/Issue2653.cs +++ b/tests/StackExchange.Redis.Tests/Issues/Issue2653.cs @@ -11,6 +11,6 @@ public class Issue2653 [InlineData("abc.def", "abc.def")] [InlineData("abc d \t ef", "abc-d-ef")] [InlineData(" abc\r\ndef\n", "abc-def")] - public void CheckLibraySanitization(string input, string expected) + public void CheckLibraySanitization(string? input, string expected) => Assert.Equal(expected, ServerEndPoint.ClientInfoSanitize(input)); } diff --git a/tests/StackExchange.Redis.Tests/PubSubTests.cs b/tests/StackExchange.Redis.Tests/PubSubTests.cs index d064f298d..249b8e63d 100644 --- a/tests/StackExchange.Redis.Tests/PubSubTests.cs +++ b/tests/StackExchange.Redis.Tests/PubSubTests.cs @@ -56,7 +56,7 @@ await UntilConditionAsync( [InlineData(null, true, "d")] [InlineData("", true, "e")] [InlineData("Foo:", true, "f")] - public async Task TestBasicPubSub(string channelPrefix, bool wildCard, string breaker) + public async Task TestBasicPubSub(string? channelPrefix, bool wildCard, string breaker) { using var conn = Create(channelPrefix: channelPrefix, shared: false, log: Writer); diff --git a/tests/StackExchange.Redis.Tests/RespProtocolTests.cs b/tests/StackExchange.Redis.Tests/RespProtocolTests.cs index c2cd8a026..c508bd1c9 100644 --- a/tests/StackExchange.Redis.Tests/RespProtocolTests.cs +++ b/tests/StackExchange.Redis.Tests/RespProtocolTests.cs @@ -156,7 +156,7 @@ public async Task ConnectWithBrokenHello(string command, bool isResp3) [InlineData("return { map = { a = 1, b = 2, c = 3 } }", RedisProtocol.Resp3, ResultType.Array, ResultType.Map, MAP_ABC, 6)] [InlineData("return { set = { a = 1, b = 2, c = 3 } }", RedisProtocol.Resp3, ResultType.Array, ResultType.Set, SET_ABC, 6)] [InlineData("return { double = 42 }", RedisProtocol.Resp3, ResultType.SimpleString, ResultType.Double, 42.0, 6)] - public async Task CheckLuaResult(string script, RedisProtocol protocol, ResultType resp2, ResultType resp3, object expected, int serverMin = 1) + public async Task CheckLuaResult(string script, RedisProtocol protocol, ResultType resp2, ResultType resp3, object? expected, int? serverMin = 1) { // note Lua does not appear to return RESP3 types in any scenarios var muxer = Create(protocol: protocol); @@ -313,7 +313,7 @@ public async Task CheckLuaResult(string script, RedisProtocol protocol, ResultTy [InlineData("debug", RedisProtocol.Resp2, ResultType.Integer, ResultType.Integer, false, "protocol", "false")] [InlineData("debug", RedisProtocol.Resp3, ResultType.Integer, ResultType.Boolean, false, "protocol", "false")] - public async Task CheckCommandResult(string command, RedisProtocol protocol, ResultType resp2, ResultType resp3, object expected, params object[] args) + public async Task CheckCommandResult(string command, RedisProtocol protocol, ResultType resp2, ResultType resp3, object? expected, params object[] args) { var muxer = Create(protocol: protocol); var ep = muxer.GetServerEndPoint(muxer.GetEndPoints().Single()); diff --git a/tests/StackExchange.Redis.Tests/ScriptingTests.cs b/tests/StackExchange.Redis.Tests/ScriptingTests.cs index bbacb96bd..59bb0e608 100644 --- a/tests/StackExchange.Redis.Tests/ScriptingTests.cs +++ b/tests/StackExchange.Redis.Tests/ScriptingTests.cs @@ -1021,7 +1021,7 @@ public void ScriptWithKeyPrefixCompare() [InlineData("$29c3804401b0727f70f73d4415e162400cbe57b", false)] [InlineData("829c3804401b0727f70f73d4415e162400cbe57", false)] [InlineData("829c3804401b0727f70f73d4415e162400cbe57bb", false)] - public void Sha1Detection(string candidate, bool isSha) + public void Sha1Detection(string? candidate, bool isSha) { Assert.Equal(isSha, ResultProcessor.ScriptLoadProcessor.IsSHA1(candidate)); } diff --git a/tests/StackExchange.Redis.Tests/SentinelFailoverTests.cs b/tests/StackExchange.Redis.Tests/SentinelFailoverTests.cs index 1e4d8c28e..873e93d3e 100644 --- a/tests/StackExchange.Redis.Tests/SentinelFailoverTests.cs +++ b/tests/StackExchange.Redis.Tests/SentinelFailoverTests.cs @@ -12,7 +12,7 @@ public class SentinelFailoverTests : SentinelBase { public SentinelFailoverTests(ITestOutputHelper output) : base(output) { } - [Fact] + [FactLongRunning] public async Task ManagedPrimaryConnectionEndToEndWithFailoverTest() { var connectionString = $"{TestConfig.Current.SentinelServer}:{TestConfig.Current.SentinelPortA},serviceName={ServiceOptions.ServiceName},allowAdmin=true"; diff --git a/tests/StackExchange.Redis.Tests/ServerSnapshotTests.cs b/tests/StackExchange.Redis.Tests/ServerSnapshotTests.cs index ed1d995a5..241999533 100644 --- a/tests/StackExchange.Redis.Tests/ServerSnapshotTests.cs +++ b/tests/StackExchange.Redis.Tests/ServerSnapshotTests.cs @@ -11,6 +11,7 @@ public class ServerSnapshotTests [Fact] [System.Diagnostics.CodeAnalysis.SuppressMessage("Assertions", "xUnit2012:Do not use boolean check to check if a value exists in a collection", Justification = "Explicit testing")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Assertions", "xUnit2013:Do not use equality check to check for collection size.", Justification = "Explicit testing")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Assertions", "xUnit2029:Do not use Empty() to check if a value does not exist in a collection", Justification = "Explicit testing")] public void EmptyBehaviour() { var snapshot = ServerSnapshot.Empty; @@ -52,6 +53,7 @@ public void EmptyBehaviour() [InlineData(5, 3)] [InlineData(5, 5)] [System.Diagnostics.CodeAnalysis.SuppressMessage("Assertions", "xUnit2012:Do not use boolean check to check if a value exists in a collection", Justification = "Explicit testing")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Assertions", "xUnit2029:Do not use Empty() to check if a value does not exist in a collection", Justification = "Explicit testing")] public void NonEmptyBehaviour(int count, int replicaCount) { var snapshot = ServerSnapshot.Empty; diff --git a/tests/StackExchange.Redis.Tests/TransactionTests.cs b/tests/StackExchange.Redis.Tests/TransactionTests.cs index b1f676d67..db4554bef 100644 --- a/tests/StackExchange.Redis.Tests/TransactionTests.cs +++ b/tests/StackExchange.Redis.Tests/TransactionTests.cs @@ -90,7 +90,7 @@ public async Task BasicTranWithExistsCondition(bool demandKeyExists, bool keyExi [InlineData("x", null, false, true)] [InlineData(null, "y", false, true)] [InlineData(null, null, false, false)] - public async Task BasicTranWithEqualsCondition(string expected, string value, bool expectEqual, bool expectTranResult) + public async Task BasicTranWithEqualsCondition(string? expected, string? value, bool expectEqual, bool expectTranResult) { using var conn = Create(); @@ -179,7 +179,7 @@ public async Task BasicTranWithHashExistsCondition(bool demandKeyExists, bool ke [InlineData("x", null, false, true)] [InlineData(null, "y", false, true)] [InlineData(null, null, false, false)] - public async Task BasicTranWithHashEqualsCondition(string expected, string value, bool expectEqual, bool expectedTranResult) + public async Task BasicTranWithHashEqualsCondition(string? expected, string? value, bool expectEqual, bool expectedTranResult) { using var conn = Create(); @@ -290,7 +290,7 @@ public async Task BasicTranWithListExistsCondition(bool demandKeyExists, bool ke [InlineData("x", null, false, true)] [InlineData(null, "y", false, true)] [InlineData(null, null, false, false)] - public async Task BasicTranWithListEqualsCondition(string expected, string value, bool expectEqual, bool expectTranResult) + public async Task BasicTranWithListEqualsCondition(string? expected, string? value, bool expectEqual, bool expectTranResult) { using var conn = Create(); @@ -357,7 +357,7 @@ public enum ComparisonType [InlineData("", ComparisonType.GreaterThan, 0L, false)] [InlineData(null, ComparisonType.GreaterThan, 1L, false)] [InlineData(null, ComparisonType.GreaterThan, 0L, false)] - public async Task BasicTranWithStringLengthCondition(string value, ComparisonType type, long length, bool expectTranResult) + public async Task BasicTranWithStringLengthCondition(string? value, ComparisonType type, long length, bool expectTranResult) { using var conn = Create(); diff --git a/tests/StackExchange.Redis.Tests/WithKeyPrefixTests.cs b/tests/StackExchange.Redis.Tests/WithKeyPrefixTests.cs index 60cccdc7d..72a99f2cc 100644 --- a/tests/StackExchange.Redis.Tests/WithKeyPrefixTests.cs +++ b/tests/StackExchange.Redis.Tests/WithKeyPrefixTests.cs @@ -58,7 +58,7 @@ public void NullPrefixIsError_String() [InlineData("abc")] [InlineData("")] [InlineData(null)] - public void NullDatabaseIsError(string prefix) + public void NullDatabaseIsError(string? prefix) { Assert.Throws(() => { diff --git a/tests/StackExchange.Redis.Tests/xunit.runner.json b/tests/StackExchange.Redis.Tests/xunit.runner.json index 8bca1f742..99e81e741 100644 --- a/tests/StackExchange.Redis.Tests/xunit.runner.json +++ b/tests/StackExchange.Redis.Tests/xunit.runner.json @@ -1,6 +1,9 @@ { "methodDisplay": "classAndMethod", "maxParallelThreads": 16, + "parallelizeAssembly": true, + "parallelizeTestCollections": true, + "parallelAlgorithm": "aggressive", "diagnosticMessages": false, "longRunningTestSeconds": 60 } \ No newline at end of file