Skip to content

Enable testing against CE 8.0-M2 and M3 #380

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

Merged
merged 7 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ runs:

- name: Test
shell: bash
env:
REDIS_VERSION: ${{ inputs.redis-version }}
run: |
echo "::group::Run tests"
echo "${{inputs.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_ca.pem
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
max-parallel: 15
fail-fast: false
matrix:
redis-version: [ '${{ needs.redis_version.outputs.CURRENT }}', '7.2.6', '6.2.16']
redis-version: [ '8.0-M02', '8.0-M03', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.6', '6.2.16']
dotnet-version: ['6.0', '7.0', '8.0']
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
Expand Down Expand Up @@ -104,5 +104,7 @@ jobs:
./redis-stack-server-${{env.redis_stack_version}}/bin/redis-cli INFO SERVER | grep redis_version
- name: Test
shell: cmd
env:
REDIS_VERSION: ${{env.redis_stack_version}}
run: |
dotnet test -f net481 --no-build --verbosity detailed -p:BuildInParallel=false tests/Test.proj --logger GitHubActions
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public async Task TestQueryAsync(string endpointId)
}

[SkipIfRedis(Is.Enterprise)]
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
public void TestMerge(string endpointId)
{
var db = GetCleanDatabase(endpointId);
Expand Down Expand Up @@ -264,7 +264,7 @@ public void TestMerge(string endpointId)


[SkipIfRedis(Is.Enterprise)]
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
public async Task TestMergeAsync(string endpointId)
{
var db = GetCleanDatabase(endpointId);
Expand Down
4 changes: 3 additions & 1 deletion tests/NRedisStack.Tests/Graph/GraphTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Xunit;
using StackExchange.Redis;
using NRedisStack.RedisStackCommands;
Expand All @@ -6,6 +7,7 @@

namespace NRedisStack.Tests.Graph;

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

Expand Down
1 change: 1 addition & 0 deletions tests/NRedisStack.Tests/NRedisStack.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="Validation" Version="2.6.68" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" />
<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
2 changes: 1 addition & 1 deletion tests/NRedisStack.Tests/Search/IndexCreationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void TestMissingEmptyFieldCommandArgs()
}

[SkipIfRedis(Comparison.LessThan, "7.3.240")]
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
public void TestMissingFields(string endpointId)
{
IDatabase db = GetCleanDatabase(endpointId);
Expand Down
15 changes: 2 additions & 13 deletions tests/NRedisStack.Tests/SkipIfRedisAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xunit;
using Xunit.Sdk;

namespace NRedisStack.Tests;

Expand All @@ -14,6 +15,7 @@ public enum Is
}

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer("NRedisStack.Tests.SkippableTheoryDiscoverer", "NRedisStack.Tests")]
public class SkipIfRedisAttribute : SkippableTheoryAttribute
{
private readonly string _targetVersion;
Expand All @@ -30,19 +32,6 @@ public SkipIfRedisAttribute(
_targetVersion = targetVersion;
}

// skip more than one environment:
public SkipIfRedisAttribute(
Is environment1,
Is environment2,
Comparison comparison = Comparison.LessThan,
string targetVersion = "0.0.0")
{
_environments.Add(environment1);
_environments.Add(environment2);
_comparison = comparison;
_targetVersion = targetVersion;
}

public SkipIfRedisAttribute(string targetVersion) // defaults to LessThan
{
_comparison = Comparison.LessThan;
Expand Down
61 changes: 61 additions & 0 deletions tests/NRedisStack.Tests/SkippableTheoryDiscoverer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Xunit.Sdk;

namespace NRedisStack.Tests;

// TODO(imalinovskiy): Remove this file once tests are migrated to Xunit v3

/// Copyright (c) Andrew Arnott. All rights reserved.
// Licensed under the Microsoft Public License (Ms-PL).
// https://github.com/AArnott/Xunit.SkippableFact/blob/main/src/Xunit.SkippableFact/Sdk/SkippableTheoryDiscoverer.cs
// See https://github.com/AArnott/Xunit.SkippableFact/blob/main/LICENSE for full license information.

using System.Collections.Generic;
using Validation;
using Xunit.Abstractions;

/// <summary>
/// Patched TestCase discoverer to support SkipIfRedisAttribute.
/// </summary>
public class SkippableTheoryDiscoverer : IXunitTestCaseDiscoverer
{
/// <summary>
/// The diagnostic message sink provided to the constructor.
/// </summary>
private readonly IMessageSink diagnosticMessageSink;

/// <summary>
/// The complex theory discovery process that we wrap.
/// </summary>
private readonly TheoryDiscoverer theoryDiscoverer;

/// <summary>
/// Initializes a new instance of the <see cref="SkippableTheoryDiscoverer"/> class.
/// </summary>
/// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages.</param>
public SkippableTheoryDiscoverer(IMessageSink diagnosticMessageSink)
{
this.diagnosticMessageSink = diagnosticMessageSink;
this.theoryDiscoverer = new TheoryDiscoverer(diagnosticMessageSink);
}

/// <inheritdoc />
public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
Requires.NotNull(factAttribute, nameof(factAttribute));
string[] skippingExceptionNames = new[] { "Xunit.SkippableFact.SkipException" };
TestMethodDisplay defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();

IEnumerable<IXunitTestCase>? basis = this.theoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute);
foreach (IXunitTestCase? testCase in basis)
{
if (testCase is XunitTheoryTestCase)
{
yield return new SkippableTheoryTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod);
}
else
{
yield return new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod, testCase.TestMethodArguments);
}
}
}
}
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/TransactionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public TransactionTests(EndpointsFixture endpointsFixture) : base(endpointsFixtu
}

[SkippableTheory]
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
public void TestJsonTransaction(string endpointId)
{
IDatabase db = GetCleanDatabase(endpointId);
Expand All @@ -34,7 +34,7 @@ public void TestJsonTransaction(string endpointId)
}

[SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")]
[MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))]
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
[Obsolete]
public void TestModulesTransaction(string endpointId)
{
Expand Down
Loading