Skip to content

Commit 744814c

Browse files
authored
Enable testing against CE 8.0-M2 and M3 (#380)
* Enable testing against CE 8.0-M2 and M3 * Use patched SkippableTheoryDiscoverer to fix tests discovery * Use older syntax * Add missing REDIS_VERSION env variables * Skip CMS.MERGE tests on cluster * Fix execution guards for some standalone-only tests * Fix GraphTests
1 parent 26a1d0e commit 744814c

File tree

9 files changed

+77
-20
lines changed

9 files changed

+77
-20
lines changed

.github/actions/run-tests/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ runs:
102102

103103
- name: Test
104104
shell: bash
105+
env:
106+
REDIS_VERSION: ${{ inputs.redis-version }}
105107
run: |
106108
echo "::group::Run tests"
107109
echo "${{inputs.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_ca.pem

.github/workflows/integration.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
max-parallel: 15
3838
fail-fast: false
3939
matrix:
40-
redis-version: [ '${{ needs.redis_version.outputs.CURRENT }}', '7.2.6', '6.2.16']
40+
redis-version: [ '8.0-M02', '8.0-M03', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.6', '6.2.16']
4141
dotnet-version: ['6.0', '7.0', '8.0']
4242
env:
4343
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
@@ -104,5 +104,7 @@ jobs:
104104
./redis-stack-server-${{env.redis_stack_version}}/bin/redis-cli INFO SERVER | grep redis_version
105105
- name: Test
106106
shell: cmd
107+
env:
108+
REDIS_VERSION: ${{env.redis_stack_version}}
107109
run: |
108110
dotnet test -f net481 --no-build --verbosity detailed -p:BuildInParallel=false tests/Test.proj --logger GitHubActions

tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public async Task TestQueryAsync(string endpointId)
215215
}
216216

217217
[SkipIfRedis(Is.Enterprise)]
218-
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
218+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
219219
public void TestMerge(string endpointId)
220220
{
221221
var db = GetCleanDatabase(endpointId);
@@ -264,7 +264,7 @@ public void TestMerge(string endpointId)
264264

265265

266266
[SkipIfRedis(Is.Enterprise)]
267-
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
267+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
268268
public async Task TestMergeAsync(string endpointId)
269269
{
270270
var db = GetCleanDatabase(endpointId);

tests/NRedisStack.Tests/Graph/GraphTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics.CodeAnalysis;
12
using Xunit;
23
using StackExchange.Redis;
34
using NRedisStack.RedisStackCommands;
@@ -6,6 +7,7 @@
67

78
namespace NRedisStack.Tests.Graph;
89

10+
[SuppressMessage("Usage", "xUnit1026:Theory methods should use all of their parameters")]
911
public class GraphTests : AbstractNRedisStackTest, IDisposable
1012
{
1113
public GraphTests(EndpointsFixture endpointsFixture) : base(endpointsFixture)
@@ -797,7 +799,7 @@ private void AssertTestGeoPoint(IGraphCommands graph)
797799
[SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")]
798800
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
799801
[Obsolete]
800-
public void TestPoint()
802+
public void TestPoint(string endpointId)
801803
{
802804
var point = new Point(30.27822306, -97.75134723);
803805

tests/NRedisStack.Tests/NRedisStack.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<PrivateAssets>all</PrivateAssets>
2727
</PackageReference>
2828
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
29+
<PackageReference Include="Validation" Version="2.6.68" />
2930
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" />
3031
<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
3132
<PackageReference Include="xunit" Version="2.4.1" />

tests/NRedisStack.Tests/Search/IndexCreationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void TestMissingEmptyFieldCommandArgs()
4242
}
4343

4444
[SkipIfRedis(Comparison.LessThan, "7.3.240")]
45-
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
45+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
4646
public void TestMissingFields(string endpointId)
4747
{
4848
IDatabase db = GetCleanDatabase(endpointId);

tests/NRedisStack.Tests/SkipIfRedisAttribute.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Xunit;
2+
using Xunit.Sdk;
23

34
namespace NRedisStack.Tests;
45

@@ -14,6 +15,7 @@ public enum Is
1415
}
1516

1617
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
18+
[XunitTestCaseDiscoverer("NRedisStack.Tests.SkippableTheoryDiscoverer", "NRedisStack.Tests")]
1719
public class SkipIfRedisAttribute : SkippableTheoryAttribute
1820
{
1921
private readonly string _targetVersion;
@@ -30,19 +32,6 @@ public SkipIfRedisAttribute(
3032
_targetVersion = targetVersion;
3133
}
3234

33-
// skip more than one environment:
34-
public SkipIfRedisAttribute(
35-
Is environment1,
36-
Is environment2,
37-
Comparison comparison = Comparison.LessThan,
38-
string targetVersion = "0.0.0")
39-
{
40-
_environments.Add(environment1);
41-
_environments.Add(environment2);
42-
_comparison = comparison;
43-
_targetVersion = targetVersion;
44-
}
45-
4635
public SkipIfRedisAttribute(string targetVersion) // defaults to LessThan
4736
{
4837
_comparison = Comparison.LessThan;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using Xunit.Sdk;
2+
3+
namespace NRedisStack.Tests;
4+
5+
// TODO(imalinovskiy): Remove this file once tests are migrated to Xunit v3
6+
7+
/// Copyright (c) Andrew Arnott. All rights reserved.
8+
// Licensed under the Microsoft Public License (Ms-PL).
9+
// https://github.com/AArnott/Xunit.SkippableFact/blob/main/src/Xunit.SkippableFact/Sdk/SkippableTheoryDiscoverer.cs
10+
// See https://github.com/AArnott/Xunit.SkippableFact/blob/main/LICENSE for full license information.
11+
12+
using System.Collections.Generic;
13+
using Validation;
14+
using Xunit.Abstractions;
15+
16+
/// <summary>
17+
/// Patched TestCase discoverer to support SkipIfRedisAttribute.
18+
/// </summary>
19+
public class SkippableTheoryDiscoverer : IXunitTestCaseDiscoverer
20+
{
21+
/// <summary>
22+
/// The diagnostic message sink provided to the constructor.
23+
/// </summary>
24+
private readonly IMessageSink diagnosticMessageSink;
25+
26+
/// <summary>
27+
/// The complex theory discovery process that we wrap.
28+
/// </summary>
29+
private readonly TheoryDiscoverer theoryDiscoverer;
30+
31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="SkippableTheoryDiscoverer"/> class.
33+
/// </summary>
34+
/// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages.</param>
35+
public SkippableTheoryDiscoverer(IMessageSink diagnosticMessageSink)
36+
{
37+
this.diagnosticMessageSink = diagnosticMessageSink;
38+
this.theoryDiscoverer = new TheoryDiscoverer(diagnosticMessageSink);
39+
}
40+
41+
/// <inheritdoc />
42+
public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
43+
{
44+
Requires.NotNull(factAttribute, nameof(factAttribute));
45+
string[] skippingExceptionNames = new[] { "Xunit.SkippableFact.SkipException" };
46+
TestMethodDisplay defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();
47+
48+
IEnumerable<IXunitTestCase>? basis = this.theoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute);
49+
foreach (IXunitTestCase? testCase in basis)
50+
{
51+
if (testCase is XunitTheoryTestCase)
52+
{
53+
yield return new SkippableTheoryTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod);
54+
}
55+
else
56+
{
57+
yield return new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod, testCase.TestMethodArguments);
58+
}
59+
}
60+
}
61+
}

tests/NRedisStack.Tests/TransactionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public TransactionTests(EndpointsFixture endpointsFixture) : base(endpointsFixtu
1515
}
1616

1717
[SkippableTheory]
18-
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
18+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
1919
public void TestJsonTransaction(string endpointId)
2020
{
2121
IDatabase db = GetCleanDatabase(endpointId);
@@ -34,7 +34,7 @@ public void TestJsonTransaction(string endpointId)
3434
}
3535

3636
[SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")]
37-
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
37+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
3838
[Obsolete]
3939
public void TestModulesTransaction(string endpointId)
4040
{

0 commit comments

Comments
 (0)