From af34b9c482eb573c5fc172ab571a7f38470a327e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 10 Aug 2023 13:28:10 +0300 Subject: [PATCH 01/48] delete mock --- tests/NRedisStack.Tests/Bloom/BloomTests.cs | 2 -- tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs | 2 -- tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs | 2 -- tests/NRedisStack.Tests/Examples/ExampleTests.cs | 2 -- tests/NRedisStack.Tests/Gears/GearsTests.cs | 2 -- tests/NRedisStack.Tests/Graph/GraphTests.cs | 2 -- tests/NRedisStack.Tests/Json/JsonTests.cs | 11 ----------- tests/NRedisStack.Tests/NRedisStack.Tests.csproj | 1 - tests/NRedisStack.Tests/PipelineTests.cs | 2 -- tests/NRedisStack.Tests/Search/SearchTests.cs | 2 -- tests/NRedisStack.Tests/Tdigest/TdigestTests.cs | 2 -- tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs | 2 -- tests/NRedisStack.Tests/TopK/TopKTests.cs | 2 -- tests/NRedisStack.Tests/TransactionsTests.cs | 6 ++---- 14 files changed, 2 insertions(+), 38 deletions(-) diff --git a/tests/NRedisStack.Tests/Bloom/BloomTests.cs b/tests/NRedisStack.Tests/Bloom/BloomTests.cs index 201fb2e5..b4909b55 100644 --- a/tests/NRedisStack.Tests/Bloom/BloomTests.cs +++ b/tests/NRedisStack.Tests/Bloom/BloomTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.Bloom; public class BloomTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "BLOOM_TESTS"; public BloomTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs index cbef55ca..3929764e 100644 --- a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs +++ b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.CuckooFilter; public class CmsTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "CMS_TESTS"; public CmsTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index c2e74c06..685b5276 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.CuckooFilter; public class CuckooTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "CUCKOO_TESTS"; public CuckooTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index b549f0ad..49f98060 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -1,7 +1,6 @@ using System.Net.Security; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -using Moq; using NRedisStack.DataTypes; using NRedisStack.RedisStackCommands; using NRedisStack.Search; @@ -21,7 +20,6 @@ namespace NRedisStack.Tests; public class ExampleTests : AbstractNRedisStackTest, IDisposable { private readonly ITestOutputHelper testOutputHelper; - Mock _mock = new Mock(); private readonly string key = "EXAMPLES_TESTS"; public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelper) : base(redisFixture) { diff --git a/tests/NRedisStack.Tests/Gears/GearsTests.cs b/tests/NRedisStack.Tests/Gears/GearsTests.cs index 79d7f7ae..6a4b1009 100644 --- a/tests/NRedisStack.Tests/Gears/GearsTests.cs +++ b/tests/NRedisStack.Tests/Gears/GearsTests.cs @@ -1,12 +1,10 @@ using Xunit; using StackExchange.Redis; -using Moq; namespace NRedisStack.Tests.Gears; public class GearsTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "BLOOM_TESTS"; public GearsTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index d539de78..2f0c6af0 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -1,7 +1,6 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; using NRedisStack.Graph; using NRedisStack.Graph.DataTypes; @@ -9,7 +8,6 @@ namespace NRedisStack.Tests.Graph; public class GraphTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "GRAPH_TESTS"; public GraphTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index f437af67..f530ba4d 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -2,7 +2,6 @@ using System.Text.Json.Nodes; using Xunit; using StackExchange.Redis; -using Moq; using NRedisStack.RedisStackCommands; using NRedisStack.Json.DataTypes; @@ -10,7 +9,6 @@ namespace NRedisStack.Tests; public class JsonTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string _testName = "JSON_TESTS"; public JsonTests(RedisFixture redisFixture) : base(redisFixture) { } @@ -100,15 +98,6 @@ public void TestSetFromDirectory() Directory.Delete("BaseDir", true); } - [Fact] - public void TestJsonSetNotExist() - { - var obj = new Person { Name = "Shachar", Age = 23 }; - _mock.Setup(x => x.Execute(It.IsAny(), It.IsAny())).Returns((RedisResult.Create(new RedisValue("OK")))); - _mock.Object.JSON().Set("Person:Shachar", "$", obj, When.NotExists); - _mock.Verify(x => x.Execute("JSON.SET", "Person:Shachar", "$", "{\"Name\":\"Shachar\",\"Age\":23}", "NX")); - } - [Fact] public void TestModulePrefixs() { diff --git a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj index bc4184b6..aa4d38d6 100644 --- a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj +++ b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj @@ -20,7 +20,6 @@ all - diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 8eba3289..5eb1b079 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -1,7 +1,6 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; using System.Text.Json; using NRedisStack.Search; @@ -9,7 +8,6 @@ namespace NRedisStack.Tests; public class PipelineTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "PIPELINE_TESTS"; public PipelineTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 9d2e4eb9..94107829 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -1,7 +1,6 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; using NRedisStack.Search; using static NRedisStack.Search.Schema; using NRedisStack.Search.Aggregation; @@ -12,7 +11,6 @@ namespace NRedisStack.Tests.Search; public class SearchTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); // private readonly string key = "SEARCH_TESTS"; private readonly string index = "TEST_INDEX"; public SearchTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs index 99f866b3..c5a47cd8 100644 --- a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs +++ b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.Tdigest; public class TdigestTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "TDIGEST_TESTS"; public TdigestTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs index dbaca333..7e8b568a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs @@ -1,14 +1,12 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.TimeSeries; public class TimeSeriesTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "TIME_SERIES_TESTS"; public TimeSeriesTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 5f720a97..f51e4f9f 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.TopK; public class TopKTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "TOPK_TESTS"; public TopKTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 32533126..3a741852 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -1,5 +1,4 @@ -using Moq; -using NRedisStack.RedisStackCommands; +using NRedisStack.RedisStackCommands; using NRedisStack.Search; using StackExchange.Redis; using System.Text.Json; @@ -9,8 +8,7 @@ namespace NRedisStack.Tests { public class TransactionTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); - private readonly string key = "TRX_TESTS"; + private readonly string key = "TRX_TESTS"; public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() From ff101b573f7d0801305b019eb5e70067a1389a41 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 10 Aug 2023 14:09:13 +0300 Subject: [PATCH 02/48] coverage --- tests/NRedisStack.Tests/Json/JsonTests.cs | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index f530ba4d..c4834ee4 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -98,6 +98,34 @@ public void TestSetFromDirectory() Directory.Delete("BaseDir", true); } + [Fact] + public void TestJsonSetNotExist() + { + //arrange + var conn = redisFixture.Redis; + var db = conn.GetDatabase(); + IJsonCommands commands = new JsonCommands(db); + + var obj = new Person { Name = "Shachar", Age = 23 }; + Assert.True(commands.Set("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(commands.Set("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(commands.Set("Person:Shachar", "$", obj, When.Exists)); + } + + [Fact] + public async Task TestJsonSetNotExistAsync() + { + //arrange + var conn = redisFixture.Redis; + var db = conn.GetDatabase(); + IJsonCommandsAsync commands = new JsonCommands(db); + + var obj = new Person { Name = "Shachar", Age = 23 }; + Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.Exists)); + } + [Fact] public void TestModulePrefixs() { From c2b5fe6957550bb1491273aac48a1d74ca00f298 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 10 Aug 2023 14:49:38 +0300 Subject: [PATCH 03/48] fix test --- tests/NRedisStack.Tests/Json/JsonTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index c4834ee4..1532a84b 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -105,11 +105,12 @@ public void TestJsonSetNotExist() var conn = redisFixture.Redis; var db = conn.GetDatabase(); IJsonCommands commands = new JsonCommands(db); + db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; Assert.True(commands.Set("Person:Shachar", "$", obj, When.NotExists)); Assert.False(commands.Set("Person:Shachar", "$", obj, When.NotExists)); - Assert.False(commands.Set("Person:Shachar", "$", obj, When.Exists)); + Assert.True(commands.Set("Person:Shachar", "$", obj, When.Exists)); } [Fact] @@ -119,11 +120,12 @@ public async Task TestJsonSetNotExistAsync() var conn = redisFixture.Redis; var db = conn.GetDatabase(); IJsonCommandsAsync commands = new JsonCommands(db); + db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); - Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.Exists)); + Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.Exists)); } [Fact] From f8f2aecc31bb0c43ae4d2edf56ff325bdd2dcb04 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Sun, 13 Aug 2023 15:56:53 +0300 Subject: [PATCH 04/48] indent --- tests/NRedisStack.Tests/TransactionsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 3a741852..dbfc61e4 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -8,7 +8,7 @@ namespace NRedisStack.Tests { public class TransactionTests : AbstractNRedisStackTest, IDisposable { - private readonly string key = "TRX_TESTS"; + private readonly string key = "TRX_TESTS"; public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() From 27a69c0bc5f7a46b84f6bff06ec4b9cb8ed56f05 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 14 Aug 2023 15:09:47 +0300 Subject: [PATCH 05/48] change to var - check --- tests/NRedisStack.Tests/Json/JsonTests.cs | 104 +++++++++++----------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 69cd141e..2fd6f74b 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -23,7 +23,7 @@ public void TestSetFromFile() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(1); //creating json string: @@ -51,7 +51,7 @@ public void TestSetFromDirectory() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); //creating json string: object[] persons = new object[10]; @@ -104,7 +104,7 @@ public void TestJsonSetNotExist() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; @@ -119,7 +119,7 @@ public async Task TestJsonSetNotExistAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommands(db); + var commands = new JsonCommands(db); db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; @@ -146,7 +146,7 @@ public void TestResp() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(1); var key = keys[0]; @@ -171,7 +171,7 @@ public async Task TestRespAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); var key = keys[0]; @@ -196,7 +196,7 @@ public void TestStringAppend() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -224,7 +224,7 @@ public async Task TestStringAppendAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -252,7 +252,7 @@ public void StringLength() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleStringKey = keys[1]; @@ -277,7 +277,7 @@ public async Task StringLengthAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleStringKey = keys[1]; @@ -302,7 +302,7 @@ public void Toggle() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -324,7 +324,7 @@ public async Task ToggleAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -346,7 +346,7 @@ public void Type() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -370,7 +370,7 @@ public async Task TypeAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -393,7 +393,7 @@ public void ArrayAppend() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -411,7 +411,7 @@ public async Task ArrayAppendAsync() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -429,7 +429,7 @@ public void ArrayIndex() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { name = "Elizabeth", nicknames = new[] { "Beth", "Betty", "Liz" }, sibling = new { name = "Johnathan", nicknames = new[] { "Jon", "Johnny" } } }); @@ -443,7 +443,7 @@ public async Task ArrayIndexAsync() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { name = "Elizabeth", nicknames = new[] { "Beth", "Betty", "Liz" }, sibling = new { name = "Johnathan", nicknames = new[] { "Jon", "Johnny" } } }); @@ -455,7 +455,7 @@ public async Task ArrayIndexAsync() [Fact] public void ArrayInsert() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -472,7 +472,7 @@ public void ArrayInsert() [Fact] public async Task ArrayInsertAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -489,7 +489,7 @@ public async Task ArrayInsertAsync() [Fact] public void ArrayLength() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -505,7 +505,7 @@ public void ArrayLength() [Fact] public async Task ArrayLengthAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -521,7 +521,7 @@ public async Task ArrayLengthAsync() [Fact] public void ArrayPop() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -539,7 +539,7 @@ public void ArrayPop() [Fact] public async Task ArrayPopAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -557,7 +557,7 @@ public async Task ArrayPopAsync() [Fact] public void ArrayTrim() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -573,7 +573,7 @@ public void ArrayTrim() [Fact] public async Task ArrayTrimAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -589,7 +589,7 @@ public async Task ArrayTrimAsync() [Fact] public void Clear() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -605,7 +605,7 @@ public void Clear() [Fact] public async Task ClearAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -621,7 +621,7 @@ public async Task ClearAsync() [Fact] public void Del() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -637,7 +637,7 @@ public void Del() [Fact] public async Task DelAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -653,7 +653,7 @@ public async Task DelAsync() [Fact] public void Forget() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -669,7 +669,7 @@ public void Forget() [Fact] public async Task ForgetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -685,7 +685,7 @@ public async Task ForgetAsync() [Fact] public void Get() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -705,7 +705,7 @@ public void Get() [Fact] public async Task GetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -725,7 +725,7 @@ public async Task GetAsync() [SkipIfRedisVersion("7.1.242")] public void MSet() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -749,7 +749,7 @@ public void MSet() [SkipIfRedisVersion("7.1.242")] public async Task MSetAsync() { - IJsonCommandsAsync commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -773,7 +773,7 @@ await commands.MSetAsync(values) public void Merge() { // Create a connection to Redis - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); Assert.True(commands.Set("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); Assert.True(commands.Merge("test_merge", "$", new { person = new { age = 30 } })); @@ -792,7 +792,7 @@ public void Merge() public async Task MergeAsync() { // Create a connection to Redis - IJsonCommandsAsync commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); Assert.True(await commands.SetAsync("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); Assert.True(await commands.MergeAsync("test_merge", "$", new { person = new { age = 30 } })); @@ -810,7 +810,7 @@ public async Task MergeAsync() [Fact] public void MGet() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -825,7 +825,7 @@ public void MGet() [Fact] public async Task MGetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -840,7 +840,7 @@ public async Task MGetAsync() [Fact] public void NumIncrby() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { age = 33, a = new { age = 34 }, b = new { age = "cat" } }); @@ -853,7 +853,7 @@ public void NumIncrby() [Fact] public async Task NumIncrbyAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { age = 33, a = new { age = 34 }, b = new { age = "cat" } }); @@ -866,7 +866,7 @@ public async Task NumIncrbyAsync() [Fact] public void ObjectKeys() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; commands.Set(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -884,7 +884,7 @@ public void ObjectKeys() [Fact] public async Task ObjectKeysAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; await commands.SetAsync(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -902,7 +902,7 @@ public async Task ObjectKeysAsync() [Fact] public void ObjectLength() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; commands.Set(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -918,7 +918,7 @@ public void ObjectLength() [Fact] public async Task ObjectLengthAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; await commands.SetAsync(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -934,7 +934,7 @@ public async Task ObjectLengthAsync() [Fact] public void TestMultiPathGet() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { a = "hello", b = new { a = "world" } }); @@ -958,7 +958,7 @@ public void TestMultiPathGet() [Fact] public async Task TestMultiPathGetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { a = "hello", b = new { a = "world" } }); @@ -982,7 +982,7 @@ public async Task TestMultiPathGetAsync() [Fact] public void Memory() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; @@ -996,7 +996,7 @@ public void Memory() [Fact] public async Task MemoryAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; @@ -1013,7 +1013,7 @@ public async Task TestSetFromFileAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); //creating json string: @@ -1041,7 +1041,7 @@ public async Task TestSetFromDirectoryAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); //creating json string: object[] persons = new object[10]; From dc0d3c0187c48423a510336c6727daeaa0c0fee8 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 14 Aug 2023 17:51:46 +0300 Subject: [PATCH 06/48] cluster test --- .../Clusters/ClusterTests.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/NRedisStack.Tests/Clusters/ClusterTests.cs diff --git a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs new file mode 100644 index 00000000..2a0a59c7 --- /dev/null +++ b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs @@ -0,0 +1,42 @@ +using StackExchange.Redis; +using Xunit; + +namespace NRedisStack.Tests; + +public class ClusterTests : AbstractNRedisStackTest, IDisposable +{ + private readonly string key = "CLUSTER_TESTS"; + public ClusterTests(RedisFixture redisFixture) : base(redisFixture) { } + + public void Dispose() + { + redisFixture.Redis.GetDatabase().KeyDelete(key); + } + + [Fact(Skip = "This test needs to run on a cluster")] + public void ClusterConnect() + { + // first, run a cluster, + ConfigurationOptions config = new ConfigurationOptions + { + // ports: 16379 -> 16384 + EndPoints = + { + { "127.0.0.1", 16379 }, + { "127.0.0.1", 16380 }, + { "127.0.0.1", 16381 }, + { "127.0.0.1", 16382 }, + { "127.0.0.1", 16383 }, + { "127.0.0.1", 16384 }, + }, + }; + var conn = ConnectionMultiplexer.Connect(config); + IDatabase clusterDB = conn.GetDatabase(); + clusterDB.KeyDelete("foo"); + clusterDB.StringSet("foo", "bar"); + var value = clusterDB.StringGet("foo"); + Assert.Equal("bar", value); + // var endpoints = conn.GetEndPoints(); + // Console.WriteLine("endpoints:" + endpoints.ToString()); + } +} From eeb2edf7204e2a19ab556af4557ab65db5e0d66d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 15 Aug 2023 17:08:19 +0300 Subject: [PATCH 07/48] add opthin to connect cluster with dotnet test --- tests/NRedisStack.Tests/RedisFixture.cs | 39 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs index 8ae470f2..297e60ad 100644 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ b/tests/NRedisStack.Tests/RedisFixture.cs @@ -1,14 +1,47 @@ +using System.Net; +using Org.BouncyCastle.Tls; using StackExchange.Redis; namespace NRedisStack.Tests { public class RedisFixture : IDisposable { + // Set the enviroment variable to specify your own alternet host and port: + string redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + string? redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); + string? numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); + // bool redisClusterMode = false; // TODO: check if this is needed + + public RedisFixture() + { + // Redis Cluster + if (redisCluster != null && numRedisClusterNodesEnv != null) + { + // Split to host and port + string[] parts = redisCluster.Split(':'); + string host = parts[0]; + int startPort = int.Parse(parts[1]); + var endpoints = new EndPointCollection(); + int numRedisClusterNodes = int.Parse(numRedisClusterNodesEnv); + for (int i = 0; i < numRedisClusterNodes; i++) + { + endpoints.Add(host, startPort + i); + } - // Set the enviroment variable to specify your own alternet host and port: - string redis = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - public RedisFixture() => Redis = ConnectionMultiplexer.Connect($"{redis}"); + + ConfigurationOptions clusterConfig = new ConfigurationOptions + { + EndPoints = endpoints + }; + // redisClusterMode = true; + Redis = ConnectionMultiplexer.Connect(clusterConfig); + } + + // Redis Standalone + else + Redis = ConnectionMultiplexer.Connect($"{redisStandalone}"); + } public void Dispose() { From 0d100d7545ced4f0a68386b26bdc32bc2300a4e7 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 16 Aug 2023 15:10:58 +0300 Subject: [PATCH 08/48] use key in topk tests --- tests/NRedisStack.Tests/TopK/TopKTests.cs | 39 ++++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index f51e4f9f..5d8220c2 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -21,30 +21,31 @@ public void CreateTopKFilter() db.Execute("FLUSHALL"); var topk = db.TOPK(); - topk.Reserve("aaa", 30, 2000, 7, 0.925); + //db.KeyDelete(key, CommandFlags.FireAndForget); + topk.Reserve(key, 30, 2000, 7, 0.925); - var res = topk.Add("aaa", "bb", "cc"); + var res = topk.Add(key, "bb", "cc"); Assert.True(res[0].IsNull && res[1].IsNull); - Assert.Equal(topk.Query("aaa", "bb", "gg", "cc"), new bool[] { true, false, true }); - Assert.False(topk.Query("aaa", "notExists")); + Assert.Equal(topk.Query(key, "bb", "gg", "cc"), new bool[] { true, false, true }); + Assert.False(topk.Query(key, "notExists")); - Assert.Equal(topk.Count("aaa", "bb", "gg", "cc"), new long[] { 1, 0, 1 }); + Assert.Equal(topk.Count(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); - var res2 = topk.List("aaa"); + var res2 = topk.List(key); Assert.Equal(res2[0].ToString(), "bb"); Assert.Equal(res2[1].ToString(), "cc"); var tuple = new Tuple("ff", 10); - var del = topk.IncrBy("aaa", tuple); - Assert.True(topk.IncrBy("aaa", tuple)[0].IsNull); + var del = topk.IncrBy(key, tuple); + Assert.True(topk.IncrBy(key, tuple)[0].IsNull); - res2 = topk.List("aaa"); + res2 = topk.List(key); Assert.Equal(res2[0].ToString(), "ff"); Assert.Equal(res2[1].ToString(), "bb"); Assert.Equal(res2[2].ToString(), "cc"); - var info = topk.Info("aaa"); + var info = topk.Info(key); Assert.Equal(info.Decay, 0.925); Assert.Equal(info.Depth, 7); Assert.Equal(info.K, 30); @@ -58,29 +59,29 @@ public async Task CreateTopKFilterAsync() db.Execute("FLUSHALL"); var topk = db.TOPK(); - await topk.ReserveAsync("aaa", 30, 2000, 7, 0.925); + await topk.ReserveAsync(key, 30, 2000, 7, 0.925); - var res = await topk.AddAsync("aaa", "bb", "cc"); + var res = await topk.AddAsync(key, "bb", "cc"); Assert.True(res[0].IsNull && res[1].IsNull); - Assert.Equal(await topk.QueryAsync("aaa", "bb", "gg", "cc"), new bool[] { true, false, true }); - Assert.False(await topk.QueryAsync("aaa", "notExists")); + Assert.Equal(await topk.QueryAsync(key, "bb", "gg", "cc"), new bool[] { true, false, true }); + Assert.False(await topk.QueryAsync(key, "notExists")); - Assert.Equal(await topk.CountAsync("aaa", "bb", "gg", "cc"), new long[] { 1, 0, 1 }); + Assert.Equal(await topk.CountAsync(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); - var res2 = await topk.ListAsync("aaa"); + var res2 = await topk.ListAsync(key); Assert.Equal(res2[0].ToString(), "bb"); Assert.Equal(res2[1].ToString(), "cc"); var tuple = new Tuple("ff", 10); - Assert.True((await topk.IncrByAsync("aaa", tuple))[0].IsNull); + Assert.True((await topk.IncrByAsync(key, tuple))[0].IsNull); - res2 = await topk.ListAsync("aaa"); + res2 = await topk.ListAsync(key); Assert.Equal(res2[0].ToString(), "ff"); Assert.Equal(res2[1].ToString(), "bb"); Assert.Equal(res2[2].ToString(), "cc"); - var info = await topk.InfoAsync("aaa"); + var info = await topk.InfoAsync(key); Assert.Equal(info.Decay, 0.925); Assert.Equal(info.Depth, 7); Assert.Equal(info.K, 30); From 02d183769d02cc262db232716294a43bc12ac484 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 22 Aug 2023 14:24:51 +0300 Subject: [PATCH 09/48] get env vars inside RedisFixture --- tests/NRedisStack.Tests/RedisFixture.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs index 297e60ad..f52c87e1 100644 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ b/tests/NRedisStack.Tests/RedisFixture.cs @@ -6,14 +6,13 @@ namespace NRedisStack.Tests { public class RedisFixture : IDisposable { - // Set the enviroment variable to specify your own alternet host and port: - string redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - string? redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); - string? numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); - // bool redisClusterMode = false; // TODO: check if this is needed - public RedisFixture() { + // Set the enviroment variable to specify your own alternet host and port: + var redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + var redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); + var numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); + // bool redisClusterMode = false; // TODO: check if this is needed // Redis Cluster if (redisCluster != null && numRedisClusterNodesEnv != null) { From 65a49b62c925b3a3e20edff6af06de34d02a558d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 22 Aug 2023 17:20:57 +0300 Subject: [PATCH 10/48] skip if redis --- .../Examples/ExampleTests.cs | 14 +- tests/NRedisStack.Tests/Gears/GearsTests.cs | 14 +- tests/NRedisStack.Tests/Graph/GraphTests.cs | 128 ++++++++--------- tests/NRedisStack.Tests/Json/JsonTests.cs | 8 +- tests/NRedisStack.Tests/PipelineTests.cs | 2 +- tests/NRedisStack.Tests/Search/SearchTests.cs | 130 +++++++++--------- .../NRedisStack.Tests/SkipIfRedisAttribute.cs | 109 +++++++++++++++ .../SkipIfRedisVersionAttribute.cs | 55 -------- tests/NRedisStack.Tests/TransactionsTests.cs | 2 +- 9 files changed, 258 insertions(+), 204 deletions(-) create mode 100644 tests/NRedisStack.Tests/SkipIfRedisAttribute.cs delete mode 100644 tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 49f98060..14d11a58 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -31,7 +31,7 @@ public void Dispose() redisFixture.Redis.GetDatabase().KeyDelete(key); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void HSETandSearch() { // Connect to the Redis server @@ -132,7 +132,7 @@ public void PipelineExample() Assert.Equal(expected, result.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task JsonWithSearchPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -176,7 +176,7 @@ public async Task JsonWithSearchPipeline() // Assert.Equal("person:01", firstPerson?.Id); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task PipelineWithAsync() { // Connect to the Redis server @@ -234,7 +234,7 @@ public async Task PipelineWithAsync() Assert.Equal("temp:JLM", respons[0].key); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TransactionExample() { // Connect to the Redis server @@ -278,7 +278,7 @@ public async Task TransactionExample() Assert.Equal("[1200]", totalAmtOfShachar.Result.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestJsonConvert() { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); @@ -960,7 +960,7 @@ public void AdvancedJsonExamplesTest() Assert.Equal(expected, res.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void BasicQueryOperationsTest() { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); @@ -1120,7 +1120,7 @@ public void BasicQueryOperationsTest() Assert.Equal(expected, res[0].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void AdvancedQueryOperationsTest() { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); diff --git a/tests/NRedisStack.Tests/Gears/GearsTests.cs b/tests/NRedisStack.Tests/Gears/GearsTests.cs index 9651f53e..9070f3ad 100644 --- a/tests/NRedisStack.Tests/Gears/GearsTests.cs +++ b/tests/NRedisStack.Tests/Gears/GearsTests.cs @@ -14,7 +14,7 @@ public void Dispose() } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestTFunctionLoadDelete() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -24,7 +24,7 @@ public void TestTFunctionLoadDelete() } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public async Task TestTFunctionLoadDeleteAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -35,7 +35,7 @@ public async Task TestTFunctionLoadDeleteAsync() Assert.True(await db.TFunctionDeleteAsync("lib")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestTFunctionList() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -66,7 +66,7 @@ public void TestTFunctionList() Assert.True(db.TFunctionDelete("lib3")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public async Task TestTFunctionListAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -95,7 +95,7 @@ public async Task TestTFunctionListAsync() Assert.True(await db.TFunctionDeleteAsync("lib3")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestTFCall() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -109,7 +109,7 @@ public void TestTFCall() Assert.True(db.TFunctionDelete("lib")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public async Task TestTFCallAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -123,7 +123,7 @@ public async Task TestTFCallAsync() Assert.True(await db.TFunctionDeleteAsync("lib")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestGearsCommandBuilder() { // TFunctionLoad: diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 05df345f..3b3edf56 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -18,7 +18,7 @@ public void Dispose() #region SyncTests - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestReserveBasic() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -26,7 +26,7 @@ public void TestReserveBasic() var graph = db.GRAPH(); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCreateNode() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -49,7 +49,7 @@ public void TestCreateNode() graph.Delete("social"); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCreateLabeledNode() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -70,7 +70,7 @@ public void TestCreateLabeledNode() // Assert.False(resultSet..iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestConnectNodes() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -97,7 +97,7 @@ public void TestConnectNodes() Assert.Equal(0, resultSet.Count); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestDeleteNodes() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -144,7 +144,7 @@ public void TestDeleteNodes() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestDeleteRelationship() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -174,7 +174,7 @@ public void TestDeleteRelationship() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestIndex() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -201,7 +201,7 @@ public void TestIndex() Assert.Equal(1, deleteExistingIndexResult.Statistics.IndicesDeleted); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestHeader() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -232,7 +232,7 @@ public void TestHeader() Assert.Equal("a.age", schemaNames[2]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestRecord() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -357,7 +357,7 @@ public void TestRecord() } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestAdditionToProcedures() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -437,7 +437,7 @@ record = iterator.Current; Assert.Equal(expectedEdge.ToString(), record.Values[1].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestEscapedQuery() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -456,7 +456,7 @@ public void TestEscapedQuery() Assert.NotNull(graph.Query("social", "MATCH (n) where n.s1='S\"' RETURN n")); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestArraySupport() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -556,7 +556,7 @@ record = iterator.Current; } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestPath() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -608,7 +608,7 @@ public void TestPath() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestNullGraphEntities() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -662,7 +662,7 @@ record = resultSet.Skip(1).First(); Assert.Null(record.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void Test64BitNumber() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -680,7 +680,7 @@ public void Test64BitNumber() } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCachedExecution() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -711,7 +711,7 @@ public void TestCachedExecution() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestMapDataType() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -741,7 +741,7 @@ public void TestMapDataType() Assert.Equal((object)expected, actual); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestGeoPointLatLon() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -755,7 +755,7 @@ public void TestGeoPointLatLon() AssertTestGeoPoint(graph); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestGeoPointLonLat() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -784,7 +784,7 @@ private void AssertTestGeoPoint(IGraphCommands graph) Assert.Equal((object)(point), property); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestPoint() { var point = new Point(30.27822306, -97.75134723); @@ -796,7 +796,7 @@ public void TestPoint() Assert.Throws(() => new Point(new List { 1, 2, 3 })); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void timeoutArgument() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -810,7 +810,7 @@ public void timeoutArgument() Assert.Equal(100l, (long)r.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCachedExecutionReadOnly() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -843,7 +843,7 @@ public void TestCachedExecutionReadOnly() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestSimpleReadOnly() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -858,7 +858,7 @@ public void TestSimpleReadOnly() Assert.Equal("30", r.Values[0].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestProfile() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -876,7 +876,7 @@ public void TestProfile() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestExplain() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -894,7 +894,7 @@ public void TestExplain() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestSlowlog() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -909,7 +909,7 @@ public void TestSlowlog() slowlogs.ForEach(sl => sl.ForEach(s => Assert.NotNull(s))); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestList() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -922,7 +922,7 @@ public void TestList() Assert.Equal(new List() { "social" }, graph.List()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestConfig() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -942,7 +942,7 @@ public void TestConfig() graph.ConfigSet(name, existingValue != null ? existingValue.ToString() : -1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestModulePrefixs() { IDatabase db1 = redisFixture.Redis.GetDatabase(); @@ -954,7 +954,7 @@ public void TestModulePrefixs() Assert.NotEqual(graph1.GetHashCode(), graph2.GetHashCode()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCallProcedureDbLabels() { var db = redisFixture.Redis.GetDatabase(); @@ -975,7 +975,7 @@ public void TestCallProcedureDbLabels() Assert.Single(labels1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCallProcedureReadOnly() { var db = redisFixture.Redis.GetDatabase(); @@ -1001,7 +1001,7 @@ public void TestCallProcedureReadOnly() #region AsyncTests - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestReserveBasicAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1009,7 +1009,7 @@ public async Task TestReserveBasicAsync() var graph = db.GRAPH(); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCreateNodeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1032,7 +1032,7 @@ public async Task TestCreateNodeAsync() await graph.DeleteAsync("social"); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCreateLabeledNodeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1053,7 +1053,7 @@ public async Task TestCreateLabeledNodeAsync() // Assert.False(resultSet..iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestConnectNodesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1081,7 +1081,7 @@ public async Task TestConnectNodesAsync() // Assert.False(resultSet.GetEnumerator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestDeleteNodesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1128,7 +1128,7 @@ public async Task TestDeleteNodesAsync() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestDeleteRelationshipAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1158,7 +1158,7 @@ public async Task TestDeleteRelationshipAsync() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestIndexAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1185,7 +1185,7 @@ public async Task TestIndexAsync() Assert.Equal(1, deleteExistingIndexResult.Statistics.IndicesDeleted); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestHeaderAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1216,7 +1216,7 @@ public async Task TestHeaderAsync() Assert.Equal("a.age", schemaNames[2]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestRecordAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1343,7 +1343,7 @@ await graph.QueryAsync("social", "MATCH (a:person), (b:person) WHERE (a.name = ' } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestAdditionToProceduresAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1423,7 +1423,7 @@ record = iterator.Current; Assert.Equal(expectedEdge.ToString(), record.Values[1].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestEscapedQueryAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1442,7 +1442,7 @@ public async Task TestEscapedQueryAsync() Assert.NotNull(await graph.QueryAsync("social", "MATCH (n) where n.s1='S\"' RETURN n")); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestArraySupportAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1542,7 +1542,7 @@ record = iterator.Current; } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestPathAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1594,7 +1594,7 @@ public async Task TestPathAsync() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestNullGraphEntitiesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1648,7 +1648,7 @@ record = resultSet.Skip(1).First(); Assert.Null(record.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task Test64bitnumberAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1666,7 +1666,7 @@ public async Task Test64bitnumberAsync() } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCachedExecutionAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1697,7 +1697,7 @@ public async Task TestCachedExecutionAsync() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestMapDataTypeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1727,7 +1727,7 @@ public async Task TestMapDataTypeAsync() Assert.Equal((object)expected, actual); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestGeoPointLatLonAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1741,7 +1741,7 @@ public async Task TestGeoPointLatLonAsync() AssertTestGeoPoint(graph); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestGeoPointLonLatAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1769,7 +1769,7 @@ private async Task AssertTestGeoPointAsync(GraphCommands graph) Assert.Equal((object)(new Point(30.27822306, -97.75134723)), property); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task timeoutArgumentAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1783,7 +1783,7 @@ public async Task timeoutArgumentAsync() Assert.Equal(100l, (long)r.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCachedExecutionReadOnlyAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1816,7 +1816,7 @@ public async Task TestCachedExecutionReadOnlyAsync() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestSimpleReadOnlyAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1831,7 +1831,7 @@ public async Task TestSimpleReadOnlyAsync() Assert.Equal("30", r.Values[0].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestProfileAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1849,7 +1849,7 @@ public async Task TestProfileAsync() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestExplainAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1867,7 +1867,7 @@ public async Task TestExplainAsync() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestSlowlogAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1882,7 +1882,7 @@ public async Task TestSlowlogAsync() slowlogs.ForEach(sl => sl.ForEach(s => Assert.NotNull(s))); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestListAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1895,7 +1895,7 @@ public async Task TestListAsync() Assert.Equal(new List() { "social" }, await graph.ListAsync()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestConfigAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1915,7 +1915,7 @@ public async Task TestConfigAsync() await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString() : -1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulePrefixsAsync() { IDatabase db1 = redisFixture.Redis.GetDatabase(); @@ -1927,7 +1927,7 @@ public async Task TestModulePrefixsAsync() Assert.NotEqual(graph1.GetHashCode(), graph2.GetHashCode()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCallProcedureDbLabelsAsync() { var db = redisFixture.Redis.GetDatabase(); @@ -1948,7 +1948,7 @@ public async Task TestCallProcedureDbLabelsAsync() Assert.Single(labels1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCallProcedureReadOnlyAsync() { var db = redisFixture.Redis.GetDatabase(); @@ -1970,7 +1970,7 @@ public async Task TestCallProcedureReadOnlyAsync() await Assert.ThrowsAsync(() => graph.CallProcedureAsync(graphName, "db.idx.fulltext.createNodeIndex", procedureArgs, ProcedureMode.Read)); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestParseInfinity() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1984,7 +1984,7 @@ public void TestParseInfinity() Assert.Equal(double.PositiveInfinity, r.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestEqualsAndToString() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2061,7 +2061,7 @@ public void TestEqualsAndToString() Assert.Equal(expectedPathString, pathString); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestPrepareQuery() { const string return1Query = "RETURN 1"; diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 2fd6f74b..1fe517d5 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -722,7 +722,7 @@ public async Task GetAsync() Assert.Equal(35, people[1]!.Age); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public void MSet() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -746,7 +746,7 @@ public void MSet() Assert.Throws(() => commands.MSet(new KeyPathValue[0])); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public async Task MSetAsync() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -769,7 +769,7 @@ await commands.MSetAsync(values) await Assert.ThrowsAsync(async () => await commands.MSetAsync(new KeyPathValue[0])); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public void Merge() { // Create a connection to Redis @@ -788,7 +788,7 @@ public void Merge() Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"phone\":\"123-456-7890\",\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"}}}", commands.Get("test_merge").ToString()); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public async Task MergeAsync() { // Create a connection to Redis diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 0100faad..945e6b62 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -16,7 +16,7 @@ public void Dispose() redisFixture.Redis.GetDatabase().KeyDelete(key); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulsPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index fe471c4b..a1dafb82 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -149,7 +149,7 @@ public async Task TestAggregationRequestTimeoutAsync() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAggregations() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -190,7 +190,7 @@ public void TestAggregations() Assert.Equal(10, r2.GetLong("sum")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationsAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -232,7 +232,7 @@ public async Task TestAggregationsAsync() } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAggregationsLoad() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -260,7 +260,7 @@ public void TestAggregationsLoad() Assert.Equal(res[0]["t2"], "world"); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationsLoadAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -322,7 +322,7 @@ public void TestAggregationRequestParamsDialect() Assert.Equal(10, r1.GetLong("sum")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationRequestParamsDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -390,7 +390,7 @@ public void TestAggregationRequestParamsWithDefaultDialect() Assert.Equal(10, r1.GetLong("sum")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationRequestParamsWithDefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -411,7 +411,7 @@ public async Task TestAggregationRequestParamsWithDefaultDialectAsync() AggregationRequest r = new AggregationRequest("$name") .GroupBy("@name", Reducers.Sum("@count").As("sum")) .Params(parameters); // From documentation - To use PARAMS, DIALECT must be set to 2 - // which is the default as we set in the constructor (FT(2)) + // which is the default as we set in the constructor (FT(2)) AggregationResult res = await ft.AggregateAsync(index, r); Assert.Equal(1, res.TotalResults); @@ -431,7 +431,7 @@ public void TestDefaultDialectError() Assert.Throws(() => db.FT(0)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAlias() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -460,7 +460,7 @@ public void TestAlias() Assert.Throws(() => ft.AliasDel("ALIAS2")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAliasAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -489,7 +489,7 @@ public async Task TestAliasAsync() await Assert.ThrowsAsync(async () => await ft.AliasDelAsync("ALIAS2")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestApplyAndFilterAggregations() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -533,7 +533,7 @@ public void TestApplyAndFilterAggregations() Assert.Equal(67.5, r2.GetDouble("avgscore"), 0); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestCreate() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -565,7 +565,7 @@ public void TestCreate() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCreateAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -591,7 +591,7 @@ public async Task TestCreateAsync() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void CreateNoParams() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -619,7 +619,7 @@ public void CreateNoParams() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task CreateNoParamsAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -647,7 +647,7 @@ public async Task CreateNoParamsAsync() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void CreateWithFieldNames() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -679,7 +679,7 @@ public void CreateWithFieldNames() Assert.Equal(1, nonAttribute.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task CreateWithFieldNamesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -711,7 +711,7 @@ public async Task CreateWithFieldNamesAsync() Assert.Equal(1, nonAttribute.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void AlterAdd() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -775,7 +775,7 @@ public void AlterAdd() Assert.Equal(4, info.CursorStats.Count); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task AlterAddAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -859,7 +859,7 @@ public async Task TestConfigAsnyc() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void configOnTimeout() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -883,7 +883,7 @@ public async Task configOnTimeoutAsync() try { ft.ConfigSet("ON_TIMEOUT", "null"); } catch (RedisServerException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDialectConfig() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -905,7 +905,7 @@ public void TestDialectConfig() Assert.True(ft.ConfigSet("DEFAULT_DIALECT", "1")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestDialectConfigAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -927,7 +927,7 @@ public async Task TestDialectConfigAsync() Assert.True(ft.ConfigSet("DEFAULT_DIALECT", "1")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCursor() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -989,7 +989,7 @@ public async Task TestCursor() catch (RedisException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCursorAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1051,7 +1051,7 @@ public async Task TestCursorAsync() catch (RedisException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAggregationGroupBy() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1159,7 +1159,7 @@ public void TestAggregationGroupBy() } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDictionary() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1178,7 +1178,7 @@ public void TestDictionary() Assert.Equal(ft.DictDump("dict").Length, 0); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDropIndex() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1211,7 +1211,7 @@ public void TestDropIndex() Assert.Equal("100", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestDropIndexAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1244,7 +1244,7 @@ public async Task TestDropIndexAsync() Assert.Equal("100", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void dropIndexDD() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1270,7 +1270,7 @@ public void dropIndexDD() Assert.Equal("0", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task dropIndexDDAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1296,7 +1296,7 @@ public async Task dropIndexDDAsync() Assert.Equal("0", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestDictionaryAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1507,7 +1507,7 @@ public void TestModulePrefixs() Assert.NotEqual(ft1.GetHashCode(), ft2.GetHashCode()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task GetTagFieldSyncAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1565,7 +1565,7 @@ public async Task GetTagFieldSyncAsync() Assert.Equal(SyncRes[i++].ToString(), "yellow"); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1692,7 +1692,7 @@ public void TestFTCreateParamsCommandBuilderNoStopwords() Assert.Equal("FT.CREATE", builedCommand.Command.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestFilters() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1742,7 +1742,7 @@ public void TestFilters() Assert.Equal("doc1", res1.Documents[0].Id); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestFiltersAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1926,7 +1926,7 @@ public void TestQueryCommandBuilderReturnField() Assert.Equal(0, res.Documents.Count()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestQueryCommandBuilderScore() { // TODO: write better test for scores and payloads @@ -2001,7 +2001,7 @@ public void TestFieldsCommandBuilder() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestLimit() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2021,7 +2021,7 @@ public void TestLimit() Assert.Equal(res.GetResults()[0]["t1"].ToString(), "a"); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestLimitAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2093,7 +2093,7 @@ public async Task TestVectorCount_Issue70() Assert.Equal(expected.Count(), actual.Args.Length); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void VectorSimilaritySearch() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2136,7 +2136,7 @@ public void VectorSimilaritySearch() Assert.Equal("{\"vector\":[2,2,2,2]}", jsonRes![0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void QueryingVectorFields() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2184,7 +2184,7 @@ public async Task TestVectorFieldJson_Issue102Async() Assert.True(await ft.CreateAsync("my_index", new FTCreateParams().On(IndexDataType.JSON), schema)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestQueryAddParam_DefaultDialect() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2203,7 +2203,7 @@ public void TestQueryAddParam_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestQueryAddParam_DefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2222,7 +2222,7 @@ public async Task TestQueryAddParam_DefaultDialectAsync() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestQueryParamsWithParams_DefaultDialect() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2250,7 +2250,7 @@ public void TestQueryParamsWithParams_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestBasicSpellCheck() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2270,7 +2270,7 @@ public void TestBasicSpellCheck() Assert.Equal(2, reply["name"]["name2"]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestBasicSpellCheckAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2290,7 +2290,7 @@ public async Task TestBasicSpellCheckAsync() Assert.Equal(2, reply["name"]["name2"]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestCrossTermDictionary() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2314,7 +2314,7 @@ public void TestCrossTermDictionary() .ExcludeTerm("slang"))); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCrossTermDictionaryAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2338,7 +2338,7 @@ public async Task TestCrossTermDictionaryAsync() .ExcludeTerm("slang"))); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDistanceBound() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2386,7 +2386,7 @@ public async Task TestDialectBoundAsync() await Assert.ThrowsAsync(async () => await ft.SpellCheckAsync(index, "name", new FTSpellCheckParams().Dialect(0))); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestQueryParamsWithParams_DefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2651,7 +2651,7 @@ public void TestProfileSearch() var profile = ft.ProfileSearch(index, new Query("foo")); // Iterators profile={Type=TEXT, Time=0.0, Term=foo, Counter=1, Size=1} profile.Item2["Iterators profile"].ToDictionary(); - var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); + var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); Assert.Equal("TEXT", iteratorsProfile["Type"].ToString()); Assert.Equal("foo", iteratorsProfile["Term"].ToString()); Assert.Equal("1", iteratorsProfile["Counter"].ToString()); @@ -2675,7 +2675,7 @@ public async Task TestProfileSearchAsync() var profile = await ft.ProfileSearchAsync(index, new Query("foo")); // Iterators profile={Type=TEXT, Time=0.0, Term=foo, Counter=1, Size=1} profile.Item2["Iterators profile"].ToDictionary(); - var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); + var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); Assert.Equal("TEXT", iteratorsProfile["Type"].ToString()); Assert.Equal("foo", iteratorsProfile["Term"].ToString()); Assert.Equal("1", iteratorsProfile["Counter"].ToString()); @@ -2690,9 +2690,9 @@ public void TestProfile() db.Execute("FLUSHALL"); var ft = db.FT(); - ft.Create(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams - db.HashSet("1", "t", "hello"); - db.HashSet("2", "t", "world"); + ft.Create(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams + db.HashSet("1", "t", "hello"); + db.HashSet("2", "t", "world"); // check using Query var q = new Query("hello|world").SetNoContent(); @@ -2700,15 +2700,15 @@ public void TestProfile() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count , 5); - Assert.Equal(searchRes.Documents.Count , 2); + Assert.Equal(searchDet.Count, 5); + Assert.Equal(searchRes.Documents.Count, 2); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = ft.ProfileAggregate(index, aggReq); - var aggregateRes  = profileAggregate.Item1; + var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count , 5); + Assert.Equal(aggregateDet.Count, 5); Assert.Equal(aggregateRes.TotalResults, 1); } @@ -2719,9 +2719,9 @@ public async Task TestProfileAsync() db.Execute("FLUSHALL"); var ft = db.FT(); - await ft.CreateAsync(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams - db.HashSet("1", "t", "hello"); - db.HashSet("2", "t", "world"); + await ft.CreateAsync(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams + db.HashSet("1", "t", "hello"); + db.HashSet("2", "t", "world"); // check using Query var q = new Query("hello|world").SetNoContent(); @@ -2729,15 +2729,15 @@ public async Task TestProfileAsync() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count , 5); - Assert.Equal(searchRes.Documents.Count , 2); + Assert.Equal(searchDet.Count, 5); + Assert.Equal(searchRes.Documents.Count, 2); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = await ft.ProfileAggregateAsync(index, aggReq); - var aggregateRes  = profileAggregate.Item1; + var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count , 5); + Assert.Equal(aggregateDet.Count, 5); Assert.Equal(aggregateRes.TotalResults, 1); } @@ -2753,7 +2753,7 @@ public void TestProfileCommandBuilder() Assert.Equal(new object[] { "index", "AGGREGATE", "LIMITED", "QUERY", "*" }, aggregate.Args); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void Issue175() { ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs new file mode 100644 index 00000000..55b63ee2 --- /dev/null +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -0,0 +1,109 @@ +using Xunit; +using StackExchange.Redis; +using NRedisStack.Tests; +using System.Text; + +public enum Comparison +{ + LessThan, + GreaterThanOrEqual, +} + +public enum Is +{ + Standalone, + Cluster +} + +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +public class SkipIfRedisAttribute : FactAttribute +{ + private readonly string _targetVersion; + private readonly Comparison _comparison; + private readonly Is? _is = null; + private readonly string DefaultRedisConnectionString = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + + public SkipIfRedisAttribute( + Is _is, + Comparison comparison = Comparison.LessThan, + string targetVersion = "0.0.0") + { + this._is = _is; + _comparison = comparison; + _targetVersion = targetVersion; + } + + public SkipIfRedisAttribute(string targetVersion) // defaults to LessThan + { + _comparison = Comparison.LessThan; + _targetVersion = targetVersion; + } + + public SkipIfRedisAttribute(Comparison comparison, string targetVersion) + { + _comparison = comparison; + _targetVersion = targetVersion; + } + + public override string? Skip + { + get + { + using (var connection = ConnectionMultiplexer.Connect(DefaultRedisConnectionString)) + { + string skipReason = ""; + bool skipped = false; + + // Cluster check + if (_is != null) + { + bool isCluster = connection.GetEndPoints().Length > 1; + switch (_is) + { + case Is.Cluster: + if (isCluster) + { + skipReason = skipReason + " Redis server is a cluster."; + skipped = true; + } + break; + + case Is.Standalone: + if (!isCluster) + { + skipReason = skipReason + " Redis server is not a cluster."; + skipped = true; + } + break; + } + } + // Version check (if Is.Standalone/Is.Cluster is set then ) + var serverVersion = connection.GetServer(connection.GetEndPoints()[0]).Version; + var targetVersion = new Version(_targetVersion); + int comparisonResult = serverVersion.CompareTo(targetVersion); + + switch (_comparison) + { + case Comparison.LessThan: + if (comparisonResult < 0) + { + skipReason = skipReason + $" Redis server version ({serverVersion}) is less than {_targetVersion}."; + skipped = true; + } + break; + case Comparison.GreaterThanOrEqual: + if (comparisonResult >= 0) + { + skipReason = skipReason + $" Redis server version ({serverVersion}) is greater than or equal to {_targetVersion}."; + skipped = true; + } + break; + } + + if (skipped) + return "Test skipped, because:" + skipReason; + return null; + } + } + } +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs deleted file mode 100644 index 6d19bc2c..00000000 --- a/tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Xunit; -using StackExchange.Redis; - -public enum Comparison -{ - LessThan, - GreaterThanOrEqual, -} - -[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -public class SkipIfRedisVersionAttribute : FactAttribute -{ - private readonly string _targetVersion; - private readonly Comparison _comparison; - private readonly string DefaultRedisConnectionString = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - - public SkipIfRedisVersionAttribute(string targetVersion) // defaults to LessThan - { - _comparison = Comparison.LessThan; - _targetVersion = targetVersion; - } - - public SkipIfRedisVersionAttribute(Comparison comparison, string targetVersion) - { - _comparison = comparison; - _targetVersion = targetVersion; - } - - public override string Skip - { - get - { - using (var connection = ConnectionMultiplexer.Connect(DefaultRedisConnectionString)) - { - var serverVersion = connection.GetServer(connection.GetEndPoints()[0]).Version; - var targetVersion = new Version(_targetVersion); - int comparisonResult = serverVersion.CompareTo(targetVersion); - - switch (_comparison) - { - case Comparison.LessThan: - if (comparisonResult < 0) - return $"Test skipped because Redis server version ({serverVersion}) is less than {_targetVersion}."; - break; - case Comparison.GreaterThanOrEqual: - if (comparisonResult >= 0) - return $"Test skipped because Redis server version ({serverVersion}) is greater than or equal to {_targetVersion}."; - break; - } - - return null; - } - } - } -} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 26f3d8aa..e25913c8 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -32,7 +32,7 @@ public async Task TestJsonTransaction() Assert.Equal("{\"Name\":\"Shachar\",\"Age\":23}", getResponse.Result.ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulsTransaction() { IDatabase db = redisFixture.Redis.GetDatabase(); From c7b6cd9e30782e028547934ae9caad16a474c2f6 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:34:14 +0300 Subject: [PATCH 11/48] add skip where needed --- .../AbstractNRedisStackTest.cs | 3 ++- tests/NRedisStack.Tests/Bloom/BloomTests.cs | 2 +- .../Clusters/ClusterTests.cs | 14 +++++++++-- .../CountMinSketch/CmsTests.cs | 6 ++--- .../CuckooFilter/CuckooTests.cs | 2 +- .../Examples/ExampleTests.cs | 2 +- tests/NRedisStack.Tests/Gears/GearsTests.cs | 20 +++++++++++----- tests/NRedisStack.Tests/Graph/GraphTests.cs | 2 +- tests/NRedisStack.Tests/Json/JsonTests.cs | 8 +++---- tests/NRedisStack.Tests/PipelineTests.cs | 6 ++--- tests/NRedisStack.Tests/Search/SearchTests.cs | 18 +++++++------- .../NRedisStack.Tests/SkipIfRedisAttribute.cs | 22 ++++++++--------- .../NRedisStack.Tests/Tdigest/TdigestTests.cs | 10 ++++---- .../TimeSeries/TestAPI/TestAdd.cs | 2 +- .../TimeSeries/TestAPI/TestAlter.cs | 2 +- .../TimeSeries/TestAPI/TestCreate.cs | 2 +- .../TimeSeries/TestAPI/TestDecrBy.cs | 2 +- .../TimeSeries/TestAPI/TestDel.cs | 2 +- .../TimeSeries/TestAPI/TestGet.cs | 2 +- .../TimeSeries/TestAPI/TestIncrBy.cs | 2 +- .../TimeSeries/TestAPI/TestMADD.cs | 8 +++---- .../TimeSeries/TestAPI/TestMAddAsync.cs | 6 ++--- .../TimeSeries/TestAPI/TestMGet.cs | 8 +++---- .../TimeSeries/TestAPI/TestMGetAsync.cs | 4 ++-- .../TimeSeries/TestAPI/TestMRange.cs | 22 ++++++++--------- .../TimeSeries/TestAPI/TestMRangeAsync.cs | 24 +++++++++---------- .../TimeSeries/TestAPI/TestMRevRange.cs | 24 +++++++++---------- .../TimeSeries/TestAPI/TestMRevRangeAsync.cs | 24 +++++++++---------- .../TimeSeries/TestAPI/TestQueryIndex.cs | 4 ++-- .../TimeSeries/TestAPI/TestQueryIndexAsync.cs | 2 +- .../TimeSeries/TestAPI/TestRange.cs | 6 ++--- .../TimeSeries/TestAPI/TestRangeAsync.cs | 4 ++-- .../TimeSeries/TestAPI/TestRules.cs | 6 ++--- .../TimeSeries/TestAPI/TestRulesAsync.cs | 4 ++-- .../TimeSeries/TimeSeriesTests.cs | 2 +- tests/NRedisStack.Tests/TopK/TopKTests.cs | 2 +- tests/NRedisStack.Tests/TransactionsTests.cs | 4 ++-- 37 files changed, 152 insertions(+), 131 deletions(-) diff --git a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs index b84d259a..ac9e079d 100644 --- a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs +++ b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs @@ -46,7 +46,8 @@ protected internal static List ReverseData(List (RedisKey)i).ToArray()); + // await redis.KeyDeleteAsync(keyNames.Select(i => (RedisKey)i).ToArray()); + await redis.ExecuteBroadcastAsync("FLUSHALL"); } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Bloom/BloomTests.cs b/tests/NRedisStack.Tests/Bloom/BloomTests.cs index b4909b55..3812461b 100644 --- a/tests/NRedisStack.Tests/Bloom/BloomTests.cs +++ b/tests/NRedisStack.Tests/Bloom/BloomTests.cs @@ -11,7 +11,7 @@ public BloomTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs index 2a0a59c7..42e65bd1 100644 --- a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs +++ b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs @@ -10,10 +10,10 @@ public ClusterTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } - [Fact(Skip = "This test needs to run on a cluster")] + [SkipIfRedis(Is.Standalone)] public void ClusterConnect() { // first, run a cluster, @@ -39,4 +39,14 @@ public void ClusterConnect() // var endpoints = conn.GetEndPoints(); // Console.WriteLine("endpoints:" + endpoints.ToString()); } + + [Fact] + public void ClusterChecks() + { + var db = redisFixture.Redis.GetDatabase(); + var endpoints1 = db.Multiplexer.GetEndPoints(); + var endpoints2 = redisFixture.Redis.GetEndPoints(); + var isCtr = redisFixture.isCluster; + var isCtr2 = ""; + } } diff --git a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs index 3929764e..2e9a47ec 100644 --- a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs +++ b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs @@ -11,7 +11,7 @@ public CmsTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] @@ -215,7 +215,7 @@ public async Task TestQueryAsync() Assert.Equal(new long[] { 10, 15 }, resp); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMerge() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -264,7 +264,7 @@ public void TestMerge() } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMergeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 685b5276..4d1a7db3 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -11,7 +11,7 @@ public CuckooTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 14d11a58..e771f702 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -28,7 +28,7 @@ public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelpe public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [SkipIfRedis(Is.Cluster)] diff --git a/tests/NRedisStack.Tests/Gears/GearsTests.cs b/tests/NRedisStack.Tests/Gears/GearsTests.cs index 9070f3ad..c448b0b0 100644 --- a/tests/NRedisStack.Tests/Gears/GearsTests.cs +++ b/tests/NRedisStack.Tests/Gears/GearsTests.cs @@ -5,12 +5,12 @@ namespace NRedisStack.Tests.Gears; public class GearsTests : AbstractNRedisStackTest, IDisposable { - private readonly string key = "BLOOM_TESTS"; + private readonly string key = "GEARS_TESTS"; public GearsTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } @@ -18,6 +18,7 @@ public void Dispose() public void TestTFunctionLoadDelete() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); Assert.True(db.TFunctionLoad(GenerateLibCode("lib"))); Assert.True(db.TFunctionDelete("lib")); @@ -28,6 +29,7 @@ public void TestTFunctionLoadDelete() public async Task TestTFunctionLoadDeleteAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -39,6 +41,7 @@ public async Task TestTFunctionLoadDeleteAsync() public void TestTFunctionList() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -70,6 +73,7 @@ public void TestTFunctionList() public async Task TestTFunctionListAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -99,6 +103,7 @@ public async Task TestTFunctionListAsync() public void TestTFCall() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -113,6 +118,7 @@ public void TestTFCall() public async Task TestTFCallAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -187,12 +193,14 @@ public void TestGearsCommandBuilder() private static void TryDeleteLib(IDatabase db, params string[] libNames) { - try + foreach (var libName in libNames) { - foreach(var libName in libNames) - db.TFunctionDelete(libName); + try + { + db.ExecuteBroadcast(GearsCommandBuilder.TFunctionDelete(libName)); + } + catch (RedisServerException) { } // ignore } - catch (RedisServerException) { } } private static string GenerateLibCode(string libName) diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 3b3edf56..08a9f42d 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -13,7 +13,7 @@ public GraphTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } #region SyncTests diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 1fe517d5..718afb0d 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -722,7 +722,7 @@ public async Task GetAsync() Assert.Equal(35, people[1]!.Age); } - [SkipIfRedis("7.1.242")] + [SkipIfRedis(Is.Cluster, Comparison.LessThan, "7.1.242")] public void MSet() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -746,7 +746,7 @@ public void MSet() Assert.Throws(() => commands.MSet(new KeyPathValue[0])); } - [SkipIfRedis("7.1.242")] + [SkipIfRedis(Is.Cluster, Comparison.LessThan, "7.1.242")] public async Task MSetAsync() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -807,7 +807,7 @@ public async Task MergeAsync() Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"phone\":\"123-456-7890\",\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"}}}", (await commands.GetAsync("test_merge")).ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void MGet() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -822,7 +822,7 @@ public void MGet() Assert.Equal("[\"world\"]", result[1].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task MGetAsync() { var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 945e6b62..6279f7d8 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -13,10 +13,10 @@ public PipelineTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } - [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Is.Cluster, Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulsPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -67,7 +67,7 @@ public async Task TestModulsPipeline() Assert.NotNull(db.TOPK().Info("topk-key")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestModulsPipelineWithotGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index a1dafb82..fca6b388 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -17,7 +17,9 @@ public SearchTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(index); + // redisFixture.Redis.GetDatabase().KeyDelete(index); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); + } private void AddDocument(IDatabase db, Document doc) @@ -322,7 +324,7 @@ public void TestAggregationRequestParamsDialect() Assert.Equal(10, r1.GetLong("sum")); } - [SkipIfRedis(Is.Cluster)] + [Fact] public async Task TestAggregationRequestParamsDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -390,7 +392,7 @@ public void TestAggregationRequestParamsWithDefaultDialect() Assert.Equal(10, r1.GetLong("sum")); } - [SkipIfRedis(Is.Cluster)] + [Fact] public async Task TestAggregationRequestParamsWithDefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -859,7 +861,7 @@ public async Task TestConfigAsnyc() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void configOnTimeout() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2250,7 +2252,7 @@ public void TestQueryParamsWithParams_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void TestBasicSpellCheck() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2270,7 +2272,7 @@ public void TestBasicSpellCheck() Assert.Equal(2, reply["name"]["name2"]); } - [SkipIfRedis(Is.Cluster)] + [Fact] public async Task TestBasicSpellCheckAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2338,7 +2340,7 @@ public async Task TestCrossTermDictionaryAsync() .ExcludeTerm("slang"))); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void TestDistanceBound() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2753,7 +2755,7 @@ public void TestProfileCommandBuilder() Assert.Equal(new object[] { "index", "AGGREGATE", "LIMITED", "QUERY", "*" }, aggregate.Args); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void Issue175() { ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs index 55b63ee2..8b035f13 100644 --- a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -49,19 +49,18 @@ public override string? Skip { get { - using (var connection = ConnectionMultiplexer.Connect(DefaultRedisConnectionString)) + string skipReason = ""; + bool skipped = false; + using (RedisFixture redisFixture = new RedisFixture()) { - string skipReason = ""; - bool skipped = false; // Cluster check if (_is != null) { - bool isCluster = connection.GetEndPoints().Length > 1; switch (_is) { case Is.Cluster: - if (isCluster) + if (redisFixture.isCluster) { skipReason = skipReason + " Redis server is a cluster."; skipped = true; @@ -69,7 +68,7 @@ public override string? Skip break; case Is.Standalone: - if (!isCluster) + if (!redisFixture.isCluster) { skipReason = skipReason + " Redis server is not a cluster."; skipped = true; @@ -78,7 +77,8 @@ public override string? Skip } } // Version check (if Is.Standalone/Is.Cluster is set then ) - var serverVersion = connection.GetServer(connection.GetEndPoints()[0]).Version; + + var serverVersion = redisFixture.Redis.GetServer(redisFixture.Redis.GetEndPoints()[0]).Version; var targetVersion = new Version(_targetVersion); int comparisonResult = serverVersion.CompareTo(targetVersion); @@ -99,11 +99,11 @@ public override string? Skip } break; } - - if (skipped) - return "Test skipped, because:" + skipReason; - return null; } + + if (skipped) + return "Test skipped, because:" + skipReason; + return null; } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs index c5a47cd8..9343f04f 100644 --- a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs +++ b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs @@ -11,7 +11,7 @@ public TdigestTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } private void AssertMergedUnmergedNodes(ITdigestCommands tdigest, string key, int mergedNodes, int unmergedNodes) @@ -370,7 +370,7 @@ public async Task TestAddAsync() AssertMergedUnmergedNodes(tdigest, "tdadd", 0, 5); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMerge() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -393,7 +393,7 @@ public void TestMerge() } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMergeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -416,7 +416,7 @@ public async Task TestMergeAsync() AssertMergedUnmergedNodes(tdigest, "td2", 3, 2); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void MergeMultiAndParams() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -437,7 +437,7 @@ public void MergeMultiAndParams() Assert.Equal(50, tdigest.Info("to").Compression); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task MergeMultiAndParamsAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs index 31c6450a..1daea83f 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs @@ -13,7 +13,7 @@ public TestAdd(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs index 7a37562b..ce15694c 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs @@ -14,7 +14,7 @@ public TestAlter(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs index 7f7bfb19..47380ecc 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs @@ -14,7 +14,7 @@ public TestCreate(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs index 3b84174b..124afda6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs @@ -13,7 +13,7 @@ public TestDecrBy(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs index d779052c..b98fd526 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs @@ -14,7 +14,7 @@ public TestDel(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } private List CreateData(ITimeSeriesCommands ts, int timeBucket) //TODO: check this diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs index 5fee7e96..faae70cc 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs @@ -14,7 +14,7 @@ public TestGet(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs index c31794fe..06fc7eb1 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs @@ -13,7 +13,7 @@ public TestIncrBy(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs index e2a22064..67cd1444 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs @@ -17,11 +17,11 @@ public void Dispose() { foreach (string key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestStarMADD() { @@ -50,7 +50,7 @@ public void TestStarMADD() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestSuccessfulMADD() { @@ -80,7 +80,7 @@ public void TestSuccessfulMADD() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestOverrideMADD() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs index 5d5ce9c5..a91dadea 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs @@ -11,7 +11,7 @@ public class TestMAddAsync : AbstractNRedisStackTest public TestMAddAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestStarMADD() { var keys = CreateKeyNames(2); @@ -43,7 +43,7 @@ public async Task TestStarMADD() } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestSuccessfulMAdd() { var keys = CreateKeyNames(2); @@ -73,7 +73,7 @@ public async Task TestSuccessfulMAdd() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestOverrideMAdd() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs index 658bd242..ab78ac32 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs @@ -16,11 +16,11 @@ public void Dispose() { foreach (string key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMGetQuery() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -47,7 +47,7 @@ public void TestMGetQuery() } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMGetQueryWithLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -74,7 +74,7 @@ public void TestMGetQueryWithLabels() Assert.Equal(labels2, results[1].labels); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMGetQuerySelectedLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs index 0057eab8..fc24abe6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs @@ -8,7 +8,7 @@ public class TestMGetAsync : AbstractNRedisStackTest { public TestMGetAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMGetQuery() { var keys = CreateKeyNames(2); @@ -64,7 +64,7 @@ public async Task TestMGetQueryWithLabels() Assert.Equal(labels2, results[1].labels); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMGetQuerySelectedLabelsAsync() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs index dfbb079c..e1fcd75a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs @@ -16,7 +16,7 @@ public void Dispose() { foreach (string key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } @@ -36,7 +36,7 @@ private List CreateData(ITimeSeriesCommands ts, int timeBucket) return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestSimpleMRange() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -59,7 +59,7 @@ public void TestSimpleMRange() Assert.Equal(tuples, results[i].values); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeWithLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -83,7 +83,7 @@ public void TestMRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeSelectLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -112,7 +112,7 @@ public void TestMRangeSelectLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeFilter() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -129,7 +129,7 @@ public void TestMRangeFilter() Assert.Equal(tuples, results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeCount() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -154,7 +154,7 @@ public void TestMRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeAggregation() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -178,7 +178,7 @@ public void TestMRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeAlign() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -237,7 +237,7 @@ public void TestMissingTimeBucket() Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeGroupby() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -263,7 +263,7 @@ public void TestMRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeReduce() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -288,7 +288,7 @@ public void TestMRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeFilterBy() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs index 175ffd68..3ea53529 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs @@ -27,7 +27,7 @@ private async Task> CreateData(TimeSeriesCommands ts, stri return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestSimpleMRange() { var keys = CreateKeyNames(2); @@ -51,7 +51,7 @@ public async Task TestSimpleMRange() Assert.Equal(tuples, results[i].values); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeWithLabels() { var keys = CreateKeyNames(2); @@ -76,7 +76,7 @@ public async Task TestMRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeSelectLabels() { var keys = CreateKeyNames(2); @@ -110,7 +110,7 @@ await ts.MRangeAsync("-", "+", } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeFilter() { var keys = CreateKeyNames(2); @@ -128,7 +128,7 @@ public async Task TestMRangeFilter() Assert.Equal(tuples, results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeCount() { var keys = CreateKeyNames(2); @@ -154,7 +154,7 @@ public async Task TestMRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeAggregation() { var keys = CreateKeyNames(2); @@ -179,7 +179,7 @@ public async Task TestMRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeAlign() { var keys = CreateKeyNames(2); @@ -203,7 +203,7 @@ public async Task TestMRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingFilter() { var keys = CreateKeyNames(2); @@ -222,7 +222,7 @@ public async Task TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingTimeBucket() { var keys = CreateKeyNames(2); @@ -245,7 +245,7 @@ await ts.MRangeAsync("-", "+", }); Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeGroupby() { var keys = CreateKeyNames(2); @@ -272,7 +272,7 @@ public async Task TestMRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeReduce() { var keys = CreateKeyNames(2); @@ -298,7 +298,7 @@ public async Task TestMRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeFilterBy() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs index afd31cfe..638ca4e2 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs @@ -27,7 +27,7 @@ private List CreateData(ITimeSeriesCommands ts, string[] keys, return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestSimpleMRevRange() { var keys = CreateKeyNames(2); @@ -52,7 +52,7 @@ public void TestSimpleMRevRange() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeWithLabels() { var keys = CreateKeyNames(2); @@ -78,7 +78,7 @@ public void TestMRevRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeSelectLabels() { var keys = CreateKeyNames(2); @@ -103,7 +103,7 @@ public void TestMRevRangeSelectLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeFilter() { var keys = CreateKeyNames(2); @@ -121,7 +121,7 @@ public void TestMRevRangeFilter() Assert.Equal(ReverseData(tuples), results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeCount() { var keys = CreateKeyNames(2); @@ -147,7 +147,7 @@ public void TestMRevRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeAggregation() { var keys = CreateKeyNames(2); @@ -172,7 +172,7 @@ public void TestMRevRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeAlign() { var keys = CreateKeyNames(2); @@ -196,7 +196,7 @@ public void TestMRevRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMissingFilter() { var keys = CreateKeyNames(2); @@ -215,7 +215,7 @@ public void TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMissingTimeBucket() { var keys = CreateKeyNames(2); @@ -234,7 +234,7 @@ public void TestMissingTimeBucket() Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeGroupby() { var keys = CreateKeyNames(2); @@ -261,7 +261,7 @@ public void TestMRevRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeReduce() { var keys = CreateKeyNames(2); @@ -288,7 +288,7 @@ public void TestMRevRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeFilterBy() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs index 5c30b3e7..a7409fc4 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs @@ -27,7 +27,7 @@ private async Task> CreateData(TimeSeriesCommands ts, stri return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestSimpleMRevRange() { var keys = CreateKeyNames(2); @@ -52,7 +52,7 @@ public async Task TestSimpleMRevRange() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeWithLabels() { var keys = CreateKeyNames(2); @@ -77,7 +77,7 @@ public async Task TestMRevRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeSelectLabels() { var keys = CreateKeyNames(2); @@ -102,7 +102,7 @@ public async Task TestMRevRangeSelectLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeFilter() { var keys = CreateKeyNames(2); @@ -120,7 +120,7 @@ public async Task TestMRevRangeFilter() Assert.Equal(ReverseData(tuples), results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeCount() { var keys = CreateKeyNames(2); @@ -146,7 +146,7 @@ public async Task TestMRevRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeAggregation() { var keys = CreateKeyNames(2); @@ -171,7 +171,7 @@ public async Task TestMRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeAlign() { var keys = CreateKeyNames(2); @@ -195,7 +195,7 @@ public async Task TestMRevRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingFilter() { var keys = CreateKeyNames(2); @@ -214,7 +214,7 @@ public async Task TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingTimeBucket() { var keys = CreateKeyNames(2); @@ -238,7 +238,7 @@ await ts.MRevRangeAsync("-", "+", Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeGroupby() { var keys = CreateKeyNames(2); @@ -265,7 +265,7 @@ public async Task TestMRevRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeReduce() { var keys = CreateKeyNames(2); @@ -292,7 +292,7 @@ public async Task TestMRevRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeFilterBy() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs index ac7fbb75..572badd7 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs @@ -14,11 +14,11 @@ public void Dispose() { foreach (var key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestTSQueryIndex() { var db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs index 2fe89e8f..92385573 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs @@ -8,7 +8,7 @@ public class TestQueryIndexAsync : AbstractNRedisStackTest { public TestQueryIndexAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestTSQueryIndex() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs index f831ddb0..dc6c43ff 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs @@ -14,7 +14,7 @@ public TestRange(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } private List CreateData(ITimeSeriesCommands ts, int timeBucket) @@ -130,7 +130,7 @@ public void TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void latest() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -165,7 +165,7 @@ public void latest() Assert.Equal(new List() { latest, compact }, ts.RevRange("ts2", 0, 10, true)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAlignTimestamp() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs index 67a1c009..9b052eec 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs @@ -129,7 +129,7 @@ public async Task TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestLatestAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -164,7 +164,7 @@ public async Task TestLatestAsync() Assert.Equal(new List() { latest, compact }, await ts.RevRangeAsync("ts2", 0, 10, true)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAlignTimestampAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs index c8c4779f..fad0d0ad 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs @@ -37,11 +37,11 @@ public void Dispose() redisFixture.Redis.GetDatabase().KeyDelete(srcKey); foreach (var key in destKeys.Values) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestRulesAdditionDeletion() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -104,7 +104,7 @@ public void TestNonExisitingDestinaion() Assert.Equal("ERR TSDB: compaction rule does not exist", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAlignTimestamp() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs index 3e2c5e91..42a2ece5 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs @@ -10,7 +10,7 @@ public class TestRulesAsync : AbstractNRedisStackTest { public TestRulesAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestRulesAdditionDeletion() { var key = CreateKeyName(); @@ -88,7 +88,7 @@ public async Task TestNonExisitingDestinaion() Assert.Equal("ERR TSDB: compaction rule does not exist", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAlignTimestampAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs index 7e8b568a..d7c0686f 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs @@ -12,7 +12,7 @@ public TimeSeriesTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } // [Fact] diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 5d8220c2..87ab2bac 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -11,7 +11,7 @@ public TopKTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index e25913c8..48d9dd14 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -13,7 +13,7 @@ public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] @@ -83,7 +83,7 @@ public async Task TestModulsTransaction() Assert.NotNull(db.TOPK().Info("topk-key")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestModulsTransactionWithoutGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); From 6e82630bd413b648cce4359aeceeb1f5fa0309c6 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:34:38 +0300 Subject: [PATCH 12/48] Execute broadcast --- src/NRedisStack/Auxiliary.cs | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/NRedisStack/Auxiliary.cs b/src/NRedisStack/Auxiliary.cs index 2dcde416..75f1fd5d 100644 --- a/src/NRedisStack/Auxiliary.cs +++ b/src/NRedisStack/Auxiliary.cs @@ -35,5 +35,53 @@ public async static Task ExecuteAsync(this IDatabaseAsync db, Seria { return await db.ExecuteAsync(command.Command, command.Args); } + + public static List ExecuteBroadcast(this IDatabaseAsync db, string command) + => db.ExecuteBroadcast(new SerializedCommand(command)); + + public static List ExecuteBroadcast(this IDatabaseAsync db, SerializedCommand command) + { + var redis = db.Multiplexer; + var endpoints = redis.GetEndPoints(); + var results = new List(endpoints.Length); + + foreach (var endPoint in endpoints) + { + var server = redis.GetServer(endPoint); + + if (server.IsReplica) + { + continue; // Skip replica nodes + } + // Send your command to the master node + + results.Add(server.Multiplexer.GetDatabase().Execute(command)); + } + return results; + } + + public async static Task> ExecuteBroadcastAsync(this IDatabaseAsync db, string command) + => await db.ExecuteBroadcastAsync(new SerializedCommand(command)); + + public async static Task> ExecuteBroadcastAsync(this IDatabaseAsync db, SerializedCommand command) + { + var redis = db.Multiplexer; + var endpoints = redis.GetEndPoints(); + var results = new List(endpoints.Length); + + foreach (var endPoint in endpoints) + { + var server = redis.GetServer(endPoint); + + if (server.IsReplica) + { + continue; // Skip replica nodes + } + // Send your command to the master node + + results.Add(await server.Multiplexer.GetDatabase().ExecuteAsync(command)); + } + return results; + } } } \ No newline at end of file From b5cdf871a44f7c16a418a4593fde21dd5fb4a71c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:41:00 +0300 Subject: [PATCH 13/48] delete cluster tests --- .../Clusters/ClusterTests.cs | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 tests/NRedisStack.Tests/Clusters/ClusterTests.cs diff --git a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs deleted file mode 100644 index 42e65bd1..00000000 --- a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs +++ /dev/null @@ -1,52 +0,0 @@ -using StackExchange.Redis; -using Xunit; - -namespace NRedisStack.Tests; - -public class ClusterTests : AbstractNRedisStackTest, IDisposable -{ - private readonly string key = "CLUSTER_TESTS"; - public ClusterTests(RedisFixture redisFixture) : base(redisFixture) { } - - public void Dispose() - { - redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); - } - - [SkipIfRedis(Is.Standalone)] - public void ClusterConnect() - { - // first, run a cluster, - ConfigurationOptions config = new ConfigurationOptions - { - // ports: 16379 -> 16384 - EndPoints = - { - { "127.0.0.1", 16379 }, - { "127.0.0.1", 16380 }, - { "127.0.0.1", 16381 }, - { "127.0.0.1", 16382 }, - { "127.0.0.1", 16383 }, - { "127.0.0.1", 16384 }, - }, - }; - var conn = ConnectionMultiplexer.Connect(config); - IDatabase clusterDB = conn.GetDatabase(); - clusterDB.KeyDelete("foo"); - clusterDB.StringSet("foo", "bar"); - var value = clusterDB.StringGet("foo"); - Assert.Equal("bar", value); - // var endpoints = conn.GetEndPoints(); - // Console.WriteLine("endpoints:" + endpoints.ToString()); - } - - [Fact] - public void ClusterChecks() - { - var db = redisFixture.Redis.GetDatabase(); - var endpoints1 = db.Multiplexer.GetEndPoints(); - var endpoints2 = redisFixture.Redis.GetEndPoints(); - var isCtr = redisFixture.isCluster; - var isCtr2 = ""; - } -} From 376ccdf1df42e6709c905c9ea19b021975a2e2fd Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:41:11 +0300 Subject: [PATCH 14/48] RedisFixture fix --- tests/NRedisStack.Tests/RedisFixture.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs index b09172d5..22a1de3e 100644 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ b/tests/NRedisStack.Tests/RedisFixture.cs @@ -6,23 +6,24 @@ namespace NRedisStack.Tests { public class RedisFixture : IDisposable { + // Set the enviroment variable to specify your own alternet host and port: + string redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + string? redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); + string? numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); + public bool isCluster = false; + public RedisFixture() { - // Set the enviroment variable to specify your own alternet host and port: - var redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - var redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); - var numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); - // bool redisClusterMode = false; // TODO: check if this is needed // Redis Cluster if (redisCluster != null && numRedisClusterNodesEnv != null) { // Split to host and port - string[] parts = redisCluster.Split(':'); + string[] parts = redisCluster!.Split(':'); string host = parts[0]; int startPort = int.Parse(parts[1]); var endpoints = new EndPointCollection(); - int numRedisClusterNodes = int.Parse(numRedisClusterNodesEnv); + int numRedisClusterNodes = int.Parse(numRedisClusterNodesEnv!); for (int i = 0; i < numRedisClusterNodes; i++) { endpoints.Add(host, startPort + i); @@ -33,7 +34,7 @@ public RedisFixture() { EndPoints = endpoints }; - // redisClusterMode = true; + isCluster = true; Redis = ConnectionMultiplexer.Connect(clusterConfig); } From 495dce1f5f550cd2c94651ae7774190a5be7ad4f Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:45:51 +0300 Subject: [PATCH 15/48] add to contributing --- CONTRIBUTING.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3b2a3ba..8dc83bd9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,6 +112,15 @@ e.g: ```bash dotnet test --environment="REDIS=172.17.0.1:6379" ``` + +If you want to run your tests against an oss cluster, you can do it thus: +```bash +dotnet test --environment "REDIS_CLUSTER=" --environment "NUM_REDIS_CLUSTER_NODES=" +``` +e.g. : +```bash +dotnet test --environment "REDIS_CLUSTER=127.0.0.1:16379" --environment "NUM_REDIS_CLUSTER_NODES=6" +``` ## How to Report a Bug ### Security Vulnerabilities From 47e2d7f957a36fc80b6567686093924b700a192e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 13:56:05 +0300 Subject: [PATCH 16/48] run cluster on CI --- .devcontainer/docker-compose.yml | 2 +- .github/docker-compose.yml | 30 +++++++++++++ .github/dockers/Dockerfile.cluster | 7 +++ .github/dockers/cluster.redis.conf | 8 ++++ .github/dockers/create_cluster.sh | 47 ++++++++++++++++++++ .github/workflows/integration.yml | 70 ++++++++++-------------------- .github/workflows/reusable.yml | 56 ++++++++++++++++++++++++ 7 files changed, 172 insertions(+), 48 deletions(-) create mode 100644 .github/docker-compose.yml create mode 100644 .github/dockers/Dockerfile.cluster create mode 100644 .github/dockers/cluster.redis.conf create mode 100644 .github/dockers/create_cluster.sh create mode 100644 .github/workflows/reusable.yml diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2af542a2..b7a2e345 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0-RC3 + image: redis/redis-stack-server:7.2.0 restart: unless-stopped networks: - redis diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml new file mode 100644 index 00000000..716aab4e --- /dev/null +++ b/.github/docker-compose.yml @@ -0,0 +1,30 @@ +--- +version: "3.8" +services: + + redis-stack-7.2.0: + image: redis/redis-stack-server:7.2.0 + ports: ["6379:6379"] + + redis-stack-6.2.6: + image: redis/redis-stack-server:6.2.6-v9 + ports: ["6379:6379"] + + redis-stack-edge: + image: redis/redis-stack-server:edge + ports: ["6379:6379"] + + redis-stack-cluster: + container_name: redis-cluster + build: + context: . + dockerfile: dockers/Dockerfile.cluster + ports: + - 16379:16379 + - 16380:16380 + - 16381:16381 + - 16382:16382 + - 16383:16383 + - 16384:16384 + volumes: + - "./dockers/cluster.redis.conf:/redis.conf:ro" \ No newline at end of file diff --git a/.github/dockers/Dockerfile.cluster b/.github/dockers/Dockerfile.cluster new file mode 100644 index 00000000..3a0d7341 --- /dev/null +++ b/.github/dockers/Dockerfile.cluster @@ -0,0 +1,7 @@ +FROM redis/redis-stack-server:edge as rss + +COPY dockers/create_cluster.sh /create_cluster.sh +RUN ls -R /opt/redis-stack +RUN chmod a+x /create_cluster.sh + +ENTRYPOINT [ "/create_cluster.sh"] diff --git a/.github/dockers/cluster.redis.conf b/.github/dockers/cluster.redis.conf new file mode 100644 index 00000000..d4de46fb --- /dev/null +++ b/.github/dockers/cluster.redis.conf @@ -0,0 +1,8 @@ +protected-mode no +enable-debug-command yes +loadmodule /opt/redis-stack/lib/redisearch.so +loadmodule /opt/redis-stack/lib/redisgraph.so +loadmodule /opt/redis-stack/lib/redistimeseries.so +loadmodule /opt/redis-stack/lib/rejson.so +loadmodule /opt/redis-stack/lib/redisbloom.so +loadmodule /opt/redis-stack/lib/redisgears.so v8-plugin-path /opt/redis-stack/lib/libredisgears_v8_plugin.so diff --git a/.github/dockers/create_cluster.sh b/.github/dockers/create_cluster.sh new file mode 100644 index 00000000..da9a0cb6 --- /dev/null +++ b/.github/dockers/create_cluster.sh @@ -0,0 +1,47 @@ +#! /bin/bash + +mkdir -p /nodes +touch /nodes/nodemap +if [ -z ${START_PORT} ]; then + START_PORT=16379 +fi +if [ -z ${END_PORT} ]; then + END_PORT=16384 +fi +if [ ! -z "$3" ]; then + START_PORT=$2 + START_PORT=$3 +fi +echo "STARTING: ${START_PORT}" +echo "ENDING: ${END_PORT}" + +for PORT in `seq ${START_PORT} ${END_PORT}`; do + mkdir -p /nodes/$PORT + if [[ -e /redis.conf ]]; then + cp /redis.conf /nodes/$PORT/redis.conf + else + touch /nodes/$PORT/redis.conf + fi + cat << EOF >> /nodes/$PORT/redis.conf +port ${PORT} +cluster-enabled yes +daemonize yes +logfile /redis.log +dir /nodes/$PORT +EOF + + set -x + /opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf + sleep 1 + if [ $? -ne 0 ]; then + echo "Redis failed to start, exiting." + continue + fi + echo 127.0.0.1:$PORT >> /nodes/nodemap +done +if [ -z "${REDIS_PASSWORD}" ]; then + echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 +else + echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 +fi +tail -f /redis.log diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 02e9f818..7df938a8 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,61 +12,37 @@ on: - cron: "0 1 * * *" jobs: - build_and_Test: - name: Test [redis-stack ${{matrix.redis-stack-version}}] - runs-on: ubuntu-latest + dotnet_6: + uses: ./.github/workflows/reusable.yml strategy: fail-fast: false + max-parallel: 5 matrix: - redis-stack-version: ["6.2.6-v9", "7.2.0-RC3", "edge"] - env: - USER_NAME: ${{ secrets.USER_NAME }} - PASSWORD: ${{ secrets.PASSWORD }} - ENDPOINT: ${{ secrets.ENDPOINT }} - REDIS_VERSION: ${{ matrix.redis-stack-version }} - steps: - - uses: actions/checkout@v3 - - name: .NET Core 6 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '6.0.x' - - name: .NET Core 7 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '7.0.x' - - name: run redis-stack-server docker - run: docker run -p 6379:6379 -d redis/redis-stack-server:${{matrix.redis-stack-version}} - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - - name: Test - run: | - echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_ca.pem - echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user.crt - echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user_private.key - ls -R - dotnet test -f net6.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - - name: Test - run: | - echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net7.0/redis_ca.pem - echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net7.0/redis_user.crt - echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net7.0/redis_user_private.key - ls -R - dotnet test -f net7.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - - name: Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{secrets.CODECOV_TOKEN}} - verbose: true - - name: Build - run: dotnet pack -c Release + redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + with: + redis_stack_type: ${{matrix.redis-stack-type}} + dotnet_version: 6.0.x + clr_version: net6.0 + secrets: inherit + + dotnet_7: + uses: ./.github/workflows/reusable.yml + strategy: + fail-fast: false + max-parallel: 5 + matrix: + redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + with: + redis_stack_type: ${{matrix.redis-stack-type}} + dotnet_version: 7.0.x + clr_version: net7.0 + secrets: inherit build_and_test_windows: name: Windows Test ${{matrix.redis-stack-version}} runs-on: windows-latest env: - redis_stack_version: 6.2.6-v7 + redis_stack_version: 6.2.6-v9 USER_NAME: ${{ secrets.USER_NAME }} PASSWORD: ${{ secrets.PASSWORD }} ENDPOINT: ${{ secrets.ENDPOINT }} diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml new file mode 100644 index 00000000..5e9c8b1f --- /dev/null +++ b/.github/workflows/reusable.yml @@ -0,0 +1,56 @@ +name: Build and Test +on: + workflow_call: + inputs: + + redis_stack_type: + required: true + type: string + + + dotnet_version: + required: true + type: string + + clr_version: + required: true + type: string + +jobs: + + build_and_Test: + name: Test [redis-stack ${{inputs.redis_stack_type}}] + runs-on: ubuntu-latest + + env: + USER_NAME: ${{ secrets.USER_NAME }} + PASSWORD: ${{ secrets.PASSWORD }} + ENDPOINT: ${{ secrets.ENDPOINT }} + steps: + - uses: actions/checkout@v3 + - name: .NET Core ${{inputs.dotnet_version}} + uses: actions/setup-dotnet@v2 + with: + dotnet-version: ${{inputs.dotnet_version}} + + - name: run redis-stack-server docker + run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true + - name: Test + run: | + echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_ca.pem + echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user.crt + echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user_private.key + ls -R + dotnet test -f ${{inputs.clr_version}} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover + - name: Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{secrets.CODECOV_TOKEN}} + verbose: true + - name: Build + run: dotnet pack -c Release + From d87cec041404f1807a7a67f46d39ee4096739071 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 14:20:02 +0300 Subject: [PATCH 17/48] wip --- .github/cluster.env | 2 ++ .github/standalone.env | 1 + .github/workflows/integration.yml | 31 ++++++++++++++++++++++++++++--- .github/workflows/reusable.yml | 13 ++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 .github/cluster.env create mode 100644 .github/standalone.env diff --git a/.github/cluster.env b/.github/cluster.env new file mode 100644 index 00000000..0d2a2906 --- /dev/null +++ b/.github/cluster.env @@ -0,0 +1,2 @@ +REDIS_CLUSTER=127.0.0.1:16379 +NUM_REDIS_CLUSTER_NODES=6 \ No newline at end of file diff --git a/.github/standalone.env b/.github/standalone.env new file mode 100644 index 00000000..e0cfd098 --- /dev/null +++ b/.github/standalone.env @@ -0,0 +1 @@ +REDIS=localhost:6379 \ No newline at end of file diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 7df938a8..d795924f 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,17 +12,37 @@ on: - cron: "0 1 * * *" jobs: + dotnet_6_cluster: + uses: ./.github/workflows/reusable.yml + with: + redis_stack_type: cluster + dotnet_version: 6.0.x + clr_version: net6.0 + dotenv_file: .github/cluster.env + secrets: inherit + dotnet_6: uses: ./.github/workflows/reusable.yml strategy: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x clr_version: net6.0 + dotenv_file: .github/standalone.env + secrets: inherit + + dotnet_7_cluster: + uses: ./.github/workflows/reusable.yml + + with: + redis_stack_type: cluster + dotnet_version: 7.0.x + clr_version: net7.0 + dotenv_file: .github/cluster.env secrets: inherit dotnet_7: @@ -31,18 +51,23 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x clr_version: net7.0 + dotenv_file: .github/standalone.env secrets: inherit build_and_test_windows: name: Windows Test ${{matrix.redis-stack-version}} runs-on: windows-latest + strategy: + fail-fast: false + matrix: + redis-stack-version: ['6.2.9-v9', '7.2.0'] env: - redis_stack_version: 6.2.6-v9 + redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} PASSWORD: ${{ secrets.PASSWORD }} ENDPOINT: ${{ secrets.ENDPOINT }} diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 5e9c8b1f..de992873 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -16,9 +16,12 @@ on: required: true type: string + dotenv_file: + required: true + type: string jobs: - build_and_Test: + build_and_test: name: Test [redis-stack ${{inputs.redis_stack_type}}] runs-on: ubuntu-latest @@ -27,14 +30,22 @@ jobs: PASSWORD: ${{ secrets.PASSWORD }} ENDPOINT: ${{ secrets.ENDPOINT }} steps: + - uses: actions/checkout@v3 + - name: .NET Core ${{inputs.dotnet_version}} uses: actions/setup-dotnet@v2 with: dotnet-version: ${{inputs.dotnet_version}} - name: run redis-stack-server docker + working-directory: ./github run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d + - name: set variables in dotenv + uses: c-py/action-dotenv-to-setenv@v2 + with: + env-file: ${{inputs.dotenv_file}} + - name: Restore dependencies run: dotnet restore - name: Build From b933427b797a32124e9893274770a672995483a3 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 14:22:16 +0300 Subject: [PATCH 18/48] fix / --- .github/workflows/reusable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index de992873..fb8570ca 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -39,7 +39,7 @@ jobs: dotnet-version: ${{inputs.dotnet_version}} - name: run redis-stack-server docker - working-directory: ./github + working-directory: .github run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d - name: set variables in dotenv uses: c-py/action-dotenv-to-setenv@v2 From ccb7625009393391e2b1ed70a1d7a03debbab091 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 14:24:36 +0300 Subject: [PATCH 19/48] -d --- .github/workflows/reusable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index fb8570ca..848b1728 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -40,7 +40,7 @@ jobs: - name: run redis-stack-server docker working-directory: .github - run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d + run: docker-compose up -d redis-stack-${{inputs.redis_stack_type}} - name: set variables in dotenv uses: c-py/action-dotenv-to-setenv@v2 with: From 908699d6fa384b00b24056332225776cc0b97705 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 15:47:28 +0300 Subject: [PATCH 20/48] delete restore --- .github/workflows/reusable.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 848b1728..28d14165 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -41,13 +41,12 @@ jobs: - name: run redis-stack-server docker working-directory: .github run: docker-compose up -d redis-stack-${{inputs.redis_stack_type}} + - name: set variables in dotenv uses: c-py/action-dotenv-to-setenv@v2 with: env-file: ${{inputs.dotenv_file}} - - name: Restore dependencies - run: dotnet restore - name: Build run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - name: Test From b5318bf3db7f8ecb60f32c7dd5a12a4a57d314bb Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 15:57:00 +0300 Subject: [PATCH 21/48] return restore --- .github/workflows/reusable.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 28d14165..dfb754c8 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -47,6 +47,8 @@ jobs: with: env-file: ${{inputs.dotenv_file}} + - name: Restore dependencies + run: dotnet restore - name: Build run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - name: Test From 31bef695faf1933741f66eebb04c18952e700b03 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 30 Aug 2023 17:24:20 +0300 Subject: [PATCH 22/48] add -RC3 --- .devcontainer/docker-compose.yml | 2 +- .github/docker-compose.yml | 2 +- .github/workflows/integration.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index b7a2e345..2af542a2 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0 + image: redis/redis-stack-server:7.2.0-RC3 restart: unless-stopped networks: - redis diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index 716aab4e..b9484c9f 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -3,7 +3,7 @@ version: "3.8" services: redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0 + image: redis/redis-stack-server:7.2.0-RC3 ports: ["6379:6379"] redis-stack-6.2.6: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d795924f..fc2d7634 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x @@ -51,7 +51,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x @@ -65,7 +65,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.9-v9', '7.2.0'] + redis-stack-version: ['6.2.9-v9', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From e544fe055c95dc822311711694d1d2e8dfa63b68 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 30 Aug 2023 17:26:19 +0300 Subject: [PATCH 23/48] add RC3 to docker-compose --- .github/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index b9484c9f..d56217a5 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: - redis-stack-7.2.0: + redis-stack-7.2.0-RC3: image: redis/redis-stack-server:7.2.0-RC3 ports: ["6379:6379"] From 5f67f42725c5b250f045ac40a7470d25d889b315 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 30 Aug 2023 17:53:08 +0300 Subject: [PATCH 24/48] try define both .net 6 and 7 --- .github/workflows/reusable.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index dfb754c8..e75d7025 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -33,10 +33,15 @@ jobs: - uses: actions/checkout@v3 - - name: .NET Core ${{inputs.dotnet_version}} + - name: .NET Core 6 uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{inputs.dotnet_version}} + dotnet-version: '6.0.x' + + - name: .NET Core 7 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: '7.0.x' - name: run redis-stack-server docker working-directory: .github From 9724f9b17619b84026aba4adf703460a5371012e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 09:50:51 +0300 Subject: [PATCH 25/48] Skip if cluster where needed --- .github/workflows/reusable.yml | 1 - tests/Doc/Doc.csproj | 1 + tests/Doc/HashExample.cs | 3 ++- tests/Doc/SearchQuickstartExample.cs | 7 ++++--- tests/Doc/SetGetExample.cs | 5 +++-- tests/NRedisStack.Tests/PipelineTests.cs | 2 +- tests/NRedisStack.Tests/Search/SearchTests.cs | 6 +++--- tests/NRedisStack.Tests/SkipIfRedisAttribute.cs | 4 +--- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index e75d7025..336ef9ae 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -7,7 +7,6 @@ on: required: true type: string - dotnet_version: required: true type: string diff --git a/tests/Doc/Doc.csproj b/tests/Doc/Doc.csproj index 56fdeec0..0958f541 100644 --- a/tests/Doc/Doc.csproj +++ b/tests/Doc/Doc.csproj @@ -20,5 +20,6 @@ + \ No newline at end of file diff --git a/tests/Doc/HashExample.cs b/tests/Doc/HashExample.cs index 913d3a0a..8212c722 100644 --- a/tests/Doc/HashExample.cs +++ b/tests/Doc/HashExample.cs @@ -1,5 +1,6 @@ // EXAMPLE: hash_tutorial // HIDE_START +using NRedisStack.Tests; using StackExchange.Redis; //REMOVE_START @@ -8,7 +9,7 @@ namespace NRedisStack.Doc; //REMOVE_END public class HashExample { - [Fact] + [SkipIfRedis(Is.Cluster)] public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/SearchQuickstartExample.cs b/tests/Doc/SearchQuickstartExample.cs index 142ab1b1..d8643356 100644 --- a/tests/Doc/SearchQuickstartExample.cs +++ b/tests/Doc/SearchQuickstartExample.cs @@ -3,6 +3,7 @@ using NRedisStack.Search; using NRedisStack.Search.Aggregation; using NRedisStack.Search.Literals.Enums; +using NRedisStack.Tests; using StackExchange.Redis; // REMOVE_START @@ -11,7 +12,7 @@ namespace NRedisStack.Doc; // REMOVE_END public class SearchQuickstartExample { - [Fact] + [SkipIfRedis(Is.Cluster)] public void run() { // STEP_START connect @@ -21,7 +22,7 @@ public void run() var json = db.JSON(); // STEP_END - // REMOVE_START + // REMOVE_START try { ft.DropIndex("idx:bicycle"); @@ -41,7 +42,7 @@ public void run() "for the smallest of tikes! This is the tiniest " + "kids’ pedal bike on the market available without" + " a coaster brake, the Jigger is the vehicle of " + - "choice for the rare tenacious little rider " + + "choice for the rare tenacious little rider " + "raring to go.", Condition = "used" }; diff --git a/tests/Doc/SetGetExample.cs b/tests/Doc/SetGetExample.cs index 6b381de0..805b8868 100644 --- a/tests/Doc/SetGetExample.cs +++ b/tests/Doc/SetGetExample.cs @@ -1,6 +1,7 @@ // EXAMPLE: set_and_get // HIDE_START using System; +using NRedisStack.Tests; using StackExchange.Redis; //REMOVE_START @@ -9,7 +10,7 @@ namespace NRedisStack.Doc; //REMOVE_END public class SetGetExample { - [Fact] + [SkipIfRedis(Is.Cluster)] public void run() { var redis = ConnectionMultiplexer.Connect("localhost:6379"); @@ -17,7 +18,7 @@ public void run() //HIDE_END bool status = db.StringSet("bike:1", "Process 134"); - + if (status) Console.WriteLine("Successfully added a bike."); diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 6279f7d8..41369e21 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -114,7 +114,7 @@ public async Task TestModulsPipelineWithotGraph() Assert.NotNull(db.TOPK().Info("topk-key")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestBloomPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index fca6b388..9946db30 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -839,7 +839,7 @@ public async Task AlterAddAsync() Assert.Equal(4, info.CursorStats.Count); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestConfig() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -850,7 +850,7 @@ public void TestConfig() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestConfigAsnyc() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2755,7 +2755,7 @@ public void TestProfileCommandBuilder() Assert.Equal(new object[] { "index", "AGGREGATE", "LIMITED", "QUERY", "*" }, aggregate.Args); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void Issue175() { ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs index 8b035f13..7853a3c3 100644 --- a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -1,8 +1,6 @@ using Xunit; -using StackExchange.Redis; -using NRedisStack.Tests; -using System.Text; +namespace NRedisStack.Tests; public enum Comparison { LessThan, From d998125562d65aa171a21a541aae95f7f5ec3f59 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 10:05:05 +0300 Subject: [PATCH 26/48] add names --- .github/workflows/integration.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index fc2d7634..ad214ea7 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -13,6 +13,7 @@ on: jobs: dotnet_6_cluster: + name: .NET 6 on Redis Cluster uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -22,6 +23,7 @@ jobs: secrets: inherit dotnet_6: + name: .NET 6 on Redis Standalone uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -36,8 +38,8 @@ jobs: secrets: inherit dotnet_7_cluster: + name: .NET 7 on Redis Cluster uses: ./.github/workflows/reusable.yml - with: redis_stack_type: cluster dotnet_version: 7.0.x @@ -46,6 +48,7 @@ jobs: secrets: inherit dotnet_7: + name: .NET 7 on Redis Standalone uses: ./.github/workflows/reusable.yml strategy: fail-fast: false From 2842a2984fb5540b53ae7af411bc18233f269248 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 10:05:18 +0300 Subject: [PATCH 27/48] skip configOnTimeout if cluster --- tests/NRedisStack.Tests/Search/SearchTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 9946db30..88669f9d 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -861,7 +861,7 @@ public async Task TestConfigAsnyc() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void configOnTimeout() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -873,7 +873,7 @@ public void configOnTimeout() try { ft.ConfigSet("ON_TIMEOUT", "null"); } catch (RedisServerException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task configOnTimeoutAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); From d07f2251554cbb9dec0c50feffd2ddac85a31903 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 12:24:22 +0300 Subject: [PATCH 28/48] try to fix win tests --- .github/workflows/integration.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index ad214ea7..d37bf14b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -13,7 +13,7 @@ on: jobs: dotnet_6_cluster: - name: .NET 6 on Redis Cluster + name: .NET 6 uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -23,7 +23,7 @@ jobs: secrets: inherit dotnet_6: - name: .NET 6 on Redis Standalone + name: .NET 6 uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -38,7 +38,7 @@ jobs: secrets: inherit dotnet_7_cluster: - name: .NET 7 on Redis Cluster + name: .NET 7 uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -48,7 +48,7 @@ jobs: secrets: inherit dotnet_7: - name: .NET 7 on Redis Standalone + name: .NET 7 uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.9-v9', '7.2.0-RC3'] + redis-stack-version: ['6.2.9-v7', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From 661cb1c1aa2d4b535564bb5c08e17c8d7e30a34c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 12:55:15 +0300 Subject: [PATCH 29/48] tests names +fix win version --- .github/workflows/integration.yml | 10 +++++----- .github/workflows/reusable.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d37bf14b..0e091537 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -13,7 +13,7 @@ on: jobs: dotnet_6_cluster: - name: .NET 6 + name: .NET 6 on [redis-stack cluster] uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -23,7 +23,7 @@ jobs: secrets: inherit dotnet_6: - name: .NET 6 + name: .NET 6 on [redis-stack ${{matrix.redis-stack-type}}] uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -38,7 +38,7 @@ jobs: secrets: inherit dotnet_7_cluster: - name: .NET 7 + name: .NET 7 on [redis-stack cluster] uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -48,7 +48,7 @@ jobs: secrets: inherit dotnet_7: - name: .NET 7 + name: .NET 7 on standalone [redis-stack ${{matrix.redis-stack-type}}] uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.9-v7', '7.2.0-RC3'] + redis-stack-version: ['6.2.13', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 336ef9ae..0d1a63ac 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -21,7 +21,7 @@ on: jobs: build_and_test: - name: Test [redis-stack ${{inputs.redis_stack_type}}] + name: Test runs-on: ubuntu-latest env: From b4a5ff2870486af1fa93882055a5c742ae7c791e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 13:17:42 +0300 Subject: [PATCH 30/48] fix versions --- .devcontainer/docker-compose.yml | 2 +- .github/workflows/integration.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2af542a2..d1aed936 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0-RC3 + image: redis/redis-stack-server:7.2.0-v0 restart: unless-stopped networks: - redis diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 0e091537..d50630f9 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -29,7 +29,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] + redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x @@ -48,13 +48,13 @@ jobs: secrets: inherit dotnet_7: - name: .NET 7 on standalone [redis-stack ${{matrix.redis-stack-type}}] + name: .NET 7 on [redis-stack ${{matrix.redis-stack-type}}] uses: ./.github/workflows/reusable.yml strategy: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] + redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.13', '7.2.0-RC3'] + redis-stack-version: ['6.2.6-v9', '7.2.0-v0'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From 6c98a16bb69ce0201f7a53bcd5800a2c34e941ad Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 13:26:10 +0300 Subject: [PATCH 31/48] versions --- .devcontainer/docker-compose.yml | 2 +- .github/workflows/integration.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index d1aed936..2af542a2 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0-v0 + image: redis/redis-stack-server:7.2.0-RC3 restart: unless-stopped networks: - redis diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d50630f9..8804a118 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -29,7 +29,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x @@ -54,7 +54,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.6-v9', '7.2.0-v0'] + redis-stack-version: ['6.2.6', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From b1feed4db47933487d40505d80500e63e72bb67a Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 13:30:33 +0300 Subject: [PATCH 32/48] win verer --- .github/workflows/integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 8804a118..c715948c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.6', '7.2.0-RC3'] + redis-stack-version: ['6.2.6-v9', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From 3b79773805ee58a5ea64735a791a826affdf0487 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 15:40:11 +0300 Subject: [PATCH 33/48] wording --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8dc83bd9..9eaade76 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ e.g: dotnet test --environment="REDIS=172.17.0.1:6379" ``` -If you want to run your tests against an oss cluster, you can do it thus: +To run your tests against an oss cluster: ```bash dotnet test --environment "REDIS_CLUSTER=" --environment "NUM_REDIS_CLUSTER_NODES=" ``` From bff96ca157e0d1302e26c27543e92da73a2643e4 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Sun, 10 Sep 2023 15:02:16 +0300 Subject: [PATCH 34/48] dotnet format --- .../CuckooFilter/ICuckooCommands.cs | 2 +- .../CuckooFilter/ICuckooCommandsAsync.cs | 2 +- .../CuckooFilter/Literals/CommandArgs.cs | 12 +- src/NRedisStack/Gears/GearsCommandBuilder.cs | 2 +- src/NRedisStack/Gears/GearsCommands.cs | 4 +- src/NRedisStack/Gears/GearsCommandsAsync.cs | 4 +- src/NRedisStack/Graph/DataTypes/Node.cs | 2 +- src/NRedisStack/Graph/DataTypes/Path.cs | 4 +- src/NRedisStack/Graph/RedisGraphUtilities.cs | 4 +- src/NRedisStack/Graph/ResultSet.cs | 2 +- src/NRedisStack/Graph/Statistics.cs | 40 ++--- src/NRedisStack/Json/JsonCommandBuilder.cs | 4 +- src/NRedisStack/Json/JsonCommandsAsync.cs | 4 +- src/NRedisStack/ResponseParser.cs | 6 +- src/NRedisStack/Search/AggregationRequest.cs | 4 +- src/NRedisStack/Search/Document.cs | 8 +- src/NRedisStack/Search/FTSpellCheckParams.cs | 12 +- src/NRedisStack/Search/Limit.cs | 16 +- src/NRedisStack/Search/Query.cs | 2 +- .../Search/SearchCommandBuilder.cs | 10 +- src/NRedisStack/Search/SearchCommands.cs | 4 +- src/NRedisStack/Search/SearchResult.cs | 2 +- src/NRedisStack/Tdigest/TdigestCommands.cs | 2 +- .../DataTypes/TimeSeriesInformation.cs | 6 +- src/NRedisStack/TopK/TopKCommandBuilder.cs | 2 +- src/NRedisStack/TopK/TopKCommands.cs | 2 +- src/NRedisStack/TopK/TopKCommandsAsync.cs | 2 +- src/NRedisStack/Transactions.cs | 4 +- tests/Doc/HashExample.cs | 2 +- tests/Doc/SearchQuickstartExample.cs | 2 +- tests/Doc/SetGetExample.cs | 2 +- .../CuckooFilter/CuckooTests.cs | 16 +- tests/NRedisStack.Tests/Graph/GraphTests.cs | 28 ++-- .../Graph/Utils/PathBuilderTest.cs | 2 +- tests/NRedisStack.Tests/Json/JsonTests.cs | 8 +- tests/NRedisStack.Tests/PipelineTests.cs | 10 +- tests/NRedisStack.Tests/Search/SearchTests.cs | 158 ++++++++---------- .../TimeSeries/TestAPI/TestAlter.cs | 4 +- .../TimeSeries/TestAPI/TestAlterAsync.cs | 4 +- .../TestTimeSeriesInformation.cs | 12 +- tests/NRedisStack.Tests/TopK/TopKTests.cs | 38 ++--- tests/NRedisStack.Tests/TransactionsTests.cs | 4 +- 42 files changed, 225 insertions(+), 233 deletions(-) diff --git a/src/NRedisStack/CuckooFilter/ICuckooCommands.cs b/src/NRedisStack/CuckooFilter/ICuckooCommands.cs index 18852203..4483f1c0 100644 --- a/src/NRedisStack/CuckooFilter/ICuckooCommands.cs +++ b/src/NRedisStack/CuckooFilter/ICuckooCommands.cs @@ -124,6 +124,6 @@ bool Reserve(RedisKey key, long capacity, /// Iterator value; either 0 or the iterator from a previous invocation of this command. /// Tuple of iterator and data. /// - Tuple ScanDump(RedisKey key, long iterator); + Tuple ScanDump(RedisKey key, long iterator); } } \ No newline at end of file diff --git a/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs b/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs index acf67b69..6717c02a 100644 --- a/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs +++ b/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs @@ -124,6 +124,6 @@ Task ReserveAsync(RedisKey key, long capacity, /// Iterator value; either 0 or the iterator from a previous invocation of this command. /// Tuple of iterator and data. /// - Task> ScanDumpAsync(RedisKey key, long iterator); + Task> ScanDumpAsync(RedisKey key, long iterator); } } \ No newline at end of file diff --git a/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs b/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs index 3b6b6c16..b480700b 100644 --- a/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs +++ b/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs @@ -2,11 +2,11 @@ namespace NRedisStack.CuckooFilter.Literals { internal class CuckooArgs { - public const string CAPACITY = "CAPACITY"; - public const string EXPANSION = "EXPANSION"; - public const string NOCREATE = "NOCREATE"; - public const string ITEMS = "ITEMS"; - public const string BUCKETSIZE = "BUCKETSIZE"; - public const string MAXITERATIONS = "MAXITERATIONS"; + public const string CAPACITY = "CAPACITY"; + public const string EXPANSION = "EXPANSION"; + public const string NOCREATE = "NOCREATE"; + public const string ITEMS = "ITEMS"; + public const string BUCKETSIZE = "BUCKETSIZE"; + public const string MAXITERATIONS = "MAXITERATIONS"; } } \ No newline at end of file diff --git a/src/NRedisStack/Gears/GearsCommandBuilder.cs b/src/NRedisStack/Gears/GearsCommandBuilder.cs index 31d8c73c..5af745ba 100644 --- a/src/NRedisStack/Gears/GearsCommandBuilder.cs +++ b/src/NRedisStack/Gears/GearsCommandBuilder.cs @@ -58,7 +58,7 @@ public static SerializedCommand TFunctionList(bool withCode = false, int verbose public static SerializedCommand TFCall(string libraryName, string functionName, string[]? keys = null, string[]? args = null, bool async = false) { string command = async ? RG.TFCALLASYNC : RG.TFCALL; - var commandArgs = new List() {$"{libraryName}.{functionName}"}; + var commandArgs = new List() { $"{libraryName}.{functionName}" }; if (keys != null) { diff --git a/src/NRedisStack/Gears/GearsCommands.cs b/src/NRedisStack/Gears/GearsCommands.cs index 2eb885f0..64b7eeb8 100644 --- a/src/NRedisStack/Gears/GearsCommands.cs +++ b/src/NRedisStack/Gears/GearsCommands.cs @@ -58,7 +58,7 @@ public static Dictionary[] TFunctionList(this IDatabase db, /// public static RedisResult TFCall_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false)); + return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: false)); } /// @@ -72,7 +72,7 @@ public static RedisResult TFCall_(this IDatabase db, string libraryName, string /// public static RedisResult TFCallAsync_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true)); + return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: true)); } } } diff --git a/src/NRedisStack/Gears/GearsCommandsAsync.cs b/src/NRedisStack/Gears/GearsCommandsAsync.cs index 4842a3ed..09b1fafa 100644 --- a/src/NRedisStack/Gears/GearsCommandsAsync.cs +++ b/src/NRedisStack/Gears/GearsCommandsAsync.cs @@ -57,7 +57,7 @@ public static async Task[]> TFunctionListAsync(t /// public async static Task TFCall_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false)); + return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: false)); } /// @@ -71,7 +71,7 @@ public async static Task TFCall_Async(this IDatabase db, string lib /// public async static Task TFCallAsync_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true)); + return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: true)); } } } diff --git a/src/NRedisStack/Graph/DataTypes/Node.cs b/src/NRedisStack/Graph/DataTypes/Node.cs index dae07ef1..960ac145 100644 --- a/src/NRedisStack/Graph/DataTypes/Node.cs +++ b/src/NRedisStack/Graph/DataTypes/Node.cs @@ -53,7 +53,7 @@ public override int GetHashCode() { int hash = 17; - foreach(var label in Labels) + foreach (var label in Labels) { hash = hash * 31 + label.GetHashCode(); } diff --git a/src/NRedisStack/Graph/DataTypes/Path.cs b/src/NRedisStack/Graph/DataTypes/Path.cs index 02af0c8e..62a3552c 100644 --- a/src/NRedisStack/Graph/DataTypes/Path.cs +++ b/src/NRedisStack/Graph/DataTypes/Path.cs @@ -11,8 +11,8 @@ namespace NRedisStack.Graph.DataTypes /// public class Path { - public ReadOnlyCollection Nodes { get;} - public ReadOnlyCollection Edges { get;} + public ReadOnlyCollection Nodes { get; } + public ReadOnlyCollection Edges { get; } public Path(IList nodes, IList edges) { diff --git a/src/NRedisStack/Graph/RedisGraphUtilities.cs b/src/NRedisStack/Graph/RedisGraphUtilities.cs index b0eae675..b8bac43e 100644 --- a/src/NRedisStack/Graph/RedisGraphUtilities.cs +++ b/src/NRedisStack/Graph/RedisGraphUtilities.cs @@ -60,7 +60,7 @@ public static string ValueToString(object value) foreach (var val in valueList) { - objectValueList.Add((object) val); + objectValueList.Add((object)val); } return ArrayToString(objectValueList.ToArray()); @@ -90,7 +90,7 @@ private static string ArrayToString(object[] array) { if (x.GetType().IsArray) { - return ArrayToString((object[]) x); + return ArrayToString((object[])x); } else { diff --git a/src/NRedisStack/Graph/ResultSet.cs b/src/NRedisStack/Graph/ResultSet.cs index 334f0a8a..88618fcb 100644 --- a/src/NRedisStack/Graph/ResultSet.cs +++ b/src/NRedisStack/Graph/ResultSet.cs @@ -255,7 +255,7 @@ private Dictionary DeserializeDictionary(RedisResult rawPath) for (int i = 0; i < size; i += 2) { string key = keyTypeValueEntries[i].ToString(); - object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i+1]); + object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i + 1]); dict.Add(key, value); } return dict; diff --git a/src/NRedisStack/Graph/Statistics.cs b/src/NRedisStack/Graph/Statistics.cs index 0991998c..66a5db99 100644 --- a/src/NRedisStack/Graph/Statistics.cs +++ b/src/NRedisStack/Graph/Statistics.cs @@ -11,28 +11,28 @@ internal Statistics(Dictionary statistics) { _statistics = statistics; - NodesCreated = GetIntValue("Nodes created"); - NodesDeleted = GetIntValue("Nodes deleted"); - IndicesAdded = GetIntValue("Indices added"); - IndicesCreated = GetIntValue("Indices created"); - IndicesDeleted = GetIntValue("Indices deleted"); - LabelsAdded = GetIntValue("Labels added"); - RelationshipsDeleted = GetIntValue("Relationships deleted"); - RelationshipsCreated = GetIntValue("Relationships created"); - PropertiesSet = GetIntValue("Properties set"); - QueryInternalExecutionTime = GetStringValue("Query internal execution time"); - GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time"); - CachedExecution = (GetIntValue("Cached execution") == 1); + NodesCreated = GetIntValue("Nodes created"); + NodesDeleted = GetIntValue("Nodes deleted"); + IndicesAdded = GetIntValue("Indices added"); + IndicesCreated = GetIntValue("Indices created"); + IndicesDeleted = GetIntValue("Indices deleted"); + LabelsAdded = GetIntValue("Labels added"); + RelationshipsDeleted = GetIntValue("Relationships deleted"); + RelationshipsCreated = GetIntValue("Relationships created"); + PropertiesSet = GetIntValue("Properties set"); + QueryInternalExecutionTime = GetStringValue("Query internal execution time"); + GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time"); + CachedExecution = (GetIntValue("Cached execution") == 1); - } + } - /// - /// Retrieves the relevant statistic. - /// - /// The requested statistic label. - /// A string representation of the specific statistic or null - public string? GetStringValue(string label) => - _statistics.TryGetValue(label, out string? value) ? value : null; + /// + /// Retrieves the relevant statistic. + /// + /// The requested statistic label. + /// A string representation of the specific statistic or null + public string? GetStringValue(string label) => + _statistics.TryGetValue(label, out string? value) ? value : null; private int GetIntValue(string label) diff --git a/src/NRedisStack/Json/JsonCommandBuilder.cs b/src/NRedisStack/Json/JsonCommandBuilder.cs index b5505100..d5846a8a 100644 --- a/src/NRedisStack/Json/JsonCommandBuilder.cs +++ b/src/NRedisStack/Json/JsonCommandBuilder.cs @@ -34,8 +34,8 @@ public static SerializedCommand MSet(KeyPathValue[] KeyPathValueList) if (KeyPathValueList.Length < 1) throw new ArgumentOutOfRangeException(nameof(KeyPathValueList)); - var args = KeyPathValueList.SelectMany(x => x.ToArray()).ToArray(); - return new SerializedCommand(JSON.MSET, args); + var args = KeyPathValueList.SelectMany(x => x.ToArray()).ToArray(); + return new SerializedCommand(JSON.MSET, args); } public static SerializedCommand Merge(RedisKey key, RedisValue path, RedisValue json) diff --git a/src/NRedisStack/Json/JsonCommandsAsync.cs b/src/NRedisStack/Json/JsonCommandsAsync.cs index c42fcbd5..2623b1b2 100644 --- a/src/NRedisStack/Json/JsonCommandsAsync.cs +++ b/src/NRedisStack/Json/JsonCommandsAsync.cs @@ -169,7 +169,7 @@ public async Task SetFromFileAsync(RedisKey key, RedisValue path, string f throw new FileNotFoundException($"File {filePath} not found."); } - string fileContent = File.ReadAllText(filePath); + string fileContent = File.ReadAllText(filePath); return await SetAsync(key, path, fileContent, when); } @@ -181,7 +181,7 @@ public async Task SetFromDirectoryAsync(RedisValue path, string filesPath, foreach (var filePath in files) { key = filePath.Substring(0, filePath.IndexOf(".")); - if(await SetFromFileAsync(key, path, filePath, when)) + if (await SetFromFileAsync(key, path, filePath, when)) { inserted++; } diff --git a/src/NRedisStack/ResponseParser.cs b/src/NRedisStack/ResponseParser.cs index 2865531e..ce04d2de 100644 --- a/src/NRedisStack/ResponseParser.cs +++ b/src/NRedisStack/ResponseParser.cs @@ -580,7 +580,7 @@ public static List ToStringList(this RedisResult result) return new[] { (long?)result }; } - return ((RedisResult[])result!).Select(x=>(long?)x).ToArray(); + return ((RedisResult[])result!).Select(x => (long?)x).ToArray(); } public static IEnumerable> ToHashSets(this RedisResult result) @@ -626,7 +626,7 @@ public static Dictionary> ToFtSpellCheckResul string termValue = rawElements[1].ToString()!; - var list = (RedisResult[]) rawElements[2]!; + var list = (RedisResult[])rawElements[2]!; Dictionary entries = new Dictionary(list.Length); foreach (var entry in list) { @@ -653,7 +653,7 @@ public static List> ToStringDoubleTupleList(this RedisResu } return list; } - + public static Dictionary ToStringRedisResultDictionary(this RedisResult value) { var res = (RedisResult[])value!; diff --git a/src/NRedisStack/Search/AggregationRequest.cs b/src/NRedisStack/Search/AggregationRequest.cs index e5854f99..29eee63c 100644 --- a/src/NRedisStack/Search/AggregationRequest.cs +++ b/src/NRedisStack/Search/AggregationRequest.cs @@ -39,7 +39,7 @@ public class AggregationRequest // Params: private Dictionary nameValue = new Dictionary(); - public int? dialect {get; private set;} = null; + public int? dialect { get; private set; } = null; public AggregationRequest(string query, int? defaultDialect = null) { @@ -57,7 +57,7 @@ public AggregationRequest Verbatim(bool verbatim = true) private void Verbatim() { - if(verbatim == true) + if (verbatim == true) args.Add("VERBATIM"); } diff --git a/src/NRedisStack/Search/Document.cs b/src/NRedisStack/Search/Document.cs index 7c61b1c1..3135621f 100644 --- a/src/NRedisStack/Search/Document.cs +++ b/src/NRedisStack/Search/Document.cs @@ -8,7 +8,7 @@ namespace NRedisStack.Search public class Document { public string Id { get; } - public double Score { get; set;} + public double Score { get; set; } public byte[] Payload { get; } public string[] ScoreExplained { get; private set; } // TODO: check if this is needed (Jedis does not have it) internal readonly Dictionary _properties; @@ -35,10 +35,12 @@ public static Document Load(string id, double score, byte[] payload, RedisValue[ for (int i = 0; i < fields.Length; i += 2) { string fieldName = (string)fields[i]; - if (fieldName == "$") { + if (fieldName == "$") + { ret["json"] = fields[i + 1]; } - else { + else + { ret[fieldName] = fields[i + 1]; } } diff --git a/src/NRedisStack/Search/FTSpellCheckParams.cs b/src/NRedisStack/Search/FTSpellCheckParams.cs index 97242604..74d3af86 100644 --- a/src/NRedisStack/Search/FTSpellCheckParams.cs +++ b/src/NRedisStack/Search/FTSpellCheckParams.cs @@ -76,12 +76,12 @@ private void Dialect() private void Terms() { - foreach (var term in terms) - { - args.Add(SearchArgs.TERMS); - args.Add(term.Value); - args.Add(term.Key); - } + foreach (var term in terms) + { + args.Add(SearchArgs.TERMS); + args.Add(term.Value); + args.Add(term.Key); + } } private void Distance() diff --git a/src/NRedisStack/Search/Limit.cs b/src/NRedisStack/Search/Limit.cs index 151cbeec..e3e9e917 100644 --- a/src/NRedisStack/Search/Limit.cs +++ b/src/NRedisStack/Search/Limit.cs @@ -11,14 +11,14 @@ public Limit(int offset, int count) _count = count; } -// public void addArgs(List args) { -// if (count == 0) { -// return; -// } -// args.add("LIMIT"); -// args.add(Integer.toString(offset)); -// args.add(Integer.toString(count)); -// } + // public void addArgs(List args) { + // if (count == 0) { + // return; + // } + // args.add("LIMIT"); + // args.add(Integer.toString(offset)); + // args.add(Integer.toString(count)); + // } internal void SerializeRedisArgs(List args) { diff --git a/src/NRedisStack/Search/Query.cs b/src/NRedisStack/Search/Query.cs index 4b2bad54..b75fd184 100644 --- a/src/NRedisStack/Search/Query.cs +++ b/src/NRedisStack/Search/Query.cs @@ -192,7 +192,7 @@ public HighlightTags(string open, string close) // public bool ExplainScore { get; set; } // TODO: Check if this is needed because Jedis doesn't have it private Dictionary _params = new Dictionary(); - public int? dialect { get; private set;} = null; + public int? dialect { get; private set; } = null; private int _slop = -1; private long _timeout = -1; private bool _inOrder = false; diff --git a/src/NRedisStack/Search/SearchCommandBuilder.cs b/src/NRedisStack/Search/SearchCommandBuilder.cs index 7da5b388..1d962a96 100644 --- a/src/NRedisStack/Search/SearchCommandBuilder.cs +++ b/src/NRedisStack/Search/SearchCommandBuilder.cs @@ -163,8 +163,8 @@ public static SerializedCommand ProfileSearch(string IndexName, Query q, bool li { var args = (limited) - ? new List(){IndexName, SearchArgs.SEARCH, SearchArgs.LIMITED, SearchArgs.QUERY} - : new List(){IndexName, SearchArgs.SEARCH, SearchArgs.QUERY}; + ? new List() { IndexName, SearchArgs.SEARCH, SearchArgs.LIMITED, SearchArgs.QUERY } + : new List() { IndexName, SearchArgs.SEARCH, SearchArgs.QUERY }; q.SerializeRedisArgs(args); return new SerializedCommand(FT.PROFILE, args); @@ -172,9 +172,9 @@ public static SerializedCommand ProfileSearch(string IndexName, Query q, bool li public static SerializedCommand ProfileAggregate(string IndexName, AggregationRequest query, bool limited = false) { - var args = (limited) - ? new List{IndexName, SearchArgs.AGGREGATE, SearchArgs.LIMITED, SearchArgs.QUERY} - : new List{IndexName, SearchArgs.AGGREGATE, SearchArgs.QUERY}; + var args = (limited) + ? new List { IndexName, SearchArgs.AGGREGATE, SearchArgs.LIMITED, SearchArgs.QUERY } + : new List { IndexName, SearchArgs.AGGREGATE, SearchArgs.QUERY }; query.SerializeRedisArgs(); args.AddRange(query.GetArgs()); diff --git a/src/NRedisStack/Search/SearchCommands.cs b/src/NRedisStack/Search/SearchCommands.cs index a53772d8..30a1e58d 100644 --- a/src/NRedisStack/Search/SearchCommands.cs +++ b/src/NRedisStack/Search/SearchCommands.cs @@ -16,7 +16,7 @@ public SearchCommands(IDatabase db, int? defaultDialect) : base(db) public void SetDefaultDialect(int? defaultDialect) { - if(defaultDialect == 0) + if (defaultDialect == 0) { throw new System.ArgumentOutOfRangeException("DIALECT=0 cannot be set."); } @@ -87,7 +87,7 @@ public bool Create(string indexName, FTCreateParams parameters, Schema schema) /// public bool Create(string indexName, Schema schema) { - return Create(indexName, new FTCreateParams(), schema); + return Create(indexName, new FTCreateParams(), schema); } /// diff --git a/src/NRedisStack/Search/SearchResult.cs b/src/NRedisStack/Search/SearchResult.cs index d111f6eb..d42bf33b 100644 --- a/src/NRedisStack/Search/SearchResult.cs +++ b/src/NRedisStack/Search/SearchResult.cs @@ -66,7 +66,7 @@ internal SearchResult(RedisResult[] resp, bool hasContent, bool hasScores, bool // } //else //{ - score = (double)resp[i + scoreOffset]; + score = (double)resp[i + scoreOffset]; //} } if (hasPayloads) diff --git a/src/NRedisStack/Tdigest/TdigestCommands.cs b/src/NRedisStack/Tdigest/TdigestCommands.cs index 72d5f847..fd11a3e8 100644 --- a/src/NRedisStack/Tdigest/TdigestCommands.cs +++ b/src/NRedisStack/Tdigest/TdigestCommands.cs @@ -45,7 +45,7 @@ public double Max(RedisKey key) public double Min(RedisKey key) { var cmd = TdigestCommandBuilder.Min(key); - var res =_db.Execute(cmd); + var res = _db.Execute(cmd); return res.ToDouble(); } diff --git a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs index e127ea44..e88de817 100644 --- a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs +++ b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs @@ -68,12 +68,12 @@ public class TimeSeriesInformation /// /// The policy will define handling of duplicate samples. /// - public TsDuplicatePolicy? DuplicatePolicy { get; private set; } + public TsDuplicatePolicy? DuplicatePolicy { get; private set; } /// /// In DEBUG mode: Key self name. /// - public string? KeySelfName { get; private set; } + public string? KeySelfName { get; private set; } /// /// In DEBUG mode: gives more information about the chunks @@ -95,7 +95,7 @@ internal TimeSeriesInformation(long totalSamples, long memoryUsage, SourceKey = sourceKey; Rules = rules; // backwards compatible with RedisTimeSeries < v1.4 - MaxSamplesPerChunk = chunkSize/16; + MaxSamplesPerChunk = chunkSize / 16; ChunkSize = chunkSize; // configure what to do on duplicate sample > v1.4 DuplicatePolicy = policy; diff --git a/src/NRedisStack/TopK/TopKCommandBuilder.cs b/src/NRedisStack/TopK/TopKCommandBuilder.cs index 2adf5fa7..fd697a1d 100644 --- a/src/NRedisStack/TopK/TopKCommandBuilder.cs +++ b/src/NRedisStack/TopK/TopKCommandBuilder.cs @@ -40,7 +40,7 @@ public static SerializedCommand IncrBy(RedisKey key, params Tuple public RedisResult[]? Add(RedisKey key, params RedisValue[] items) { - return (RedisResult[]?) _db.Execute(TopKCommandBuilder.Add(key, items)); + return (RedisResult[]?)_db.Execute(TopKCommandBuilder.Add(key, items)); } /// diff --git a/src/NRedisStack/TopK/TopKCommandsAsync.cs b/src/NRedisStack/TopK/TopKCommandsAsync.cs index 20576147..0fd9656a 100644 --- a/src/NRedisStack/TopK/TopKCommandsAsync.cs +++ b/src/NRedisStack/TopK/TopKCommandsAsync.cs @@ -14,7 +14,7 @@ public TopKCommandsAsync(IDatabaseAsync db) /// public async Task AddAsync(RedisKey key, params RedisValue[] items) { - return (RedisResult[]?) await _db.ExecuteAsync(TopKCommandBuilder.Add(key, items)); + return (RedisResult[]?)await _db.ExecuteAsync(TopKCommandBuilder.Add(key, items)); } /// diff --git a/src/NRedisStack/Transactions.cs b/src/NRedisStack/Transactions.cs index 2399090d..f260fe6d 100644 --- a/src/NRedisStack/Transactions.cs +++ b/src/NRedisStack/Transactions.cs @@ -12,9 +12,9 @@ public Transaction(IDatabase db) _transaction = db.CreateTransaction(); } - public ConditionResult AddCondition(Condition condition) => _transaction.AddCondition(condition); + public ConditionResult AddCondition(Condition condition) => _transaction.AddCondition(condition); - public bool Execute(CommandFlags flags = CommandFlags.None) => _transaction.Execute(flags); + public bool Execute(CommandFlags flags = CommandFlags.None) => _transaction.Execute(flags); public Task ExecuteAsync(CommandFlags flags = CommandFlags.None) => _transaction.ExecuteAsync(flags); diff --git a/tests/Doc/HashExample.cs b/tests/Doc/HashExample.cs index 8212c722..d50f868b 100644 --- a/tests/Doc/HashExample.cs +++ b/tests/Doc/HashExample.cs @@ -122,7 +122,7 @@ public void run() //REMOVE_END // Bike stats: crashes=1, owners=1 //STEP_END - //HIDE_START + //HIDE_START } } //HIDE_END \ No newline at end of file diff --git a/tests/Doc/SearchQuickstartExample.cs b/tests/Doc/SearchQuickstartExample.cs index d8643356..ab282428 100644 --- a/tests/Doc/SearchQuickstartExample.cs +++ b/tests/Doc/SearchQuickstartExample.cs @@ -38,7 +38,7 @@ public void run() Brand = "Velorim", Model = "Jigger", Price = 270M, - Description = "Small and powerful, the Jigger is the best ride " + + Description = "Small and powerful, the Jigger is the best ride " + "for the smallest of tikes! This is the tiniest " + "kids’ pedal bike on the market available without" + " a coaster brake, the Jigger is the vehicle of " + diff --git a/tests/Doc/SetGetExample.cs b/tests/Doc/SetGetExample.cs index 805b8868..a7da9411 100644 --- a/tests/Doc/SetGetExample.cs +++ b/tests/Doc/SetGetExample.cs @@ -31,7 +31,7 @@ public void run() Assert.True(status); Assert.Equal("Process 134", value.ToString()); //REMOVE_END - //HIDE_START + //HIDE_START } } //HIDE_END diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 4d1a7db3..4a63bdf0 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -95,7 +95,7 @@ public void TestCountFilterDoesNotExist() db.Execute("FLUSHALL"); var cf = db.CF(); - Assert.Equal(cf.Count("notExistFilter", "notExistItem"), 0); + Assert.Equal(0, cf.Count("notExistFilter", "notExistItem")); } [Fact] @@ -105,7 +105,7 @@ public async Task TestCountFilterDoesNotExistAsync() db.Execute("FLUSHALL"); var cf = db.CF(); - Assert.Equal(await cf.CountAsync("notExistFilter", "notExistItem"), 0); + Assert.Equal(0, await cf.CountAsync("notExistFilter", "notExistItem")); } [Fact] @@ -116,7 +116,7 @@ public void TestCountFilterExist() var cf = db.CF(); cf.Insert(key, new RedisValue[] { "foo" }); - Assert.Equal(cf.Count(key, "notExistItem"), 0); + Assert.Equal(0, cf.Count(key, "notExistItem")); } [Fact] @@ -127,7 +127,7 @@ public async Task TestCountFilterExistAsync() var cf = db.CF(); await cf.InsertAsync(key, new RedisValue[] { "foo" }); - Assert.Equal(await cf.CountAsync(key, "notExistItem"), 0); + Assert.Equal(0, await cf.CountAsync(key, "notExistItem")); } [Fact] @@ -138,7 +138,7 @@ public void TestCountItemExist() var cf = db.CF(); cf.Insert(key, new RedisValue[] { "foo" }); - Assert.Equal(cf.Count(key, "foo"), 1); + Assert.Equal(1, cf.Count(key, "foo")); } [Fact] @@ -149,7 +149,7 @@ public async Task TestCountItemExistAsync() var cf = db.CF(); await cf.InsertAsync(key, new RedisValue[] { "foo" }); - Assert.Equal(await cf.CountAsync(key, "foo"), 1); + Assert.Equal(1, await cf.CountAsync(key, "foo")); } [Fact] @@ -285,7 +285,7 @@ public void TestInsertNX() Assert.Equal(result, new bool[] { false, false, false }); // test empty items: - Assert.Throws(() => cf.InsertNX(key, new RedisValue[]{})); + Assert.Throws(() => cf.InsertNX(key, new RedisValue[] { })); } [Fact] @@ -313,7 +313,7 @@ public async Task TestInsertNXAsync() Assert.Equal(result, new bool[] { false, false, false }); // test empty items: - Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, new RedisValue[]{})); + Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, new RedisValue[] { })); } [Fact] diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 08a9f42d..58b65efe 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -43,7 +43,7 @@ public void TestCreateNode() Assert.Equal(2, stats.PropertiesSet); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // delete graph.Delete("social"); @@ -66,7 +66,7 @@ public void TestCreateLabeledNode() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // Assert.False(resultSet..iterator().MoveNext()); } @@ -94,7 +94,7 @@ public void TestConnectNodes() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] @@ -120,7 +120,7 @@ public void TestDeleteNodes() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); @@ -140,7 +140,7 @@ public void TestDeleteNodes() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -170,7 +170,7 @@ public void TestDeleteRelationship() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -936,7 +936,7 @@ public void TestConfig() Assert.True(graph.ConfigSet(name, 250L)); var actual = graph.ConfigGet(name); - Assert.Equal(actual.Count, 1); + Assert.Equal(1, actual.Count); Assert.Equal("250", actual[name].ToString()); graph.ConfigSet(name, existingValue != null ? existingValue.ToString() : -1); @@ -1026,7 +1026,7 @@ public async Task TestCreateNodeAsync() Assert.Equal(2, stats.PropertiesSet); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // delete await graph.DeleteAsync("social"); @@ -1049,7 +1049,7 @@ public async Task TestCreateLabeledNodeAsync() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // Assert.False(resultSet..iterator().MoveNext()); } @@ -1077,7 +1077,7 @@ public async Task TestConnectNodesAsync() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // Assert.False(resultSet.GetEnumerator().MoveNext()); } @@ -1104,7 +1104,7 @@ public async Task TestDeleteNodesAsync() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); @@ -1124,7 +1124,7 @@ public async Task TestDeleteNodesAsync() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -1154,7 +1154,7 @@ public async Task TestDeleteRelationshipAsync() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -1909,7 +1909,7 @@ public async Task TestConfigAsync() Assert.True(await graph.ConfigSetAsync(name, 250L)); var actual = await graph.ConfigGetAsync(name); - Assert.Equal(actual.Count, 1); + Assert.Equal(1, actual.Count); Assert.Equal("250", actual[name].ToString()); await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString() : -1); diff --git a/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs b/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs index 8dd7a921..7d30e546 100644 --- a/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs +++ b/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs @@ -8,7 +8,7 @@ public class PathBuilderTest [Fact] public void TestPathBuilderSizeException() { - var thrownException = Assert.Throws(()=> + var thrownException = Assert.Throws(() => { var pathBuilder = new PathBuilder(0); diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 718afb0d..82d40699 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -775,12 +775,12 @@ public void Merge() // Create a connection to Redis var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); - Assert.True(commands.Set("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); + Assert.True(commands.Set("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new { home = "123 Main Street" }, phone = "123-456-7890" } })); Assert.True(commands.Merge("test_merge", "$", new { person = new { age = 30 } })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\"},\"phone\":\"123-456-7890\"}}", commands.Get("test_merge").ToString()); // Test with root path path $.a.b - Assert.True(commands.Merge("test_merge", "$.person.address", new {work = "Redis office"})); + Assert.True(commands.Merge("test_merge", "$.person.address", new { work = "Redis office" })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"},\"phone\":\"123-456-7890\"}}", commands.Get("test_merge").ToString()); // Test with null value to delete a value @@ -794,12 +794,12 @@ public async Task MergeAsync() // Create a connection to Redis var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); - Assert.True(await commands.SetAsync("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); + Assert.True(await commands.SetAsync("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new { home = "123 Main Street" }, phone = "123-456-7890" } })); Assert.True(await commands.MergeAsync("test_merge", "$", new { person = new { age = 30 } })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\"},\"phone\":\"123-456-7890\"}}", (await commands.GetAsync("test_merge")).ToString()); // Test with root path path $.a.b - Assert.True(await commands.MergeAsync("test_merge", "$.person.address", new {work = "Redis office"})); + Assert.True(await commands.MergeAsync("test_merge", "$.person.address", new { work = "Redis office" })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"},\"phone\":\"123-456-7890\"}}", (await commands.GetAsync("test_merge")).ToString()); // Test with null value to delete a value diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 41369e21..592dcfce 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -39,7 +39,7 @@ public async Task TestModulsPipeline() Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("graph-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); @@ -88,7 +88,7 @@ public async Task TestModulsPipelineWithotGraph() Assert.False(db.KeyExists("cms-key")); Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); @@ -122,19 +122,19 @@ public async Task TestBloomPipeline() var pipeline = new Pipeline(db); pipeline.Bf.ReserveAsync(key, 0.001, 100); - for(int i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { pipeline.Bf.AddAsync(key, i.ToString()); } - for(int i = 0; i < 100; i++) + for (int i = 0; i < 100; i++) { Assert.False(db.BF().Exists(key, i.ToString())); } pipeline.Execute(); - for(int i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { Assert.True(db.BF().Exists(key, i.ToString())); } diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 88669f9d..5caf53b5 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -177,7 +177,6 @@ public void TestAggregations() Assert.Equal(2, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("def", r1.GetString("name")); Assert.Equal(30, r1.GetLong("sum")); Assert.Equal(30, r1.GetDouble("sum"), 0); @@ -187,7 +186,6 @@ public void TestAggregations() Assert.Null(r1.GetString("nosuchcol")); Row r2 = res.GetRow(1); - Assert.NotNull(r2); Assert.Equal("abc", r2.GetString("name")); Assert.Equal(10, r2.GetLong("sum")); } @@ -218,7 +216,6 @@ public async Task TestAggregationsAsync() Assert.Equal(2, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("def", r1.GetString("name")); Assert.Equal(30, r1.GetLong("sum")); Assert.Equal(30, r1.GetDouble("sum"), 0); @@ -228,7 +225,6 @@ public async Task TestAggregationsAsync() Assert.Null(r1.GetString("nosuchcol")); Row r2 = res.GetRow(1); - Assert.NotNull(r2); Assert.Equal("abc", r2.GetString("name")); Assert.Equal(10, r2.GetLong("sum")); } @@ -248,18 +244,18 @@ public void TestAggregationsLoad() // load t1 var req = new AggregationRequest("*").Load(new FieldName("t1")); var res = ft.Aggregate("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); + Assert.Equal("hello", res[0]["t1"].ToString()); // load t2 req = new AggregationRequest("*").Load(new FieldName("t2")); res = ft.Aggregate("idx", req); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("world", res[0]["t2"]); // load all req = new AggregationRequest("*").LoadAll(); res = ft.Aggregate("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("hello", res[0]["t1"].ToString()); + Assert.Equal("world", res[0]["t2"]); } [SkipIfRedis(Is.Cluster)] @@ -276,18 +272,18 @@ public async Task TestAggregationsLoadAsync() // load t1 var req = new AggregationRequest("*").Load(new FieldName("t1")); var res = await ft.AggregateAsync("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); + Assert.Equal("hello", res[0]["t1"].ToString()); // load t2 req = new AggregationRequest("*").Load(new FieldName("t2")); res = await ft.AggregateAsync("idx", req); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("world", res[0]["t2"]); // load all req = new AggregationRequest("*").LoadAll(); res = await ft.AggregateAsync("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("hello", res[0]["t1"].ToString()); + Assert.Equal("world", res[0]["t2"]); } @@ -319,7 +315,6 @@ public void TestAggregationRequestParamsDialect() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -355,7 +350,6 @@ public async Task TestAggregationRequestParamsDialectAsync() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -387,7 +381,6 @@ public void TestAggregationRequestParamsWithDefaultDialect() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -419,7 +412,6 @@ public async Task TestAggregationRequestParamsWithDefaultDialectAsync() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -525,12 +517,10 @@ public void TestApplyAndFilterAggregations() Assert.Equal(3, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("def", r1.GetString("name")); Assert.Equal(52.5, r1.GetDouble("avgscore"), 0); Row r2 = res.GetRow(1); - Assert.NotNull(r2); Assert.Equal("ghi", r2.GetString("name")); Assert.Equal(67.5, r2.GetDouble("avgscore"), 0); } @@ -748,7 +738,7 @@ public void AlterAdd() var info = ft.Info(index); Assert.Equal(index, info.IndexName); - Assert.Equal(0, info.IndexOption.Count); + Assert.Empty(info.IndexOption); // Assert.Equal(,info.IndexDefinition); Assert.Equal("title", (info.Attributes[0]["identifier"]).ToString()); Assert.Equal("TAG", (info.Attributes[1]["type"]).ToString()); @@ -1090,68 +1080,68 @@ public void TestAggregationGroupBy() var req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Count()); var res = ft.Aggregate("idx", req).GetRow(0); Assert.True(res.ContainsKey("parent")); - Assert.Equal(res["parent"], "redis"); + Assert.Equal("redis", res["parent"]); // Assert.Equal(res["__generated_aliascount"], "3"); req = new AggregationRequest("redis").GroupBy("@parent", Reducers.CountDistinct("@title")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliascount_distincttitle"), 3); + Assert.Equal("redis", res["parent"]); + Assert.Equal(3, res.GetLong("__generated_aliascount_distincttitle")); req = new AggregationRequest("redis").GroupBy("@parent", Reducers.CountDistinctish("@title")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliascount_distinctishtitle"), 3); + Assert.Equal("redis", res["parent"]); + Assert.Equal(3, res.GetLong("__generated_aliascount_distinctishtitle")); req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Sum("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliassumrandom_num"), 21); // 10+8+3 + Assert.Equal("redis", res["parent"]); + Assert.Equal(21, res.GetLong("__generated_aliassumrandom_num")); // 10+8+3 req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Min("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasminrandom_num"), 3); // min(10,8,3) + Assert.Equal("redis", res["parent"]); + Assert.Equal(3, res.GetLong("__generated_aliasminrandom_num")); // min(10,8,3) req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Max("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasmaxrandom_num"), 10); // max(10,8,3) + Assert.Equal("redis", res["parent"]); + Assert.Equal(10, res.GetLong("__generated_aliasmaxrandom_num")); // max(10,8,3) req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Avg("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasavgrandom_num"), 7); // (10+3+8)/3 + Assert.Equal("redis", res["parent"]); + Assert.Equal(7, res.GetLong("__generated_aliasavgrandom_num")); // (10+3+8)/3 req = new AggregationRequest("redis").GroupBy("@parent", Reducers.StdDev("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetDouble("__generated_aliasstddevrandom_num"), 3.60555127546); + Assert.Equal("redis", res["parent"]); + Assert.Equal(3.60555127546, res.GetDouble("__generated_aliasstddevrandom_num")); req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.Quantile("@random_num", 0.5)); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasquantilerandom_num,0.5"), 8); // median of 3,8,10 + Assert.Equal("redis", res["parent"]); + Assert.Equal(8, res.GetLong("__generated_aliasquantilerandom_num,0.5")); // median of 3,8,10 req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.ToList("@title")); var rawRes = ft.Aggregate("idx", req); res = rawRes.GetRow(0); - Assert.Equal(res["parent"], "redis"); + Assert.Equal("redis", res["parent"]); // TODO: complete this assert after handling multi bulk reply //Assert.Equal((RedisValue[])res["__generated_aliastolisttitle"], { "RediSearch", "RedisAI", "RedisJson"}); req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.FirstValue("@title").As("first")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res["first"], "RediSearch"); + Assert.Equal("redis", res["parent"]); + Assert.Equal("RediSearch", res["first"]); req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.RandomSample("@title", 2).As("random")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); + Assert.Equal("redis", res["parent"]); // TODO: complete this assert after handling multi bulk reply // Assert.Equal(res[2], "random"); // Assert.Equal(len(res[3]), 2); @@ -1177,7 +1167,7 @@ public void TestDictionary() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, ft.DictDel("dict", "foo", "bar", "hello world")); - Assert.Equal(ft.DictDump("dict").Length, 0); + Assert.Equal(0, ft.DictDump("dict").Length); } [SkipIfRedis(Is.Cluster)] @@ -1208,7 +1198,7 @@ public void TestDropIndex() } catch (RedisServerException ex) { - Assert.True(ex.Message.Contains("no such index")); + Assert.Contains("no such index", ex.Message); } Assert.Equal("100", db.Execute("DBSIZE").ToString()); } @@ -1241,7 +1231,7 @@ public async Task TestDropIndexAsync() } catch (RedisServerException ex) { - Assert.True(ex.Message.Contains("no such index")); + Assert.Contains("no such index", ex.Message); } Assert.Equal("100", db.Execute("DBSIZE").ToString()); } @@ -1314,7 +1304,7 @@ public async Task TestDictionaryAsync() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, await ft.DictDelAsync("dict", "foo", "bar", "hello world")); - Assert.Equal((await ft.DictDumpAsync("dict")).Length, 0); + Assert.Equal(0, (await ft.DictDumpAsync("dict")).Length); } string explainQuery = "@f3:f3_val @f2:f2_val @f1:f1_val"; @@ -1552,19 +1542,19 @@ public async Task GetTagFieldSyncAsync() var SyncRes = ft.TagVals(index, "category"); int i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange;purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange;purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); var AsyncRes = await ft.TagValsAsync(index, "category"); i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange;purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange;purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); } [SkipIfRedis(Is.Cluster)] @@ -1610,19 +1600,19 @@ public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync() var SyncRes = ft.TagVals(index, "category"); int i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange,purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange,purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); var AsyncRes = await ft.TagValsAsync(index, "category"); i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange,purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange,purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); } @@ -1889,7 +1879,7 @@ public void TestQueryCommandBuilder() var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("txt")); var res = ft.Search("idx", testQuery); - Assert.Equal(0, res.Documents.Count()); + Assert.Empty(res.Documents); } [Fact] @@ -1925,7 +1915,7 @@ public void TestQueryCommandBuilderReturnField() var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("txt")); var res = ft.Search("idx", testQuery); - Assert.Equal(0, res.Documents.Count()); + Assert.Empty(res.Documents); } [SkipIfRedis(Is.Cluster)] @@ -2019,8 +2009,8 @@ public void TestLimit() var req = new AggregationRequest("*").SortBy("@t1").Limit(1); var res = ft.Aggregate("idx", req); - Assert.Equal(res.GetResults().Count, 1); - Assert.Equal(res.GetResults()[0]["t1"].ToString(), "a"); + Assert.Equal(1, res.GetResults().Count); + Assert.Equal("a", res.GetResults()[0]["t1"].ToString()); } [SkipIfRedis(Is.Cluster)] @@ -2039,8 +2029,8 @@ public async Task TestLimitAsync() var req = new AggregationRequest("*").SortBy("@t1").Limit(1, 1); var res = await ft.AggregateAsync("idx", req); - Assert.Equal(res.GetResults().Count, 1); - Assert.Equal(res.GetResults()[0]["t1"].ToString(), "b"); + Assert.Equal(1, res.GetResults().Count); + Assert.Equal("b", res.GetResults()[0]["t1"].ToString()); } [Fact] @@ -2435,7 +2425,7 @@ public void TestAddAndGetSuggestion() Assert.Equal(1, ft.SugGet(key, suggestion.Substring(0, 3), true, max: 5).Count); // turn off fuzzy start at second word no hit - Assert.Equal(0, ft.SugGet(key, noMatch.Substring(1, 6), false, max: 5).Count); + Assert.Empty(ft.SugGet(key, noMatch.Substring(1, 6), false, max: 5)); // my attempt to trigger the fuzzy by 1 character Assert.Equal(1, ft.SugGet(key, noMatch.Substring(1, 6), true, max: 5).Count); @@ -2458,7 +2448,7 @@ public async Task TestAddAndGetSuggestionAsync() Assert.Equal(1, (await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5)).Count); // turn off fuzzy start at second word no hit - Assert.Equal(0, (await ft.SugGetAsync(key, noMatch.Substring(1, 6), false, max: 5)).Count); + Assert.Empty((await ft.SugGetAsync(key, noMatch.Substring(1, 6), false, max: 5))); // my attempt to trigger the fuzzy by 1 character Assert.Equal(1, (await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5)).Count); @@ -2574,8 +2564,8 @@ public void getSuggestionNoHit() var ft = db.FT(); ft.SugAdd(key, "NO WORD", 0.4); - Assert.Equal(0, ft.SugGetWithScores(key, "DIF").Count); - Assert.Equal(0, ft.SugGet(key, "DIF").Count); + Assert.Empty(ft.SugGetWithScores(key, "DIF")); + Assert.Empty(ft.SugGet(key, "DIF")); } [Fact] @@ -2586,8 +2576,8 @@ public async Task getSuggestionNoHitAsync() var ft = db.FT(); await ft.SugAddAsync(key, "NO WORD", 0.4); - Assert.Equal(0, (await ft.SugGetWithScoresAsync(key, "DIF")).Count); - Assert.Equal(0, (await ft.SugGetAsync(key, "DIF")).Count); + Assert.Empty((await ft.SugGetWithScoresAsync(key, "DIF"))); + Assert.Empty((await ft.SugGetAsync(key, "DIF"))); } [Fact] @@ -2702,16 +2692,16 @@ public void TestProfile() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count, 5); - Assert.Equal(searchRes.Documents.Count, 2); + Assert.Equal(5, searchDet.Count); + Assert.Equal(2, searchRes.Documents.Count); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = ft.ProfileAggregate(index, aggReq); var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count, 5); - Assert.Equal(aggregateRes.TotalResults, 1); + Assert.Equal(5, aggregateDet.Count); + Assert.Equal(1, aggregateRes.TotalResults); } [Fact] @@ -2731,16 +2721,16 @@ public async Task TestProfileAsync() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count, 5); - Assert.Equal(searchRes.Documents.Count, 2); + Assert.Equal(5, searchDet.Count); + Assert.Equal(2, searchRes.Documents.Count); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = await ft.ProfileAggregateAsync(index, aggReq); var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count, 5); - Assert.Equal(aggregateRes.TotalResults, 1); + Assert.Equal(5, aggregateDet.Count); + Assert.Equal(1, aggregateRes.TotalResults); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs index ce15694c..2fc943f7 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs @@ -57,8 +57,8 @@ public void TestAlterPolicyAndChunk() ts.Create(key); Assert.True(ts.Alter(key, chunkSizeBytes: 128, duplicatePolicy: TsDuplicatePolicy.MIN)); TimeSeriesInformation info = ts.Info(key); - Assert.Equal(info.ChunkSize, 128); - Assert.Equal(info.DuplicatePolicy, TsDuplicatePolicy.MIN); + Assert.Equal(128, info.ChunkSize); + Assert.Equal(TsDuplicatePolicy.MIN, info.DuplicatePolicy); } } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs index 688860e9..05a992ce 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs @@ -56,8 +56,8 @@ public async Task TestAlterPolicyAndChunkAsync() ts.Create(key); Assert.True(await ts.AlterAsync(key, chunkSizeBytes: 128, duplicatePolicy: TsDuplicatePolicy.MIN)); TimeSeriesInformation info = ts.Info(key); - Assert.Equal(info.ChunkSize, 128); - Assert.Equal(info.DuplicatePolicy, TsDuplicatePolicy.MIN); + Assert.Equal(128, info.ChunkSize); + Assert.Equal(TsDuplicatePolicy.MIN, info.DuplicatePolicy); } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs index f4432c16..9318fd07 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs @@ -28,16 +28,16 @@ public void TestInformationSync() Assert.Equal(4184, info.MemoryUsage); Assert.Equal(0, info.RetentionTime); Assert.Equal(1, info.ChunkCount); - Assert.Equal(null, info.DuplicatePolicy); + Assert.Null(info.DuplicatePolicy); Assert.Null(info.KeySelfName); Assert.Null(info.Chunks); Assert.Equal(4184, infoDebug.MemoryUsage); Assert.Equal(0, infoDebug.RetentionTime); Assert.Equal(1, infoDebug.ChunkCount); - Assert.Equal(null, infoDebug.DuplicatePolicy); + Assert.Null(infoDebug.DuplicatePolicy); Assert.Equal(infoDebug.KeySelfName, key); - Assert.Equal(infoDebug.Chunks.Count, 1); + Assert.Equal(1, infoDebug.Chunks!.Count); } [Fact] @@ -56,16 +56,16 @@ public async Task TestInformationAsync() Assert.Equal(4184, info.MemoryUsage); Assert.Equal(0, info.RetentionTime); Assert.Equal(1, info.ChunkCount); - Assert.Equal(null, info.DuplicatePolicy); + Assert.Null(info.DuplicatePolicy); Assert.Null(info.KeySelfName); Assert.Null(info.Chunks); Assert.Equal(4184, infoDebug.MemoryUsage); Assert.Equal(0, infoDebug.RetentionTime); Assert.Equal(1, infoDebug.ChunkCount); - Assert.Equal(null, infoDebug.DuplicatePolicy); + Assert.Null(infoDebug.DuplicatePolicy); Assert.Equal(infoDebug.KeySelfName, key); - Assert.Equal(infoDebug.Chunks.Count, 1); + Assert.Equal(1, infoDebug.Chunks!.Count); } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 87ab2bac..7e8ddada 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -25,7 +25,7 @@ public void CreateTopKFilter() topk.Reserve(key, 30, 2000, 7, 0.925); var res = topk.Add(key, "bb", "cc"); - Assert.True(res[0].IsNull && res[1].IsNull); + Assert.True(res![0].IsNull && res[1].IsNull); Assert.Equal(topk.Query(key, "bb", "gg", "cc"), new bool[] { true, false, true }); Assert.False(topk.Query(key, "notExists")); @@ -33,23 +33,23 @@ public void CreateTopKFilter() Assert.Equal(topk.Count(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); var res2 = topk.List(key); - Assert.Equal(res2[0].ToString(), "bb"); - Assert.Equal(res2[1].ToString(), "cc"); + Assert.Equal("bb", res2[0].ToString()); + Assert.Equal("cc", res2[1].ToString()); var tuple = new Tuple("ff", 10); var del = topk.IncrBy(key, tuple); Assert.True(topk.IncrBy(key, tuple)[0].IsNull); res2 = topk.List(key); - Assert.Equal(res2[0].ToString(), "ff"); - Assert.Equal(res2[1].ToString(), "bb"); - Assert.Equal(res2[2].ToString(), "cc"); + Assert.Equal("ff", res2[0].ToString()); + Assert.Equal("bb", res2[1].ToString()); + Assert.Equal("cc", res2[2].ToString()); var info = topk.Info(key); - Assert.Equal(info.Decay, 0.925); - Assert.Equal(info.Depth, 7); - Assert.Equal(info.K, 30); - Assert.Equal(info.Width, 2000); + Assert.Equal(0.925, info.Decay); + Assert.Equal(7, info.Depth); + Assert.Equal(30, info.K); + Assert.Equal(2000, info.Width); } [Fact] @@ -70,22 +70,22 @@ public async Task CreateTopKFilterAsync() Assert.Equal(await topk.CountAsync(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); var res2 = await topk.ListAsync(key); - Assert.Equal(res2[0].ToString(), "bb"); - Assert.Equal(res2[1].ToString(), "cc"); + Assert.Equal("bb", res2[0].ToString()); + Assert.Equal("cc", res2[1].ToString()); var tuple = new Tuple("ff", 10); Assert.True((await topk.IncrByAsync(key, tuple))[0].IsNull); res2 = await topk.ListAsync(key); - Assert.Equal(res2[0].ToString(), "ff"); - Assert.Equal(res2[1].ToString(), "bb"); - Assert.Equal(res2[2].ToString(), "cc"); + Assert.Equal("ff", res2[0].ToString()); + Assert.Equal("bb", res2[1].ToString()); + Assert.Equal("cc", res2[2].ToString()); var info = await topk.InfoAsync(key); - Assert.Equal(info.Decay, 0.925); - Assert.Equal(info.Depth, 7); - Assert.Equal(info.K, 30); - Assert.Equal(info.Width, 2000); + Assert.Equal(0.925, info.Decay); + Assert.Equal(7, info.Depth); + Assert.Equal(30, info.K); + Assert.Equal(2000, info.Width); } [Fact] diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 48d9dd14..10618576 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -55,7 +55,7 @@ public async Task TestModulsTransaction() Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("graph-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); @@ -104,7 +104,7 @@ public async Task TestModulsTransactionWithoutGraph() Assert.False(db.KeyExists("cms-key")); Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); From f0f4f3d29497a45887c49c6f1cc85f63e37c4f2c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 20 Sep 2023 16:59:28 +0300 Subject: [PATCH 35/48] format --- tests/NRedisStack.Tests/Graph/GraphTests.cs | 78 +++++++++---------- tests/NRedisStack.Tests/Search/SearchTests.cs | 12 +-- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index f1350dec..4c5f397a 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -300,7 +300,7 @@ public void TestRecord() Assert.NotNull(stats.QueryInternalExecutionTime); Assert.NotEmpty(stats.QueryInternalExecutionTime); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // IReadOnlyCollection iterator = resultSet.GetEnumerator(); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); @@ -389,7 +389,7 @@ public void TestAdditionToProcedures() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); var record = iterator.Current; @@ -422,7 +422,7 @@ public void TestAdditionToProcedures() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -491,11 +491,11 @@ public void TestArraySupport() List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -513,11 +513,11 @@ public void TestArraySupport() schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -536,7 +536,7 @@ record = iterator.Current; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record @@ -613,7 +613,7 @@ public void TestNullGraphEntities() Assert.NotNull(graph.Query("social", "CREATE (:L)-[:E]->(:L2)")); // Test a query that produces 1 record with 3 null values. ResultSet resultSet = graph.Query("social", "OPTIONAL MATCH (a:NONEXISTENT)-[e]->(b) RETURN a, e, b"); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); IEnumerator iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -667,7 +667,7 @@ public void Test64BitNumber() Dictionary parameters = new Dictionary(); parameters.Add("val", value); ResultSet resultSet = graph.Query("social", "CREATE (n {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; // Assert.Equal(value, r.Values[0]); @@ -687,7 +687,7 @@ public void TestCachedExecution() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = graph.Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; Assert.Equal(parameters["val"], resultSet.First().Values[0]); Assert.False(resultSet.Statistics.CachedExecution); @@ -698,7 +698,7 @@ public void TestCachedExecution() { resultSet = graph.Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // r = resultSet.GetEnumerator().Current; // Assert.Equal(parameters["val"], r.Values[0]); Assert.Equal(parameters["val"], resultSet.First().Values[0]); @@ -727,7 +727,7 @@ public void TestMapDataType() f.Add("y", (long)2); expected.Add("f", f); ResultSet res = graph.Query("social", "RETURN {a:1, b:'str', c:NULL, d:[1,2,3], e:True, f:{x:1, y:2}}"); - Assert.Equal(1, res.Count); + Assert.Single(res); var iterator = res.GetEnumerator(); iterator.MoveNext(); @@ -767,7 +767,7 @@ public void TestGeoPointLonLat() private void AssertTestGeoPoint(IGraphCommands graph) { ResultSet results = graph.Query("social", "MATCH (restaurant) RETURN restaurant"); - Assert.Equal(1, results.Count); + Assert.Single(results); var record = results.GetEnumerator(); record.MoveNext(); Assert.Equal(1, record.Current.Size); @@ -798,7 +798,7 @@ public void timeoutArgument() db.Execute("FLUSHALL"); var graph = db.GRAPH(); ResultSet rs = graph.Query("social", "UNWIND range(0,100) AS x WITH x AS x WHERE x = 100 RETURN x", 1L); - Assert.Equal(1, rs.Count); + Assert.Single(rs); var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -817,7 +817,7 @@ public void TestCachedExecutionReadOnly() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = graph.RO_Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); iterator.MoveNext(); NRedisStack.Graph.Record r = iterator.Current; @@ -830,7 +830,7 @@ public void TestCachedExecutionReadOnly() { resultSet = graph.RO_Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); iterator.MoveNext(); r = iterator.Current; @@ -846,7 +846,7 @@ public void TestSimpleReadOnly() var graph = db.GRAPH(); graph.Query("social", "CREATE (:person{name:'filipe',age:30})"); ResultSet rsRo = graph.RO_Query("social", "MATCH (a:person) WHERE (a.name = 'filipe') RETURN a.age"); - Assert.Equal(1, rsRo.Count); + Assert.Single(rsRo); var iterator = rsRo.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -931,7 +931,7 @@ public void TestConfig() Assert.True(graph.ConfigSet(name, 250L)); var actual = graph.ConfigGet(name); - Assert.Equal(1, actual.Count); + Assert.Single(actual); Assert.Equal("250", actual[name].ToString()); graph.ConfigSet(name, existingValue != null ? existingValue.ToString() : -1); @@ -1286,7 +1286,7 @@ await graph.QueryAsync("social", "MATCH (a:person), (b:person) WHERE (a.name = ' Assert.NotNull(stats.QueryInternalExecutionTime); Assert.NotEmpty(stats.QueryInternalExecutionTime); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // IReadOnlyCollection iterator = resultSet.GetEnumerator(); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); @@ -1375,7 +1375,7 @@ public async Task TestAdditionToProceduresAsync() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); var record = iterator.Current; @@ -1408,7 +1408,7 @@ public async Task TestAdditionToProceduresAsync() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -1477,11 +1477,11 @@ public async Task TestArraySupportAsync() List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -1499,11 +1499,11 @@ public async Task TestArraySupportAsync() schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -1522,7 +1522,7 @@ record = iterator.Current; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record @@ -1599,7 +1599,7 @@ public async Task TestNullGraphEntitiesAsync() Assert.NotNull(await graph.QueryAsync("social", "CREATE (:L)-[:E]->(:L2)")); // Test a query that produces 1 record with 3 null values. ResultSet resultSet = await graph.QueryAsync("social", "OPTIONAL MATCH (a:NONEXISTENT)-[e]->(b) RETURN a, e, b"); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); IEnumerator iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -1653,7 +1653,7 @@ public async Task Test64bitnumberAsync() Dictionary parameters = new Dictionary(); parameters.Add("val", value); ResultSet resultSet = await graph.QueryAsync("social", "CREATE (n {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; // Assert.Equal(value, r.Values[0]); @@ -1673,7 +1673,7 @@ public async Task TestCachedExecutionAsync() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = await graph.QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; Assert.Equal(parameters["val"], resultSet.First().Values[0]); Assert.False(resultSet.Statistics.CachedExecution); @@ -1684,7 +1684,7 @@ public async Task TestCachedExecutionAsync() { resultSet = await graph.QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // r = resultSet.GetEnumerator().Current; // Assert.Equal(parameters["val"], r.Values[0]); Assert.Equal(parameters["val"], resultSet.First().Values[0]); @@ -1713,7 +1713,7 @@ public async Task TestMapDataTypeAsync() f.Add("y", (long)2); expected.Add("f", f); ResultSet res = await graph.QueryAsync("social", "RETURN {a:1, b:'str', c:NULL, d:[1,2,3], e:True, f:{x:1, y:2}}"); - Assert.Equal(1, res.Count); + Assert.Single(res); var iterator = res.GetEnumerator(); iterator.MoveNext(); @@ -1753,7 +1753,7 @@ public async Task TestGeoPointLonLatAsync() private async Task AssertTestGeoPointAsync(GraphCommands graph) { ResultSet results = await graph.QueryAsync("social", "MATCH (restaurant) RETURN restaurant"); - Assert.Equal(1, results.Count); + Assert.Single(results); var record = results.GetEnumerator(); record.MoveNext(); Assert.Equal(1, record.Current.Size); @@ -1771,7 +1771,7 @@ public async Task timeoutArgumentAsync() db.Execute("FLUSHALL"); var graph = db.GRAPH(); ResultSet rs = await graph.QueryAsync("social", "UNWIND range(0,100) AS x WITH x AS x WHERE x = 100 RETURN x", 1L); - Assert.Equal(1, rs.Count); + Assert.Single(rs); var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -1790,7 +1790,7 @@ public async Task TestCachedExecutionReadOnlyAsync() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = await graph.RO_QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); iterator.MoveNext(); NRedisStack.Graph.Record r = iterator.Current; @@ -1803,7 +1803,7 @@ public async Task TestCachedExecutionReadOnlyAsync() { resultSet = await graph.RO_QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); iterator.MoveNext(); r = iterator.Current; @@ -1819,7 +1819,7 @@ public async Task TestSimpleReadOnlyAsync() var graph = db.GRAPH(); await graph.QueryAsync("social", "CREATE (:person{name:'filipe',age:30})"); ResultSet rsRo = await graph.RO_QueryAsync("social", "MATCH (a:person) WHERE (a.name = 'filipe') RETURN a.age"); - Assert.Equal(1, rsRo.Count); + Assert.Single(rsRo); var iterator = rsRo.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -1904,7 +1904,7 @@ public async Task TestConfigAsync() Assert.True(await graph.ConfigSetAsync(name, 250L)); var actual = await graph.ConfigGetAsync(name); - Assert.Equal(1, actual.Count); + Assert.Single(actual); Assert.Equal("250", actual[name].ToString()); await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString() : -1); @@ -1972,7 +1972,7 @@ public void TestParseInfinity() db.Execute("FLUSHALL"); var graph = db.GRAPH(); ResultSet rs = graph.Query("db", "RETURN 10^100000"); - Assert.Equal(1, rs.Count()); + Assert.Single(rs); var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 51b27581..be4be390 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -2249,7 +2249,7 @@ public void TestBasicSpellCheck() db.HashSet("doc1", new HashEntry[] { new HashEntry("name", "name2"), new HashEntry("body", "name2") }); var reply = ft.SpellCheck(index, "name"); - Assert.Equal(1, reply.Keys.Count); + Assert.Single(reply.Keys); Assert.Equal("name", reply.Keys.First()); Assert.Equal(1, reply["name"]["name1"]); Assert.Equal(2, reply["name"]["name2"]); @@ -2269,7 +2269,7 @@ public async Task TestBasicSpellCheckAsync() db.HashSet("doc1", new HashEntry[] { new HashEntry("name", "name2"), new HashEntry("body", "name2") }); var reply = await ft.SpellCheckAsync(index, "name"); - Assert.Equal(1, reply.Keys.Count); + Assert.Single(reply.Keys); Assert.Equal("name", reply.Keys.First()); Assert.Equal(1, reply["name"]["name1"]); Assert.Equal(2, reply["name"]["name2"]); @@ -2415,13 +2415,13 @@ public void TestAddAndGetSuggestion() Assert.True(ft.SugAdd(key, noMatch, 1d) > 0); // test that with a partial part of that string will have the entire word returned - Assert.Equal(1, ft.SugGet(key, suggestion.Substring(0, 3), true, max: 5).Count); + Assert.Single(ft.SugGet(key, suggestion.Substring(0, 3), true, max: 5)); // turn off fuzzy start at second word no hit Assert.Empty(ft.SugGet(key, noMatch.Substring(1, 6), false, max: 5)); // my attempt to trigger the fuzzy by 1 character - Assert.Equal(1, ft.SugGet(key, noMatch.Substring(1, 6), true, max: 5).Count); + Assert.Single(ft.SugGet(key, noMatch.Substring(1, 6), true, max: 5)); } [Fact] @@ -2438,13 +2438,13 @@ public async Task TestAddAndGetSuggestionAsync() Assert.True(await ft.SugAddAsync(key, noMatch, 1d) > 0); // test that with a partial part of that string will have the entire word returned - Assert.Equal(1, (await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5)).Count); + Assert.Single(await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5)); // turn off fuzzy start at second word no hit Assert.Empty((await ft.SugGetAsync(key, noMatch.Substring(1, 6), false, max: 5))); // my attempt to trigger the fuzzy by 1 character - Assert.Equal(1, (await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5)).Count); + Assert.Single(await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5)); } [Fact] From 87a8549292fff516dfc358d3c1773fc023deee4f Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 20 Sep 2023 17:00:07 +0300 Subject: [PATCH 36/48] format --- tests/NRedisStack.Tests/Search/SearchTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index be4be390..9c0fb072 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -1160,7 +1160,7 @@ public void TestDictionary() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, ft.DictDel("dict", "foo", "bar", "hello world")); - Assert.Equal(0, ft.DictDump("dict").Length); + Assert.Empty(ft.DictDump("dict")); } [SkipIfRedis(Is.OSSCluster)] @@ -1297,7 +1297,7 @@ public async Task TestDictionaryAsync() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, await ft.DictDelAsync("dict", "foo", "bar", "hello world")); - Assert.Equal(0, (await ft.DictDumpAsync("dict")).Length); + Assert.Empty((await ft.DictDumpAsync("dict"))); } string explainQuery = "@f3:f3_val @f2:f2_val @f1:f1_val"; From 9309d408225e4d1b0674332bee3e5a97447543b7 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 20 Sep 2023 17:32:26 +0300 Subject: [PATCH 37/48] add linter.yaml --- .github/workflows/linter.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/linter.yaml diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml new file mode 100644 index 00000000..f372eac6 --- /dev/null +++ b/.github/workflows/linter.yaml @@ -0,0 +1,27 @@ +name: Lint Code Base + +on: + push: + branches-ignore: [master] + # Remove the line above to run when pushing to master + pull_request: + branches: [master] + +jobs: + build: + name: Lint Code Base + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + + - name: Lint Code Base + uses: github/super-linter@v3 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From abdf4b427b8399e15f45a0eed4ac42fbca759e1e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 20 Sep 2023 17:49:27 +0300 Subject: [PATCH 38/48] update linter --- .github/workflows/linter.yaml | 78 ++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 23 deletions(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index f372eac6..1a56aa80 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -1,27 +1,59 @@ -name: Lint Code Base +--- + ################################# + ################################# + ## Super Linter GitHub Actions ## + ################################# + ################################# + name: Lint Code Base -on: - push: - branches-ignore: [master] - # Remove the line above to run when pushing to master - pull_request: - branches: [master] + ############################# + # Start the job on all push # + ############################# + on: + push: + branches-ignore: [master, main] + # Remove the line above to run when pushing to master or main + pull_request: + branches: [master, main] -jobs: - build: - name: Lint Code Base - runs-on: ubuntu-latest + ############### + # Set the Job # + ############### + jobs: + build: + # Name the Job + name: Lint Code Base + # Set the agent to run on + runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v2 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - fetch-depth: 0 + ############################################ + # Grant status permission for MULTI_STATUS # + ############################################ + permissions: + contents: read + packages: read + statuses: write - - name: Lint Code Base - uses: github/super-linter@v3 - env: - VALIDATE_ALL_CODEBASE: false - DEFAULT_BRANCH: master - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + ################## + # Load all steps # + ################## + steps: + ########################## + # Checkout the code base # + ########################## + - name: Checkout Code + uses: actions/checkout@v4 + with: + # Full git history is needed to get a proper + # list of changed files within `super-linter` + fetch-depth: 0 + + ################################ + # Run Linter against code base # + ################################ + - name: Lint Code Base + uses: super-linter/super-linter@v5 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: main + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 5b35f845a0a2e298ddd013e68156d1ff0eb44246 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 20 Sep 2023 18:01:02 +0300 Subject: [PATCH 39/48] lint on push --- .github/workflows/linter.yaml | 70 +++++++---------------------------- 1 file changed, 14 insertions(+), 56 deletions(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 1a56aa80..c0446295 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -1,59 +1,17 @@ ---- - ################################# - ################################# - ## Super Linter GitHub Actions ## - ################################# - ################################# - name: Lint Code Base +name: Format check on push +on: push +jobs: + dotnet-format: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 - ############################# - # Start the job on all push # - ############################# - on: - push: - branches-ignore: [master, main] - # Remove the line above to run when pushing to master or main - pull_request: - branches: [master, main] + - name: Add dotnet-format problem matcher + uses: xt0rted/dotnet-format-problem-matcher@v1 - ############### - # Set the Job # - ############### - jobs: - build: - # Name the Job - name: Lint Code Base - # Set the agent to run on - runs-on: ubuntu-latest + - name: Restore dotnet tools + uses: xt0rted/dotnet-tool-restore@v1 - ############################################ - # Grant status permission for MULTI_STATUS # - ############################################ - permissions: - contents: read - packages: read - statuses: write - - ################## - # Load all steps # - ################## - steps: - ########################## - # Checkout the code base # - ########################## - - name: Checkout Code - uses: actions/checkout@v4 - with: - # Full git history is needed to get a proper - # list of changed files within `super-linter` - fetch-depth: 0 - - ################################ - # Run Linter against code base # - ################################ - - name: Lint Code Base - uses: super-linter/super-linter@v5 - env: - VALIDATE_ALL_CODEBASE: false - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + - name: Run dotnet format + uses: xt0rted/dotnet-format@v1 \ No newline at end of file From 204e2bee48cac5fa007ba28ceeef316a73186bde Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 21 Sep 2023 16:15:41 +0300 Subject: [PATCH 40/48] change linter --- .github/workflows/linter.yaml | 38 ++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index c0446295..14d5e28f 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -1,17 +1,35 @@ -name: Format check on push -on: push +name: Format check on pull request +on: pull_request jobs: dotnet-format: - runs-on: ubuntu-latest + runs-on: windows-latest steps: + - name: Install dotnet-format + run: dotnet tool install -g dotnet-format + - name: Checkout repo uses: actions/checkout@v2 - - - name: Add dotnet-format problem matcher - uses: xt0rted/dotnet-format-problem-matcher@v1 - - - name: Restore dotnet tools - uses: xt0rted/dotnet-tool-restore@v1 + with: + ref: ${{ github.head_ref }} - name: Run dotnet format - uses: xt0rted/dotnet-format@v1 \ No newline at end of file + id: format + uses: jfversluis/dotnet-format@v1.0.5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + action: "fix" + only-changed-files: true + + - name: Commit files + if: steps.format.outputs.has-changes == 'true' + run: | + git config --local user.name "github-actions[bot]" + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -a -m 'Automated dotnet-format update + Co-authored-by: ${{ github.event.pull_request.user.login }} <${{ github.event.pull_request.user.id }}+${{ github.event.pull_request.user.login }}@users.noreply.github.com>' + - name: Push changes + if: steps.format.outputs.has-changes == 'true' + uses: ad-m/github-push-action@v0.5.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.head_ref }} From 50ce6cc897658118127826ce130f0806d9f949d7 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 21 Sep 2023 16:21:34 +0300 Subject: [PATCH 41/48] create lint problems to see what happen --- src/NRedisStack/Bloom/BloomCommands.cs | 2 +- src/NRedisStack/Search/SearchCommands.cs | 2 +- tests/NRedisStack.Tests/Json/JsonTests.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NRedisStack/Bloom/BloomCommands.cs b/src/NRedisStack/Bloom/BloomCommands.cs index d4f3acb9..99694540 100644 --- a/src/NRedisStack/Bloom/BloomCommands.cs +++ b/src/NRedisStack/Bloom/BloomCommands.cs @@ -12,7 +12,7 @@ public BloomCommands(IDatabase db) : base(db) } /// - public bool Add(RedisKey key, RedisValue item) + public bool Add (RedisKey key, RedisValue item) { return _db.Execute(BloomCommandBuilder.Add(key, item)).ToString() == "1"; } diff --git a/src/NRedisStack/Search/SearchCommands.cs b/src/NRedisStack/Search/SearchCommands.cs index 30a1e58d..80435e77 100644 --- a/src/NRedisStack/Search/SearchCommands.cs +++ b/src/NRedisStack/Search/SearchCommands.cs @@ -42,7 +42,7 @@ public AggregationResult Aggregate(string index, AggregationRequest query) } /// - public bool AliasAdd(string alias, string index) + public bool AliasAdd (string alias, string index) { return _db.Execute(SearchCommandBuilder.AliasAdd(alias, index)).OKtoBoolean(); } diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 70294443..a28f0ce6 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -760,7 +760,7 @@ public async Task MSetAsync() }; await commands.MSetAsync(values) ; - var result = await commands.MGetAsync(keys.Select(x => new RedisKey(x)).ToArray(), "$.a"); + var result = await commands.MGetAsync (keys.Select(x => new RedisKey(x)).ToArray(), "$.a"); Assert.Equal("[\"hello\"]", result[0].ToString()); Assert.Equal("[\"world\"]", result[1].ToString()); From fe9f0dd2f20cc88097df496f1d99dbab2757b357 Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Wed, 27 Sep 2023 11:45:35 +0300 Subject: [PATCH 42/48] linter force and run --- .github/workflows/linter.yaml | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 14d5e28f..51c8cabe 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -12,24 +12,10 @@ jobs: with: ref: ${{ github.head_ref }} - - name: Run dotnet format - id: format - uses: jfversluis/dotnet-format@v1.0.5 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - action: "fix" - only-changed-files: true + - name: lint + run: | + dotnet format - - name: Commit files - if: steps.format.outputs.has-changes == 'true' + - name: fail if files modified run: | - git config --local user.name "github-actions[bot]" - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git commit -a -m 'Automated dotnet-format update - Co-authored-by: ${{ github.event.pull_request.user.login }} <${{ github.event.pull_request.user.id }}+${{ github.event.pull_request.user.login }}@users.noreply.github.com>' - - name: Push changes - if: steps.format.outputs.has-changes == 'true' - uses: ad-m/github-push-action@v0.5.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.head_ref }} + git status|grep modified && exit 1 From 3ebfeadc3923af784639d9199f7ce8e103df1304 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 12:14:39 +0300 Subject: [PATCH 43/48] try to fix yml --- .github/workflows/linter.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 51c8cabe..4d76533d 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -16,6 +16,11 @@ jobs: run: | dotnet format - - name: fail if files modified + - name: Check for modified files run: | - git status|grep modified && exit 1 + if (git status | Select-String -Pattern 'modified') { + Write-Host "Modified files found." + exit 1 + } else { + Write-Host "No modified files found." + } From 1e998b90c03cb1c10fec98e7e3535426c286040b Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 12:45:37 +0300 Subject: [PATCH 44/48] dotnet format --- src/NRedisStack/Bloom/BloomCommands.cs | 2 +- src/NRedisStack/Search/SearchCommands.cs | 2 +- tests/NRedisStack.Tests/Json/JsonTests.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NRedisStack/Bloom/BloomCommands.cs b/src/NRedisStack/Bloom/BloomCommands.cs index 99694540..d4f3acb9 100644 --- a/src/NRedisStack/Bloom/BloomCommands.cs +++ b/src/NRedisStack/Bloom/BloomCommands.cs @@ -12,7 +12,7 @@ public BloomCommands(IDatabase db) : base(db) } /// - public bool Add (RedisKey key, RedisValue item) + public bool Add(RedisKey key, RedisValue item) { return _db.Execute(BloomCommandBuilder.Add(key, item)).ToString() == "1"; } diff --git a/src/NRedisStack/Search/SearchCommands.cs b/src/NRedisStack/Search/SearchCommands.cs index 80435e77..30a1e58d 100644 --- a/src/NRedisStack/Search/SearchCommands.cs +++ b/src/NRedisStack/Search/SearchCommands.cs @@ -42,7 +42,7 @@ public AggregationResult Aggregate(string index, AggregationRequest query) } /// - public bool AliasAdd (string alias, string index) + public bool AliasAdd(string alias, string index) { return _db.Execute(SearchCommandBuilder.AliasAdd(alias, index)).OKtoBoolean(); } diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index a28f0ce6..70294443 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -760,7 +760,7 @@ public async Task MSetAsync() }; await commands.MSetAsync(values) ; - var result = await commands.MGetAsync (keys.Select(x => new RedisKey(x)).ToArray(), "$.a"); + var result = await commands.MGetAsync(keys.Select(x => new RedisKey(x)).ToArray(), "$.a"); Assert.Equal("[\"hello\"]", result[0].ToString()); Assert.Equal("[\"world\"]", result[1].ToString()); From 70b56243b36d7683ec1ee02d517cee321186e2a0 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 13:09:18 +0300 Subject: [PATCH 45/48] tell the contributer to run dotnet format in the CONTRIBUTING.md --- .github/workflows/linter.yaml | 2 +- CONTRIBUTING.md | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 4d76533d..415e671e 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -19,7 +19,7 @@ jobs: - name: Check for modified files run: | if (git status | Select-String -Pattern 'modified') { - Write-Host "Modified files found." + Write-Host "Modified files found. Please run dotnet format and commit the changes." exit 1 } else { Write-Host "No modified files found." diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9eaade76..bb55086f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,9 +35,10 @@ Here's how to get started with your code contribution: 3. Write your tests 4. Use the `docker run -p 6379:6379 -it redis/redis-stack-server:edge` as your local environment for running the functional tests. You can also use Development Container as described below. -5. Make sure your tests pass using `dotnet test` -6. Push your changes to GitHub -7. Open a pull request +5. run `dotnet format` to make sure your code is formatted correctly +6. Make sure your tests pass using `dotnet test` +7. Push your changes to GitHub +8. Open a pull request ## Development Container From 9990e598b05b2d97276782dc551dfb172b805f92 Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Wed, 27 Sep 2023 13:47:16 +0300 Subject: [PATCH 46/48] disable multi runs --- .github/workflows/linter.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 415e671e..3ef14d77 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -1,5 +1,11 @@ name: Format check on pull request + on: pull_request + +concurrency: + group: ${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: dotnet-format: runs-on: windows-latest From 41ce42b5f0805535b90a6d6c342f4400c9160722 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 14:42:11 +0300 Subject: [PATCH 47/48] fix warnings --- tests/NRedisStack.Tests/TransactionsTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index c96240c4..a3e8aa05 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -30,7 +30,7 @@ public void TestJsonTransaction() [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] [Obsolete] - public async Task TestModulsTransaction() + public void TestModulsTransaction() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); @@ -82,7 +82,7 @@ public async Task TestModulsTransaction() [SkipIfRedis(Is.OSSCluster)] [Obsolete] - public async Task TestModulsTransactionWithoutGraph() + public void TestModulsTransactionWithoutGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); From 60510b94d19d9cec491824bc25f15e604507b2ae Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 14:48:56 +0300 Subject: [PATCH 48/48] chayom changes --- CONTRIBUTING.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bb55086f..7c5e007b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,10 +35,9 @@ Here's how to get started with your code contribution: 3. Write your tests 4. Use the `docker run -p 6379:6379 -it redis/redis-stack-server:edge` as your local environment for running the functional tests. You can also use Development Container as described below. -5. run `dotnet format` to make sure your code is formatted correctly +5. Run dotnet format to make sure your code is formatted 6. Make sure your tests pass using `dotnet test` -7. Push your changes to GitHub -8. Open a pull request +7. Open a pull request ## Development Container