From 92395181c38741a03f162d5d30a834e235bd4d2d Mon Sep 17 00:00:00 2001 From: Tomas Pelak Date: Wed, 22 Jan 2025 03:36:07 +0100 Subject: [PATCH] fix tests --- hosting/Windows/Garnet.worker/Worker.cs | 2 +- libs/host/GarnetApplication.cs | 92 ++++------ libs/host/GarnetApplicationBuilder.cs | 6 +- libs/host/GarnetServer.cs | 169 +++++++----------- libs/server/StoreWrapper.cs | 2 +- main/GarnetServer/Program.cs | 9 +- .../Garnet.test.cluster/ClusterTestContext.cs | 5 +- test/Garnet.test/CacheSizeTrackerTests.cs | 18 +- test/Garnet.test/GarnetBitmapTests.cs | 36 ++-- test/Garnet.test/GarnetClientTests.cs | 22 +-- .../GarnetJSON/JsonCommandsTest.cs | 28 +-- test/Garnet.test/HyperLogLogTests.cs | 30 ++-- test/Garnet.test/IndexGrowthTests.cs | 28 +-- test/Garnet.test/LuaScriptTests.cs | 7 +- test/Garnet.test/ObjectTestsForOutput.cs | 7 +- test/Garnet.test/ReadCacheTests.cs | 8 +- .../Resp/ACL/AclConfigurationFileTests.cs | 16 +- test/Garnet.test/Resp/ACL/AclTest.cs | 3 +- test/Garnet.test/Resp/ACL/BasicTests.cs | 4 +- test/Garnet.test/Resp/ACL/DeleteUserTests.cs | 4 +- test/Garnet.test/Resp/ACL/ParallelTests.cs | 4 +- test/Garnet.test/Resp/ACL/RespCommandTests.cs | 11 +- test/Garnet.test/Resp/ACL/SetUserTests.cs | 36 ++-- .../Resp/GarnetAuthenticatorTests.cs | 5 +- test/Garnet.test/RespAdminCommandsTests.cs | 67 +++---- test/Garnet.test/RespAofAzureTests.cs | 79 ++++---- test/Garnet.test/RespAofTests.cs | 105 +++++------ test/Garnet.test/RespBlockingListTests.cs | 11 +- test/Garnet.test/RespCommandTests.cs | 12 +- test/Garnet.test/RespCustomCommandTests.cs | 11 +- test/Garnet.test/RespGetLowMemoryTests.cs | 11 +- test/Garnet.test/RespHashTests.cs | 11 +- test/Garnet.test/RespInfoTests.cs | 12 +- test/Garnet.test/RespListGarnetClientTests.cs | 11 +- test/Garnet.test/RespListTests.cs | 11 +- test/Garnet.test/RespLowMemoryTests.cs | 12 +- test/Garnet.test/RespMetricsTest.cs | 12 +- test/Garnet.test/RespModuleTests.cs | 16 +- test/Garnet.test/RespPubSubTests.cs | 12 +- test/Garnet.test/RespScanCommandsTests.cs | 12 +- test/Garnet.test/RespSetTest.cs | 11 +- .../RespSortedSetGarnetClientTests.cs | 11 +- test/Garnet.test/RespSortedSetGeoTests.cs | 12 +- test/Garnet.test/RespSortedSetTests.cs | 11 +- test/Garnet.test/RespTests.cs | 39 ++-- test/Garnet.test/RespTlsTests.cs | 11 +- test/Garnet.test/RespTransactionProcTests.cs | 12 +- test/Garnet.test/TestUtils.cs | 6 +- test/Garnet.test/TransactionTests.cs | 15 +- 49 files changed, 531 insertions(+), 554 deletions(-) diff --git a/hosting/Windows/Garnet.worker/Worker.cs b/hosting/Windows/Garnet.worker/Worker.cs index b6de5ea2ec8..e4e6dd5997e 100644 --- a/hosting/Windows/Garnet.worker/Worker.cs +++ b/hosting/Windows/Garnet.worker/Worker.cs @@ -14,7 +14,7 @@ public class Worker : BackgroundService private bool _isDisposed = false; private readonly string[] args; - private GarnetServer server; + private GarnetApplication server; public Worker(string[] args) { diff --git a/libs/host/GarnetApplication.cs b/libs/host/GarnetApplication.cs index 58efc453c77..a9ea80bf120 100644 --- a/libs/host/GarnetApplication.cs +++ b/libs/host/GarnetApplication.cs @@ -2,15 +2,12 @@ // Licensed under the MIT license. using System; -using System.Diagnostics; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using Garnet.common; using Garnet.server; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace Garnet.host; @@ -20,77 +17,58 @@ namespace Garnet.host; /// public class GarnetApplication : IHost { + /// + /// Metrics API + /// + public MetricsApi Metrics; + + /// + /// Command registration API + /// + public RegisterApi Register; + + /// + /// Store API + /// + public StoreApi Store; + + internal GarnetProvider Provider; + private readonly IHost host; public GarnetApplication(IHost host) { this.host = host; + + Metrics = host.Services.GetRequiredService(); + Register = host.Services.GetService(); + Store = host.Services.GetService(); + + Provider = host.Services.GetRequiredService(); } public IServiceProvider Services => host.Services; public Task StartAsync(CancellationToken cancellationToken = default) - { - var opts = host.Services.GetRequiredService>(); - var logger = host.Services.GetRequiredService>(); - - Debug.Assert(opts != null); - - var version = GetVersion(); - - if (!opts.Value.QuietMode) - { - var red = "\u001b[31m"; - var magenta = "\u001b[35m"; - var normal = "\u001b[0m"; - - Console.WriteLine($@"{red} _________ - /_||___||_\ {normal}Garnet {version} {(IntPtr.Size == 8 ? "64" : "32")} bit; {(opts.Value.EnableCluster ? "cluster" : "standalone")} mode{red} - '. \ / .' {normal}Port: {opts.Value.Port}{red} - '.\ /.' {magenta}https://aka.ms/GetGarnet{red} - '.' - {normal}"); - } - - Trace.Listeners.Add(new ConsoleTraceListener()); - - // Set up an initial memory logger to log messages from configuration parser into memory. - using var memLogProvider = new MemoryLoggerProvider(); - - var initLogger = (MemoryLogger)memLogProvider.CreateLogger("ArgParser"); - - logger?.LogInformation("Garnet {version} {bits} bit; {clusterMode} mode; Port: {port}", GetVersion(), IntPtr.Size == 8 ? "64" : "32", opts.Value.EnableCluster ? "cluster" : "standalone", opts.Value.Port); - - // Flush initialization logs from memory logger - initLogger.FlushLogger(logger); - - var setMax = opts.Value.ThreadPoolMaxThreads <= 0 || ThreadPool.SetMaxThreads(opts.Value.ThreadPoolMaxThreads, opts.Value.ThreadPoolMaxThreads); - - if (opts.Value.ThreadPoolMinThreads > 0 && !ThreadPool.SetMinThreads(opts.Value.ThreadPoolMinThreads, opts.Value.ThreadPoolMinThreads)) - throw new Exception($"Unable to call ThreadPool.SetMinThreads with {opts.Value.ThreadPoolMinThreads}"); - - // Retry to set max threads if it wasn't set in the previous step - if (!setMax && !ThreadPool.SetMaxThreads(opts.Value.ThreadPoolMaxThreads, opts.Value.ThreadPoolMaxThreads)) - throw new Exception($"Unable to call ThreadPool.SetMaxThreads with {opts.Value.ThreadPoolMaxThreads}"); - - logger?.LogTrace("TLS is {tlsEnabled}", opts.Value.TlsOptions == null ? "disabled" : "enabled"); - - return host.StartAsync(cancellationToken); - } + => host.StartAsync(cancellationToken); public Task StopAsync(CancellationToken cancellationToken = default) => host.StopAsync(cancellationToken); - - public void Dispose() => host.Dispose(); + + public void Dispose() + { + host.Dispose(); + } public void Run() { HostingAbstractionsHostExtensions.Run(this); } - public async Task RunAsync(CancellationToken cancellationToken = default) + public Task RunAsync(CancellationToken cancellationToken = default) { - await HostingAbstractionsHostExtensions.RunAsync(this, cancellationToken); + HostingAbstractionsHostExtensions.RunAsync(this, cancellationToken); + return Task.CompletedTask; } public static GarnetApplicationBuilder CreateHostBuilder(string[] args) @@ -125,10 +103,4 @@ public static GarnetApplicationBuilder CreateHostBuilder(string[] args, GarnetSe { return new (new GarnetApplicationOptions {Args = args}, options); } - - private static string GetVersion() - { - var Version = Assembly.GetExecutingAssembly().GetName().Version; - return $"{Version.Major}.{Version.Minor}.{Version.Build}"; - } } \ No newline at end of file diff --git a/libs/host/GarnetApplicationBuilder.cs b/libs/host/GarnetApplicationBuilder.cs index 3f7c0a68199..45c0f3e941f 100644 --- a/libs/host/GarnetApplicationBuilder.cs +++ b/libs/host/GarnetApplicationBuilder.cs @@ -57,6 +57,8 @@ internal GarnetApplicationBuilder(GarnetApplicationOptions options, GarnetServer hostApplicationBuilder.Services.AddSingleton(garnetServerOptionsWrapped); hostApplicationBuilder.Services.AddSingleton(); + hostApplicationBuilder.Services.AddHostedService(); + hostApplicationBuilder.Services.AddSingleton(); hostApplicationBuilder.Services.AddSingleton(); @@ -73,7 +75,7 @@ internal GarnetApplicationBuilder(GarnetApplicationOptions options, GarnetServer var store = storeFactory.CreateMainStore(out var checkpointDir); var objectStore = storeFactory.CreateObjectStore(checkpointDir, out var objectStoreSizeTracker); - + TsavoriteLog appendOnlyFile = null; if (opts.Value.EnableAOF) @@ -134,8 +136,6 @@ internal GarnetApplicationBuilder(GarnetApplicationOptions options, GarnetServer hostApplicationBuilder.Services.AddSingleton(); hostApplicationBuilder.Services.AddSingleton(); hostApplicationBuilder.Services.AddSingleton(); - - hostApplicationBuilder.Services.AddHostedService(); } public GarnetApplication Build() diff --git a/libs/host/GarnetServer.cs b/libs/host/GarnetServer.cs index c471691e510..d21b152759b 100644 --- a/libs/host/GarnetServer.cs +++ b/libs/host/GarnetServer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -6,140 +6,97 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; -using Garnet.common; using Garnet.networking; using Garnet.server; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Tsavorite.core; -namespace Garnet; +namespace Garnet.host; -/// -/// Implementation Garnet server -/// -public class GarnetServer : IHostedService, IDisposable +public class GarnetServer : IHostedService { - internal GarnetProvider Provider; - - private readonly GarnetServerOptions opts; - private IGarnetServer server; - private SubscribeBroker> subscribeBroker; + private readonly IGarnetServer garnetServerTcp; + private readonly GarnetProvider garnetProvider; + private readonly StoreWrapper store; + private readonly IOptions opts; private readonly ILogger logger; - - /// - /// Store and associated information used by this Garnet server - /// - protected StoreWrapper storeWrapper; - - /// - /// Metrics API - /// - public MetricsApi Metrics; - - /// - /// Command registration API - /// - public RegisterApi Register; - - /// - /// Store API - /// - public StoreApi Store; - + public GarnetServer( - IOptions opts, - ILogger logger, - IGarnetServer garnetServerTcp, - StoreWrapper storeWrapper) + IGarnetServer garnetServerTcp, + GarnetProvider garnetProvider, + StoreWrapper store, + IOptions options, + ILogger logger) { + this.garnetServerTcp = garnetServerTcp; + this.garnetProvider = garnetProvider; + this.store = store; + this.opts = options; this.logger = logger; - this.server = garnetServerTcp; - this.storeWrapper = storeWrapper; - Trace.Listeners.Add(new ConsoleTraceListener()); - - // Assign values to GarnetServerOptions - this.opts = opts.Value; - this.opts.AuthSettings = this.opts.AuthSettings; + garnetServerTcp.Register(WireFormat.ASCII, garnetProvider); - this.InitializeServer(); } - private void InitializeServer() - { - // Create session provider for Garnet - Provider = new GarnetProvider(storeWrapper, subscribeBroker); + public Task StartAsync(CancellationToken cancellationToken) + { + var version = GetVersion(); + + if (!opts.Value.QuietMode) + { + var red = "\u001b[31m"; + var magenta = "\u001b[35m"; + var normal = "\u001b[0m"; + + Console.WriteLine($@"{red} _________ + /_||___||_\ {normal}Garnet {version} {(IntPtr.Size == 8 ? "64" : "32")} bit; {(opts.Value.EnableCluster ? "cluster" : "standalone")} mode{red} + '. \ / .' {normal}Port: {opts.Value.Port}{red} + '.\ /.' {magenta}https://aka.ms/GetGarnet{red} + '.' + {normal}"); + } + + Trace.Listeners.Add(new ConsoleTraceListener()); - // Create user facing API endpoints - Metrics = new MetricsApi(Provider); - Register = new RegisterApi(Provider); - Store = new StoreApi(storeWrapper); + // Set up an initial memory logger to log messages from configuration parser into memory. + using var memLogProvider = new MemoryLoggerProvider(); + + var initLogger = (MemoryLogger)memLogProvider.CreateLogger("ArgParser"); + + logger?.LogInformation("Garnet {version} {bits} bit; {clusterMode} mode; Port: {port}", GetVersion(), IntPtr.Size == 8 ? "64" : "32", opts.Value.EnableCluster ? "cluster" : "standalone", opts.Value.Port); - server.Register(WireFormat.ASCII, Provider); - } + // Flush initialization logs from memory logger + initLogger.FlushLogger(logger); - /// - /// Start server instance - /// - public void Start() - { - Provider.Recover(); - server.Start(); - Provider.Start(); - if (!opts.QuietMode) - this.logger.LogInformation("* Ready to accept connections"); - } + var setMax = opts.Value.ThreadPoolMaxThreads <= 0 || ThreadPool.SetMaxThreads(opts.Value.ThreadPoolMaxThreads, opts.Value.ThreadPoolMaxThreads); - /// - /// Dispose store (including log and checkpoint directory) - /// - public void Dispose() - { - Dispose(false); - } + if (opts.Value.ThreadPoolMinThreads > 0 && !ThreadPool.SetMinThreads(opts.Value.ThreadPoolMinThreads, opts.Value.ThreadPoolMinThreads)) + throw new Exception($"Unable to call ThreadPool.SetMinThreads with {opts.Value.ThreadPoolMinThreads}"); - /// - /// Dispose, optionally deleting logs and checkpoints - /// - /// Whether to delete logs and checkpoints - public void Dispose(bool deleteDir = true) - { - InternalDispose(); - if (deleteDir) - { - if (opts.CheckpointDir != opts.LogDir && !string.IsNullOrEmpty(opts.CheckpointDir)) - { - var ckptdir = opts.DeviceFactoryCreator(); - ckptdir.Initialize(opts.CheckpointDir); - ckptdir.Delete(new FileDescriptor { directoryName = "" }); - } - } - } + // Retry to set max threads if it wasn't set in the previous step + if (!setMax && !ThreadPool.SetMaxThreads(opts.Value.ThreadPoolMaxThreads, opts.Value.ThreadPoolMaxThreads)) + throw new Exception($"Unable to call ThreadPool.SetMaxThreads with {opts.Value.ThreadPoolMaxThreads}"); - private void InternalDispose() - { - // Provider.Dispose will get stuck - //Provider?.Dispose(); + logger?.LogTrace("TLS is {tlsEnabled}", opts.Value.TlsOptions == null ? "disabled" : "enabled"); + + garnetProvider.Recover(); + garnetServerTcp.Start(); + garnetProvider.Start(); + + if (!opts.Value.QuietMode) + logger?.LogInformation("* Ready to accept connections"); - server.Dispose(); - subscribeBroker?.Dispose(); - opts.AuthSettings?.Dispose(); - } - - public Task StartAsync(CancellationToken cancellationToken) - { - Start(); - return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) { - Dispose(); + garnetProvider?.Dispose(); + garnetServerTcp?.Dispose(); + //store?.Dispose(); - return Task.CompletedTask; + return Task.CompletedTask; } private static string GetVersion() diff --git a/libs/server/StoreWrapper.cs b/libs/server/StoreWrapper.cs index c6856f92f9e..724770bbae8 100644 --- a/libs/server/StoreWrapper.cs +++ b/libs/server/StoreWrapper.cs @@ -26,7 +26,7 @@ namespace Garnet.server /// /// Wrapper for store and store-specific information /// - public sealed class StoreWrapper + public sealed class StoreWrapper { internal readonly string version; internal readonly string redisProtocolVersion; diff --git a/main/GarnetServer/Program.cs b/main/GarnetServer/Program.cs index e232e678574..8ded59d120b 100644 --- a/main/GarnetServer/Program.cs +++ b/main/GarnetServer/Program.cs @@ -1,20 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -using System.Linq; using Garnet; using Garnet.host; using Garnet.server; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; var builder = GarnetApplication.CreateHostBuilder(args); var app = builder.Build(); -var hostedServices = app.Services.GetServices(); -var server = hostedServices.OfType().FirstOrDefault(); -RegisterExtensions(server); +RegisterExtensions(app); app.Run(); @@ -23,7 +18,7 @@ /// commands such as db.Execute in StackExchange.Redis. Example: /// db.Execute("SETIFPM", key, value, prefix); /// -static void RegisterExtensions(GarnetServer server) +static void RegisterExtensions(GarnetApplication server) { // Register custom command on raw strings (SETIFPM = "set if prefix match") // Add RESP command info to registration for command to appear when client runs COMMAND / COMMAND INFO diff --git a/test/Garnet.test.cluster/ClusterTestContext.cs b/test/Garnet.test.cluster/ClusterTestContext.cs index f14466a1450..36a774a47b2 100644 --- a/test/Garnet.test.cluster/ClusterTestContext.cs +++ b/test/Garnet.test.cluster/ClusterTestContext.cs @@ -79,10 +79,7 @@ public void RegisterCustomTxn(string name, Func proc { foreach (var node in nodes) { - var hostedServices = node.Services.GetServices(); - var server = hostedServices.OfType().FirstOrDefault(); - - server.Register.NewTransactionProc(name, proc, commandInfo, commandDocs); + node.Register.NewTransactionProc(name, proc, commandInfo, commandDocs); } } diff --git a/test/Garnet.test/CacheSizeTrackerTests.cs b/test/Garnet.test/CacheSizeTrackerTests.cs index 41dfabddf55..020c1390645 100644 --- a/test/Garnet.test/CacheSizeTrackerTests.cs +++ b/test/Garnet.test/CacheSizeTrackerTests.cs @@ -3,6 +3,8 @@ using System; using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -17,24 +19,24 @@ namespace Garnet.test [TestFixture] public class CacheSizeTrackerTests { - GarnetServer server; + GarnetApplication server; TsavoriteKV objStore; CacheSizeTracker cacheSizeTracker; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, MemorySize: "2k", PageSize: "512", lowMemory: true, objectStoreIndexSize: "1k", objectStoreHeapMemorySize: "5k"); - server.Start(); + await server.RunAsync(); objStore = server.Provider.StoreWrapper.objectStore; cacheSizeTracker = server.Provider.StoreWrapper.objectStoreSizeTracker; } [TearDown] - public void TearDown() + public async Task TearDown() { - server?.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } @@ -90,11 +92,11 @@ public void IncreaseEmptyPageCountTest() } [Test] - public void ReadCacheIncreaseEmptyPageCountTest() + public async Task ReadCacheIncreaseEmptyPageCountTest() { - server?.Dispose(); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, MemorySize: "1k", PageSize: "512", lowMemory: true, objectStoreIndexSize: "1k", objectStoreReadCacheHeapMemorySize: "1k", enableObjectStoreReadCache: true); - server.Start(); + await server.RunAsync(); objStore = server.Provider.StoreWrapper.objectStore; cacheSizeTracker = server.Provider.StoreWrapper.objectStoreSizeTracker; diff --git a/test/Garnet.test/GarnetBitmapTests.cs b/test/Garnet.test/GarnetBitmapTests.cs index c1281a26d48..87f7a949217 100644 --- a/test/Garnet.test/GarnetBitmapTests.cs +++ b/test/Garnet.test/GarnetBitmapTests.cs @@ -3,7 +3,9 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Garnet.common; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -13,22 +15,22 @@ namespace Garnet.test { public class GarnetBitmapTests { - GarnetServer server; + GarnetApplication server; Random r; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); r = new Random(674386); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } @@ -162,7 +164,7 @@ public void BitmapSimpleSetGet_PCT(int bytesPerSend) [TestCase(false)] [TestCase(true)] [Category("SET+GET+BIT")] - public void BitmapSetGetBitTest_LTM(bool preSet) + public async Task BitmapSetGetBitTest_LTM(bool preSet) { int bitmapBytes = 512; server.Dispose(); @@ -170,7 +172,7 @@ public void BitmapSetGetBitTest_LTM(bool preSet) lowMemory: true, MemorySize: (bitmapBytes << 2).ToString(), PageSize: (bitmapBytes << 1).ToString()); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -444,7 +446,7 @@ public void BitmapBitCountNegativeOffsets() [Test, Order(10)] [Category("BITCOUNT")] - public void BitmapBitCountTest_LTM() + public async Task BitmapBitCountTest_LTM() { int bitmapBytes = 512; server.Dispose(); @@ -452,7 +454,7 @@ public void BitmapBitCountTest_LTM() lowMemory: true, MemorySize: (bitmapBytes << 2).ToString(), PageSize: (bitmapBytes << 1).ToString()); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -641,7 +643,7 @@ public void BitmapBitPosOffsetsTest() [Test, Order(14)] [Category("BITPOS")] - public void BitmapBitPosTest_LTM() + public async Task BitmapBitPosTest_LTM() { int bitmapBytes = 512; server.Dispose(); @@ -649,7 +651,7 @@ public void BitmapBitPosTest_LTM() lowMemory: true, MemorySize: (bitmapBytes << 2).ToString(), PageSize: (bitmapBytes << 1).ToString()); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -1264,7 +1266,7 @@ public unsafe void BitmapBitfieldGetTest_PCT([Values(RespCommand.BITFIELD, RespC [Test, Order(23)] [Category("BITFIELD")] - public void BitmapBitfieldGetTest_LTM([Values(RespCommand.BITFIELD, RespCommand.BITFIELD_RO)] RespCommand testCmd) + public async Task BitmapBitfieldGetTest_LTM([Values(RespCommand.BITFIELD, RespCommand.BITFIELD_RO)] RespCommand testCmd) { int bitmapBytes = 512; server.Dispose(); @@ -1274,7 +1276,7 @@ public void BitmapBitfieldGetTest_LTM([Values(RespCommand.BITFIELD, RespCommand. PageSize: (bitmapBytes << 1).ToString()); //MemorySize: "16g", //PageSize: "32m"); - server.Start(); + await server.StopAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -1465,7 +1467,7 @@ public void BitmapBitfieldSetTest() [Test, Order(26)] [Category("BITFIELD")] - public void BitmapBitfieldSetTest_LTM() + public async Task BitmapBitfieldSetTest_LTM() { int bitmapBytes = 512; server.Dispose(); @@ -1475,7 +1477,7 @@ public void BitmapBitfieldSetTest_LTM() PageSize: (bitmapBytes << 1).ToString()); //MemorySize: "16g", //PageSize: "32m"); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -1931,7 +1933,7 @@ public void BitmapBitfieldSignedIncrTest() [Test, Order(29)] [Category("BITFIELD")] - public void BitmapBitfieldIncrTest_LTM() + public async Task BitmapBitfieldIncrTest_LTM() { int bitmapBytes = 512; server.Dispose(); @@ -1941,7 +1943,7 @@ public void BitmapBitfieldIncrTest_LTM() PageSize: (bitmapBytes << 1).ToString()); //MemorySize: "16g", //PageSize: "32m"); - server.Start(); + await server.StopAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); diff --git a/test/Garnet.test/GarnetClientTests.cs b/test/Garnet.test/GarnetClientTests.cs index 56498b2fccb..c129853839c 100644 --- a/test/Garnet.test/GarnetClientTests.cs +++ b/test/Garnet.test/GarnetClientTests.cs @@ -117,10 +117,10 @@ static void WaitAndReset(ManualResetEventSlim e) } [Test] - public void SetGetWithCallback([Values] bool useTLS) + public async Task SetGetWithCallback([Values] bool useTLS) { using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, EnableTLS: useTLS); - server.Start(); + await server.RunAsync(); using var db = TestUtils.GetGarnetClient(useTLS); db.Connect(); @@ -145,10 +145,10 @@ public void SetGetWithCallback([Values] bool useTLS) } [Test] - public void SimpleMetricsTest([Values] bool recordLatency) + public async Task SimpleMetricsTest([Values] bool recordLatency) { using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); var db = TestUtils.GetGarnetClient(recordLatency: recordLatency); db.Connect(); @@ -180,7 +180,7 @@ public void SimpleMetricsTest([Values] bool recordLatency) public async Task SimpleStringArrayTest([Values] bool stringParams) { using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); var db = TestUtils.GetGarnetClient(); db.Connect(); @@ -196,7 +196,7 @@ public async Task SimpleStringArrayTest([Values] bool stringParams) public async Task SimpleNoArgsTest() { using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); var db = TestUtils.GetGarnetClient(); db.Connect(); @@ -213,7 +213,7 @@ public async Task SimpleIncrTest([Values] bool stringParams) { ManualResetEventSlim e = new(); using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); var key = "mykey"; var db = TestUtils.GetGarnetClient(); @@ -275,7 +275,7 @@ public async Task SimpleDecrTest([Values] bool stringParams) { ManualResetEventSlim e = new(); using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); var key = "mykey"; var db = TestUtils.GetGarnetClient(); @@ -336,7 +336,7 @@ public async Task SimpleDecrTest([Values] bool stringParams) public async Task CanUseSetNxStringResultAsync() { using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); var db = TestUtils.GetGarnetClient(); db.Connect(); @@ -355,7 +355,7 @@ public async Task CanUseSetNxStringResultAsync() public async Task CanUseMGetTests([Values] bool disableObjectStore) { using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: disableObjectStore); - server.Start(); + await server.RunAsync(); var db = TestUtils.GetGarnetClient(); db.Connect(); @@ -462,7 +462,7 @@ public async Task CanDoBulkDeleteTests([Values] bool useStringType) { //KeyDeleteAsync using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); var db = TestUtils.GetGarnetClient(); db.Connect(); diff --git a/test/Garnet.test/GarnetJSON/JsonCommandsTest.cs b/test/Garnet.test/GarnetJSON/JsonCommandsTest.cs index 7ed66c9d366..243934c140f 100644 --- a/test/Garnet.test/GarnetJSON/JsonCommandsTest.cs +++ b/test/Garnet.test/GarnetJSON/JsonCommandsTest.cs @@ -5,6 +5,8 @@ using System.IO; using System.Reflection; using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using GarnetJSON; using NUnit.Framework; @@ -16,22 +18,22 @@ namespace Garnet.test [TestFixture] class JsonCommandsTest { - GarnetServer server; + GarnetApplication server; string binPath; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); binPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, extensionAllowUnsignedAssemblies: true, extensionBinPaths: [binPath]); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } @@ -84,7 +86,7 @@ public void JsonSetGetTests() } [Test] - public void SaveRecoverTest() + public async Task SaveRecoverTest() { string key = "key"; RegisterCustomCommand(); @@ -102,10 +104,10 @@ public void SaveRecoverTest() while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true); RegisterCustomCommand(); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -116,12 +118,12 @@ public void SaveRecoverTest() } [Test] - public void AofUpsertRecoverTest() + public async Task AofUpsertRecoverTest() { - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableAOF: true); RegisterCustomCommand(); - server.Start(); + await server.RunAsync(); var key = "aofkey"; using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) @@ -133,10 +135,10 @@ public void AofUpsertRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); RegisterCustomCommand(); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { diff --git a/test/Garnet.test/HyperLogLogTests.cs b/test/Garnet.test/HyperLogLogTests.cs index 646cfd86d40..1d88ef859b6 100644 --- a/test/Garnet.test/HyperLogLogTests.cs +++ b/test/Garnet.test/HyperLogLogTests.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -12,17 +14,17 @@ namespace Garnet.test { - public unsafe class HyperLogLogTests + public class HyperLogLogTests { - GarnetServer server; + GarnetApplication server; Random r; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); r = new Random(674386); } @@ -329,7 +331,7 @@ private static unsafe ulong MurmurHash2x64A(byte* bString, int len, uint seed = [Test] [Repeat(1)] - public void HyperLogLogUpdateReturnTest() + public unsafe void HyperLogLogUpdateReturnTest() { using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -387,7 +389,7 @@ private void RandomString(ref byte[] valuebuffer) [Test] [Repeat(1)] - public void HyperLogLogMultiValueUpdateReturnTest() + public unsafe void HyperLogLogMultiValueUpdateReturnTest() { using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -573,7 +575,7 @@ public void HyperLogLogTestPFADDV2() [TestCase(32)] [TestCase(4096)] [Repeat(1)] - public void HyperLogLogPFADD_LTM(int seqSize) + public async Task HyperLogLogPFADD_LTM(int seqSize) { bool sparse = seqSize < 128 ? true : false; server.Dispose(); @@ -587,7 +589,7 @@ public void HyperLogLogPFADD_LTM(int seqSize) lowMemory: true, MemorySize: "32k", PageSize: "16k"); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -693,14 +695,14 @@ public void HyperLogLogTestPFMERGE_SparseToSparseV2() [Test] [Repeat(10)] - public void HyperLogLogTestPFMERGE_LTM_SparseToSparse() + public async Task HyperLogLogTestPFMERGE_LTM_SparseToSparse() { server.Dispose(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, MemorySize: "1024", PageSize: "512"); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -803,13 +805,13 @@ public void HyperLogLogTestPFMERGE_SparseToDenseV2() [TestCase(false)] [TestCase(true)] [Repeat(1)] - public void HyperLogLogTestPFMERGE_LTM_SparseToDense(bool reverse) + public async Task HyperLogLogTestPFMERGE_LTM_SparseToDense(bool reverse) { server.Dispose(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, MemorySize: "32k", PageSize: "16k"); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -912,14 +914,14 @@ public void HyperLogLogTestPFMERGE_DenseToDenseV2() [Test] [Repeat(1)] - public void HyperLogLogTestPFMERGE_LTM_DenseToDense() + public async Task HyperLogLogTestPFMERGE_LTM_DenseToDense() { server.Dispose(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, MemorySize: "32k", PageSize: "16k"); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); diff --git a/test/Garnet.test/IndexGrowthTests.cs b/test/Garnet.test/IndexGrowthTests.cs index c08d2f90cbe..25e13fc8f48 100644 --- a/test/Garnet.test/IndexGrowthTests.cs +++ b/test/Garnet.test/IndexGrowthTests.cs @@ -3,6 +3,8 @@ using System; using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -12,7 +14,7 @@ namespace Garnet.test [TestFixture] public class IndexGrowthTests { - GarnetServer server; + GarnetApplication server; private int indexResizeTaskDelaySeconds = 10; private int indexResizeWaitCycles = 2; @@ -30,10 +32,10 @@ public void TearDown() } [Test] - public void IndexGrowthTest() + public async Task IndexGrowthTest() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, indexSize: "64", indexMaxSize: "128", indexResizeFrequencySecs: indexResizeTaskDelaySeconds); - server.Start(); + await server.RunAsync(); var store = server.Provider.StoreWrapper.store; @@ -68,10 +70,10 @@ public void IndexGrowthTest() } [Test] - public void ObjectStoreIndexGrowthTest() + public async Task ObjectStoreIndexGrowthTest() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, objectStoreIndexSize: "64", objectStoreIndexMaxSize: "128", indexResizeFrequencySecs: indexResizeTaskDelaySeconds); - server.Start(); + await server.RunAsync(); var objectStore = server.Provider.StoreWrapper.objectStore; @@ -115,10 +117,10 @@ private static void VerifyObjectStoreSetMembers(IDatabase db, RedisKey[] keys, R } [Test] - public void IndexGrowthTestWithDiskReadAndCheckpoint() + public async Task IndexGrowthTestWithDiskReadAndCheckpoint() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, indexSize: "512", indexMaxSize: "1k", indexResizeFrequencySecs: indexResizeTaskDelaySeconds); - server.Start(); + await server.RunAsync(); var store = server.Provider.StoreWrapper.store; @@ -166,9 +168,9 @@ public void IndexGrowthTestWithDiskReadAndCheckpoint() while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, lowMemory: true, indexSize: "512", indexMaxSize: "1k"); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -179,10 +181,10 @@ public void IndexGrowthTestWithDiskReadAndCheckpoint() } [Test] - public void ObjectStoreIndexGrowthTestWithDiskReadAndCheckpoint() + public async Task ObjectStoreIndexGrowthTestWithDiskReadAndCheckpoint() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, objectStoreIndexSize: "512", objectStoreIndexMaxSize: "1k", indexResizeFrequencySecs: indexResizeTaskDelaySeconds); - server.Start(); + await server.RunAsync(); var objectStore = server.Provider.StoreWrapper.objectStore; @@ -230,9 +232,9 @@ public void ObjectStoreIndexGrowthTestWithDiskReadAndCheckpoint() while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, lowMemory: true, objectStoreIndexSize: "512", objectStoreIndexMaxSize: "1k"); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { diff --git a/test/Garnet.test/LuaScriptTests.cs b/test/Garnet.test/LuaScriptTests.cs index ace05933400..bf018be0db8 100644 --- a/test/Garnet.test/LuaScriptTests.cs +++ b/test/Garnet.test/LuaScriptTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -14,14 +15,14 @@ namespace Garnet.test [TestFixture] public class LuaScriptTests { - protected GarnetServer server; + protected GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableLua: true); - server.Start(); + await server.RunAsync(); } [TearDown] diff --git a/test/Garnet.test/ObjectTestsForOutput.cs b/test/Garnet.test/ObjectTestsForOutput.cs index bcaf7b256a1..e245ac65af6 100644 --- a/test/Garnet.test/ObjectTestsForOutput.cs +++ b/test/Garnet.test/ObjectTestsForOutput.cs @@ -3,6 +3,7 @@ using System.Text; using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -11,14 +12,14 @@ namespace Garnet.test [TestFixture] public class ObjectTestsForOutput { - protected GarnetServer server; + protected GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: false); - server.Start(); + await server.RunAsync(); } diff --git a/test/Garnet.test/ReadCacheTests.cs b/test/Garnet.test/ReadCacheTests.cs index 80aa9684847..795540fa9b2 100644 --- a/test/Garnet.test/ReadCacheTests.cs +++ b/test/Garnet.test/ReadCacheTests.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -10,14 +12,14 @@ namespace Garnet.test [TestFixture] public class ReadCacheTests { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableReadCache: true, enableObjectStoreReadCache: true, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] diff --git a/test/Garnet.test/Resp/ACL/AclConfigurationFileTests.cs b/test/Garnet.test/Resp/ACL/AclConfigurationFileTests.cs index bac19583320..0e5d0b103ec 100644 --- a/test/Garnet.test/Resp/ACL/AclConfigurationFileTests.cs +++ b/test/Garnet.test/Resp/ACL/AclConfigurationFileTests.cs @@ -30,7 +30,7 @@ public async Task EmptyInput() // Ensure Garnet starts up with default user only server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, aclFile: configurationFile); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -52,7 +52,7 @@ public async Task NoDefaultRule() // Start up Garnet server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, aclFile: configurationFile); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -78,7 +78,7 @@ public async Task WithDefaultRule() // Start up Garnet with a defined default user password server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, aclFile: configurationFile, defaultPassword: DummyPassword); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -118,7 +118,7 @@ public async Task AclLoad() // Start up Garnet server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, aclFile: configurationFile, defaultPassword: DummyPassword); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -189,7 +189,7 @@ public async Task AclLoadErrors() // Start up Garnet server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, aclFile: configurationFile); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -244,7 +244,7 @@ public async Task DuplicateUserNames() File.WriteAllText(configurationFile, $"user test on >{DummyPassword} +@admin\r\nuser test off"); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, aclFile: configurationFile); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -328,7 +328,7 @@ public void BadInputMalformedStatement() } [Test] - public void AclSave() + public async Task AclSave() { // Create a modified ACL that (1) removes two users, (2) adds one user, (3) removes one password and (4) removes the default user var originalConfigurationFile = @@ -343,7 +343,7 @@ public void AclSave() // Start up Garnet server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, aclFile: configurationFile, defaultPassword: DummyPassword); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); diff --git a/test/Garnet.test/Resp/ACL/AclTest.cs b/test/Garnet.test/Resp/ACL/AclTest.cs index 9f5e614cdab..1063c769204 100644 --- a/test/Garnet.test/Resp/ACL/AclTest.cs +++ b/test/Garnet.test/Resp/ACL/AclTest.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.IO; +using Garnet.host; using NUnit.Framework; namespace Garnet.test.Resp.ACL @@ -44,7 +45,7 @@ abstract class AclTest /// /// Garnet server instance to use in the tests. /// - protected GarnetServer server = null; + protected GarnetApplication server = null; /// /// Creates working directory diff --git a/test/Garnet.test/Resp/ACL/BasicTests.cs b/test/Garnet.test/Resp/ACL/BasicTests.cs index bdbaa63651f..9593a140a1c 100644 --- a/test/Garnet.test/Resp/ACL/BasicTests.cs +++ b/test/Garnet.test/Resp/ACL/BasicTests.cs @@ -19,10 +19,10 @@ internal class BasicTests : AclTest /// Creates and starts the Garnet test server /// [SetUp] - public virtual void Setup() + public virtual async Task Setup() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); } /// diff --git a/test/Garnet.test/Resp/ACL/DeleteUserTests.cs b/test/Garnet.test/Resp/ACL/DeleteUserTests.cs index 69b142d32cd..aeebdd68153 100644 --- a/test/Garnet.test/Resp/ACL/DeleteUserTests.cs +++ b/test/Garnet.test/Resp/ACL/DeleteUserTests.cs @@ -18,10 +18,10 @@ class DeleteUserTests : AclTest /// Creates and starts the Garnet test server /// [SetUp] - public virtual void Setup() + public virtual async Task Setup() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); } /// diff --git a/test/Garnet.test/Resp/ACL/ParallelTests.cs b/test/Garnet.test/Resp/ACL/ParallelTests.cs index 129ff99027e..d7a8354fe39 100644 --- a/test/Garnet.test/Resp/ACL/ParallelTests.cs +++ b/test/Garnet.test/Resp/ACL/ParallelTests.cs @@ -18,10 +18,10 @@ internal class ParallelTests : AclTest /// Creates and starts the Garnet test server /// [SetUp] - public virtual void Setup() + public virtual async Task Setup() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); } /// diff --git a/test/Garnet.test/Resp/ACL/RespCommandTests.cs b/test/Garnet.test/Resp/ACL/RespCommandTests.cs index bf47124bdbc..f8ea8c71789 100644 --- a/test/Garnet.test/Resp/ACL/RespCommandTests.cs +++ b/test/Garnet.test/Resp/ACL/RespCommandTests.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Threading.Tasks; using Garnet.client; +using Garnet.host; using Garnet.server; using Garnet.server.ACL; using NUnit.Framework; @@ -22,11 +23,11 @@ public class RespCommandTests private IReadOnlyDictionary respCustomCommandsInfo; - private GarnetServer server; + private GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, defaultPassword: DefaultPassword, useAcl: true, enableLua: true); @@ -40,13 +41,13 @@ public void Setup() server.Register.NewTransactionProc("READWRITETX", () => new ReadWriteTxn(), new RespCommandsInfo { Arity = 4 }); server.Register.NewProcedure("SUM", () => new Sum()); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/Resp/ACL/SetUserTests.cs b/test/Garnet.test/Resp/ACL/SetUserTests.cs index 669e2335318..519a607c6c0 100644 --- a/test/Garnet.test/Resp/ACL/SetUserTests.cs +++ b/test/Garnet.test/Resp/ACL/SetUserTests.cs @@ -20,11 +20,11 @@ class SetUserTests : AclTest /// Tests that new connections start with default user when no users are defined /// [Test] - public void PasswordlessDefaultUserTest() + public async Task PasswordlessDefaultUserTest() { // Create a new test server without password - should automatically login default user server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); // Check user is authenticated as default using var lightClientRequest = TestUtils.CreateRequest(); @@ -44,7 +44,7 @@ public async Task ProtectedDefaultUserErrorHandlingTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, defaultPassword: DummyPassword); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -69,7 +69,7 @@ public async Task ProtectedDefaultUserLoginImplicitTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, defaultPassword: DummyPassword); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -91,7 +91,7 @@ public async Task ProtectedDefaultUserLoginExplicitTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true, defaultPassword: DummyPassword); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -114,7 +114,7 @@ public async Task EnableAndDisableUsers() { // Create a new test server without default password server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -169,7 +169,7 @@ public async Task AddPasswordFromCleartextTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -199,7 +199,7 @@ public async Task AddPasswordFromHashTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -229,7 +229,7 @@ public async Task RemovePasswordFromCleartextTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -261,7 +261,7 @@ public async Task RemovePasswordFromHashTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -293,7 +293,7 @@ public async Task AddDuplicatePasswordTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -326,7 +326,7 @@ public async Task PasswordlessUserTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -349,7 +349,7 @@ public async Task ResetPasswordsTest() { // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -393,7 +393,7 @@ public async Task AddAndRemoveCategoryTest() // Create a new test server with password - should disallow any operation server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -449,7 +449,7 @@ public async Task ResetUser() { // Create a new test server server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -494,7 +494,7 @@ public async Task BadInputEmpty() { // Create a new test server server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -519,7 +519,7 @@ public async Task BadInputUnknownOperation() { // Create a new test server server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); @@ -544,7 +544,7 @@ public async Task KeyPatternsWildcard() { // Create a new test server server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, useAcl: true); - server.Start(); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); diff --git a/test/Garnet.test/Resp/GarnetAuthenticatorTests.cs b/test/Garnet.test/Resp/GarnetAuthenticatorTests.cs index af92c5dd471..23fb94b80c4 100644 --- a/test/Garnet.test/Resp/GarnetAuthenticatorTests.cs +++ b/test/Garnet.test/Resp/GarnetAuthenticatorTests.cs @@ -4,6 +4,7 @@ using System; using System.Text; using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using Garnet.server.Auth; using Garnet.server.Auth.Settings; @@ -77,8 +78,8 @@ public async Task InvalidatingAuthorizationAsync() return true; }; - using GarnetServer server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, authenticationSettings: authSettings); - server.Start(); + using var server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, authenticationSettings: authSettings); + await server.RunAsync(); using var c = TestUtils.GetGarnetClientSession(); c.Connect(); diff --git a/test/Garnet.test/RespAdminCommandsTests.cs b/test/Garnet.test/RespAdminCommandsTests.cs index 7bf4f07f069..eccfdcbabe6 100644 --- a/test/Garnet.test/RespAdminCommandsTests.cs +++ b/test/Garnet.test/RespAdminCommandsTests.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -17,20 +18,22 @@ namespace Garnet.test [TestFixture] public class RespAdminCommandsTests { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); + TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } @@ -157,13 +160,13 @@ public void SeSaveTest() } [Test] - public void SeSaveRecoverTest([Values] bool disableObj, [Values] bool useAzure) + public async Task SeSaveRecoverTest([Values] bool disableObj, [Values] bool useAzure) { if (useAzure) TestUtils.IgnoreIfNotRunningAzureTests(); - server.Dispose(); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: disableObj, UseAzureStorage: useAzure); - server.Start(); + _ = server.StartAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -176,9 +179,9 @@ public void SeSaveRecoverTest([Values] bool disableObj, [Values] bool useAzure) while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, UseAzureStorage: useAzure); - server.Start(); + _ = server.StartAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -189,7 +192,7 @@ public void SeSaveRecoverTest([Values] bool disableObj, [Values] bool useAzure) } [Test] - public void SeSaveRecoverObjectTest() + public async Task SeSaveRecoverObjectTest() { var key = "SeSaveRecoverTestObjectKey"; var ldata = new RedisValue[] { "a", "b", "c", "d" }; @@ -208,9 +211,9 @@ public void SeSaveRecoverObjectTest() while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true); - server.Start(); + _ = server.StartAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -223,7 +226,7 @@ public void SeSaveRecoverObjectTest() } [Test] - public void SeSaveRecoverCustomObjectTest() + public async Task SeSaveRecoverCustomObjectTest() { string key = "key"; string field = "field1"; @@ -247,11 +250,11 @@ public void SeSaveRecoverCustomObjectTest() while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true); server.Register.NewCommand("MYDICTSET", CommandType.ReadModifyWrite, factory, new MyDictSet(), new RespCommandsInfo { Arity = 4 }); server.Register.NewCommand("MYDICTGET", CommandType.Read, factory, new MyDictGet(), new RespCommandsInfo { Arity = 3 }); - server.Start(); + _ = server.StartAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -262,7 +265,7 @@ public void SeSaveRecoverCustomObjectTest() } [Test] - public void SeSaveRecoverCustomScriptTest() + public async Task SeSaveRecoverCustomScriptTest() { static void ValidateServerData(IDatabase db, string strKey, string strValue, string listKey, string listValue) { @@ -293,10 +296,10 @@ static void ValidateServerData(IDatabase db, string strKey, string strValue, str while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true); server.Register.NewProcedure("SETMAINANDOBJECT", () => new SetStringAndList()); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -309,13 +312,13 @@ static void ValidateServerData(IDatabase db, string strKey, string strValue, str [TestCase(63, 2, 1)] [TestCase(16, 16, 1)] [TestCase(5, 64, 1)] - public void SeSaveRecoverMultipleObjectsTest(int memorySize, int recoveryMemorySize, int pageSize) + public async Task SeSaveRecoverMultipleObjectsTest(int memorySize, int recoveryMemorySize, int pageSize) { string sizeToString(int size) => size + "k"; server.Dispose(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, MemorySize: sizeToString(memorySize), PageSize: sizeToString(pageSize)); - server.Start(); + await server.RunAsync(); var ldata = new RedisValue[] { "a", "b", "c", "d" }; var ldataArr = ldata.Select(x => x).Reverse().ToArray(); @@ -334,9 +337,9 @@ public void SeSaveRecoverMultipleObjectsTest(int memorySize, int recoveryMemoryS while (server.LastSave().Ticks == DateTimeOffset.FromUnixTimeSeconds(0).Ticks) Thread.Sleep(10); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, lowMemory: true, MemorySize: sizeToString(recoveryMemorySize), PageSize: sizeToString(pageSize), objectStoreHeapMemorySize: "64k"); - server.Start(); + await server.RunAsync(); ClassicAssert.LessOrEqual(server.Provider.StoreWrapper.objectStore.MaxAllocatedPageCount, (recoveryMemorySize / pageSize) + 1); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) @@ -358,13 +361,13 @@ public void SeSaveRecoverMultipleObjectsTest(int memorySize, int recoveryMemoryS [TestCase("16k", "16k")] [TestCase("5k", "8k")] [TestCase("5k", "64k")] - public void SeSaveRecoverMultipleKeysTest(string memorySize, string recoveryMemorySize) + public async Task SeSaveRecoverMultipleKeysTest(string memorySize, string recoveryMemorySize) { bool disableObj = true; server.Dispose(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: disableObj, lowMemory: true, MemorySize: memorySize, PageSize: "512", enableAOF: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -401,9 +404,9 @@ public void SeSaveRecoverMultipleKeysTest(string memorySize, string recoveryMemo db.Execute("COMMITAOF"); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: disableObj, tryRecover: true, lowMemory: true, MemorySize: recoveryMemorySize, PageSize: "512", enableAOF: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -417,11 +420,11 @@ public void SeSaveRecoverMultipleKeysTest(string memorySize, string recoveryMemo } [Test] - public void SeAofRecoverTest() + public async Task SeAofRecoverTest() { - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableAOF: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -431,9 +434,9 @@ public void SeAofRecoverTest() db.Execute("COMMITAOF"); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableAOF: true, tryRecover: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { diff --git a/test/Garnet.test/RespAofAzureTests.cs b/test/Garnet.test/RespAofAzureTests.cs index 9787ba1e749..7a273cf6883 100644 --- a/test/Garnet.test/RespAofAzureTests.cs +++ b/test/Garnet.test/RespAofAzureTests.cs @@ -3,6 +3,8 @@ using System; using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -12,7 +14,7 @@ namespace Garnet.test [TestFixture] public class RespAofAzureTests { - GarnetServer server; + GarnetApplication server; static readonly SortedSetEntry[] entries = [ new SortedSetEntry("a", 1), @@ -28,10 +30,10 @@ public class RespAofAzureTests ]; [SetUp] - public void Setup() + public async Task Setup() { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableAOF: true, lowMemory: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); } [TearDown] @@ -41,7 +43,7 @@ public void TearDown() } [Test] - public void AofUpsertStoreRecoverTest() + public async Task AofUpsertStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -51,9 +53,9 @@ public void AofUpsertStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -66,7 +68,7 @@ public void AofUpsertStoreRecoverTest() } [Test] - public void AofUpsertStoreAutoCommitRecoverTest() + public async Task AofUpsertStoreAutoCommitRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -76,9 +78,9 @@ public void AofUpsertStoreAutoCommitRecoverTest() } server.Store.WaitForCommit(); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -91,11 +93,11 @@ public void AofUpsertStoreAutoCommitRecoverTest() } [Test] - public void AofUpsertStoreAutoCommitCommitWaitRecoverTest() + public async Task AofUpsertStoreAutoCommitCommitWaitRecoverTest() { - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: false, enableAOF: true, commitWait: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -103,9 +105,10 @@ public void AofUpsertStoreAutoCommitCommitWaitRecoverTest() db.StringSet("SeAofUpsertRecoverTestKey1", "SeAofUpsertRecoverTestValue1"); db.StringSet("SeAofUpsertRecoverTestKey2", "SeAofUpsertRecoverTestValue2"); } - server.Dispose(false); + + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -118,7 +121,7 @@ public void AofUpsertStoreAutoCommitCommitWaitRecoverTest() } [Test] - public void AofUpsertStoreCkptRecoverTest() + public async Task AofUpsertStoreCkptRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -136,9 +139,9 @@ public void AofUpsertStoreCkptRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -153,7 +156,7 @@ public void AofUpsertStoreCkptRecoverTest() } [Test] - public void AofRMWStoreRecoverTest() + public async Task AofRMWStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -163,9 +166,9 @@ public void AofRMWStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -178,7 +181,7 @@ public void AofRMWStoreRecoverTest() } [Test] - public void AofDeleteStoreRecoverTest() + public async Task AofDeleteStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -198,9 +201,9 @@ public void AofDeleteStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -215,7 +218,7 @@ public void AofDeleteStoreRecoverTest() } [Test] - public void AofExpiryRMWStoreRecoverTest() + public async Task AofExpiryRMWStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -233,9 +236,9 @@ public void AofExpiryRMWStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -248,7 +251,7 @@ public void AofExpiryRMWStoreRecoverTest() } [Test] - public void AofRMWObjectStoreRecoverTest() + public async Task AofRMWObjectStoreRecoverTest() { var key = "AofRMWObjectStoreRecoverTestKey"; @@ -267,9 +270,9 @@ public void AofRMWObjectStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -285,7 +288,7 @@ public void AofRMWObjectStoreRecoverTest() } [Test] - public void AofDeleteObjectStoreRecoverTest() + public async Task AofDeleteObjectStoreRecoverTest() { var key1 = "AofDeleteObjectStoreRecoverTestKey1"; var key2 = "AofDeleteObjectStoreRecoverTestKey2"; @@ -313,9 +316,9 @@ public void AofDeleteObjectStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -328,7 +331,7 @@ public void AofDeleteObjectStoreRecoverTest() } [Test] - public void AofRMWObjectStoreCopyUpdateRecoverTest() + public async Task AofRMWObjectStoreCopyUpdateRecoverTest() { var key = "AofRMWObjectStoreRecoverTestKey"; @@ -349,9 +352,9 @@ public void AofRMWObjectStoreCopyUpdateRecoverTest() db.SortedSetAdd("AofRMWObjectStoreRecoverTestKey" + 1, newEntries); } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -367,7 +370,7 @@ public void AofRMWObjectStoreCopyUpdateRecoverTest() } [Test] - public void AofMultiRMWStoreCkptRecoverTest() + public async Task AofMultiRMWStoreCkptRecoverTest() { long ret = 0; using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) @@ -404,9 +407,9 @@ public void AofMultiRMWStoreCkptRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true, UseAzureStorage: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { diff --git a/test/Garnet.test/RespAofTests.cs b/test/Garnet.test/RespAofTests.cs index 9cae04773e1..6712bec0431 100644 --- a/test/Garnet.test/RespAofTests.cs +++ b/test/Garnet.test/RespAofTests.cs @@ -5,7 +5,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using Garnet.server; +using Microsoft.Extensions.Hosting; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -15,7 +18,7 @@ namespace Garnet.test [TestFixture] public class RespAofTests { - GarnetServer server; + GarnetApplication server; private IReadOnlyDictionary respCustomCommandsInfo; static readonly SortedSetEntry[] entries = @@ -33,13 +36,13 @@ public class RespAofTests ]; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); ClassicAssert.IsTrue(TestUtils.TryGetCustomCommandsInfo(out respCustomCommandsInfo)); ClassicAssert.IsNotNull(respCustomCommandsInfo); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableAOF: true, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] @@ -50,7 +53,7 @@ public void TearDown() } [Test] - public void AofUpsertStoreRecoverTest() + public async Task AofUpsertStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -60,7 +63,7 @@ public void AofUpsertStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -75,7 +78,7 @@ public void AofUpsertStoreRecoverTest() } [Test] - public void AofUpsertStoreAutoCommitRecoverTest() + public async Task AofUpsertStoreAutoCommitRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -85,7 +88,7 @@ public void AofUpsertStoreAutoCommitRecoverTest() } server.Store.WaitForCommit(); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -101,11 +104,11 @@ public void AofUpsertStoreAutoCommitRecoverTest() [Test] [CancelAfter(10_000)] - public void AofUpsertStoreCommitTaskRecoverTest() + public async Task AofUpsertStoreCommitTaskRecoverTest() { - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: false, enableAOF: true, commitFrequencyMs: 100); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -115,7 +118,7 @@ public void AofUpsertStoreCommitTaskRecoverTest() } server.Store.WaitForCommit(); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -130,9 +133,9 @@ public void AofUpsertStoreCommitTaskRecoverTest() } [Test] - public void AofUpsertStoreAutoCommitCommitWaitRecoverTest() + public async Task AofUpsertStoreAutoCommitCommitWaitRecoverTest() { - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: false, enableAOF: true, commitWait: true); server.Start(); @@ -142,7 +145,7 @@ public void AofUpsertStoreAutoCommitCommitWaitRecoverTest() db.StringSet("SeAofUpsertRecoverTestKey1", "SeAofUpsertRecoverTestValue1"); db.StringSet("SeAofUpsertRecoverTestKey2", "SeAofUpsertRecoverTestValue2"); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -157,9 +160,9 @@ public void AofUpsertStoreAutoCommitCommitWaitRecoverTest() } [Test] - public void AofTransactionStoreAutoCommitCommitWaitRecoverTest() + public async Task AofTransactionStoreAutoCommitCommitWaitRecoverTest() { - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: false, enableAOF: true, commitWait: true); server.Start(); @@ -172,7 +175,7 @@ public void AofTransactionStoreAutoCommitCommitWaitRecoverTest() ClassicAssert.IsTrue(transaction.Execute()); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -187,7 +190,7 @@ public void AofTransactionStoreAutoCommitCommitWaitRecoverTest() } [Test] - public void AofUpsertStoreCkptRecoverTest() + public async Task AofUpsertStoreCkptRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -205,7 +208,7 @@ public void AofUpsertStoreCkptRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -222,7 +225,7 @@ public void AofUpsertStoreCkptRecoverTest() } [Test] - public void AofRMWStoreRecoverTest() + public async Task AofRMWStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -232,7 +235,7 @@ public void AofRMWStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -247,7 +250,7 @@ public void AofRMWStoreRecoverTest() } [Test] - public void AofDeleteStoreRecoverTest() + public async Task AofDeleteStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -267,7 +270,7 @@ public void AofDeleteStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -284,7 +287,7 @@ public void AofDeleteStoreRecoverTest() } [Test] - public void AofExpiryRMWStoreRecoverTest() + public async Task AofExpiryRMWStoreRecoverTest() { using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -302,7 +305,7 @@ public void AofExpiryRMWStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -317,7 +320,7 @@ public void AofExpiryRMWStoreRecoverTest() } [Test] - public void AofRMWObjectStoreRecoverTest() + public async Task AofRMWObjectStoreRecoverTest() { var key = "AofRMWObjectStoreRecoverTestKey"; @@ -336,7 +339,7 @@ public void AofRMWObjectStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -354,7 +357,7 @@ public void AofRMWObjectStoreRecoverTest() } [Test] - public void AofDeleteObjectStoreRecoverTest() + public async Task AofDeleteObjectStoreRecoverTest() { var key1 = "AofDeleteObjectStoreRecoverTestKey1"; var key2 = "AofDeleteObjectStoreRecoverTestKey2"; @@ -382,7 +385,7 @@ public void AofDeleteObjectStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -397,7 +400,7 @@ public void AofDeleteObjectStoreRecoverTest() } [Test] - public void AofRMWObjectStoreCopyUpdateRecoverTest() + public async Task AofRMWObjectStoreCopyUpdateRecoverTest() { var key = "AofRMWObjectStoreRecoverTestKey"; @@ -418,7 +421,7 @@ public void AofRMWObjectStoreCopyUpdateRecoverTest() db.SortedSetAdd("AofRMWObjectStoreRecoverTestKey" + 1, newEntries); } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -436,7 +439,7 @@ public void AofRMWObjectStoreCopyUpdateRecoverTest() } [Test] - public void AofUpsertObjectStoreRecoverTest() + public async Task AofUpsertObjectStoreRecoverTest() { var origList = new RedisValue[] { "a", "b", "c", "d" }; var key1 = "lkey1"; @@ -461,7 +464,7 @@ public void AofUpsertObjectStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Start(); @@ -475,16 +478,16 @@ public void AofUpsertObjectStoreRecoverTest() } [Test] - public void AofUpsertCustomObjectRecoverTest() + public async Task AofUpsertCustomObjectRecoverTest() { - void RegisterCustomCommand(GarnetServer gServer) + void RegisterCustomCommand(GarnetApplication gServer) { var factory = new MyDictFactory(); gServer.Register.NewCommand("MYDICTSET", CommandType.ReadModifyWrite, factory, new MyDictSet(), respCustomCommandsInfo["MYDICTSET"]); gServer.Register.NewCommand("MYDICTGET", CommandType.Read, factory, new MyDictGet(), respCustomCommandsInfo["MYDICTGET"]); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableAOF: true); RegisterCustomCommand(server); server.Start(); @@ -511,10 +514,10 @@ void RegisterCustomCommand(GarnetServer gServer) } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); RegisterCustomCommand(server); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -526,7 +529,7 @@ void RegisterCustomCommand(GarnetServer gServer) } [Test] - public void AofUpsertCustomScriptRecoverTest() + public async Task AofUpsertCustomScriptRecoverTest() { static void ValidateServerData(IDatabase db, string strKey, string strValue, string listKey, string listValue) { @@ -537,7 +540,7 @@ static void ValidateServerData(IDatabase db, string strKey, string strValue, str ClassicAssert.AreEqual(listValue, (string)retList[0]); } - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, enableAOF: true); server.Register.NewProcedure("SETMAINANDOBJECT", () => new SetStringAndList()); server.Start(); @@ -555,10 +558,10 @@ static void ValidateServerData(IDatabase db, string strKey, string strValue, str } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Register.NewProcedure("SETMAINANDOBJECT", () => new SetStringAndList()); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -567,7 +570,7 @@ static void ValidateServerData(IDatabase db, string strKey, string strValue, str } [Test] - public void AofMultiRMWStoreCkptRecoverTest() + public async Task AofMultiRMWStoreCkptRecoverTest() { long ret = 0; using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) @@ -604,9 +607,9 @@ public void AofMultiRMWStoreCkptRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig(allowAdmin: true))) { @@ -617,7 +620,7 @@ public void AofMultiRMWStoreCkptRecoverTest() } [Test] - public void AofListObjectStoreRecoverTest() + public async Task AofListObjectStoreRecoverTest() { var key = "AofListObjectStoreRecoverTest"; var ldata = new RedisValue[] { "a", "b", "c", "d" }; @@ -635,9 +638,9 @@ public void AofListObjectStoreRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { @@ -649,7 +652,7 @@ public void AofListObjectStoreRecoverTest() } [Test] - public void AofCustomTxnRecoverTest() + public async Task AofCustomTxnRecoverTest() { server.Register.NewTransactionProc("READWRITETX", () => new ReadWriteTxn(), new RespCommandsInfo { Arity = 4 }); string readkey = "readme"; @@ -669,11 +672,11 @@ public void AofCustomTxnRecoverTest() } server.Store.CommitAOF(true); - server.Dispose(false); + await server.StopAsync(); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, tryRecover: true, enableAOF: true); server.Register.NewTransactionProc("READWRITETX", () => new ReadWriteTxn(), new RespCommandsInfo { Arity = 4 }); - server.Start(); + await server.RunAsync(); using (var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig())) { diff --git a/test/Garnet.test/RespBlockingListTests.cs b/test/Garnet.test/RespBlockingListTests.cs index 2e925241614..5ba9a27d623 100644 --- a/test/Garnet.test/RespBlockingListTests.cs +++ b/test/Garnet.test/RespBlockingListTests.cs @@ -4,6 +4,7 @@ using System; using System.Text; using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -12,21 +13,21 @@ namespace Garnet.test { public class RespBlockingListTests { - GarnetServer server; + GarnetApplication server; private TaskFactory taskFactory = new(); [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespCommandTests.cs b/test/Garnet.test/RespCommandTests.cs index 8059ee3c256..919ecc54631 100644 --- a/test/Garnet.test/RespCommandTests.cs +++ b/test/Garnet.test/RespCommandTests.cs @@ -7,7 +7,9 @@ using System.Linq; using System.Reflection; using System.Runtime.InteropServices; +using System.Threading.Tasks; using Garnet.common; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -21,7 +23,7 @@ namespace Garnet.test [TestFixture] public class RespCommandTests { - GarnetServer server; + GarnetApplication server; private string extTestDir; private IReadOnlyDictionary respCommandsInfo; private IReadOnlyDictionary respSubCommandsInfo; @@ -31,7 +33,7 @@ public class RespCommandTests private IReadOnlyDictionary respCustomCommandsDocs; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); extTestDir = Path.Combine(TestUtils.MethodTestDir, "test"); @@ -47,13 +49,13 @@ public void Setup() ClassicAssert.IsNotNull(respCustomCommandsDocs); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, disablePubSub: true, extensionBinPaths: [extTestDir]); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); TestUtils.DeleteDirectory(Directory.GetParent(extTestDir)?.FullName); } diff --git a/test/Garnet.test/RespCustomCommandTests.cs b/test/Garnet.test/RespCustomCommandTests.cs index cef93535171..f40a67f091a 100644 --- a/test/Garnet.test/RespCustomCommandTests.cs +++ b/test/Garnet.test/RespCustomCommandTests.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Garnet.common; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -144,12 +145,12 @@ public override bool Execute(TGarnetApi garnetApi, ref CustomProcedu [TestFixture] public class RespCustomCommandTests { - GarnetServer server; + GarnetApplication server; private string _extTestDir1; private string _extTestDir2; [SetUp] - public void Setup() + public async Task Setup() { _extTestDir1 = Path.Combine(TestUtils.MethodTestDir, "test1"); _extTestDir2 = Path.Combine(TestUtils.MethodTestDir, "test2"); @@ -159,13 +160,13 @@ public void Setup() disablePubSub: true, extensionBinPaths: [_extTestDir1, _extTestDir2], extensionAllowUnsignedAssemblies: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); TestUtils.DeleteDirectory(Directory.GetParent(_extTestDir1)?.FullName); } diff --git a/test/Garnet.test/RespGetLowMemoryTests.cs b/test/Garnet.test/RespGetLowMemoryTests.cs index ff39389a7ef..46b9c4b2976 100644 --- a/test/Garnet.test/RespGetLowMemoryTests.cs +++ b/test/Garnet.test/RespGetLowMemoryTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -14,22 +15,22 @@ namespace Garnet.test [TestFixture] public class RespGetLowMemoryTests { - GarnetServer server; + GarnetApplication server; Random r; [SetUp] - public void Setup() + public async Task Setup() { r = new Random(335); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, getSG: true, disablePubSub: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespHashTests.cs b/test/Garnet.test/RespHashTests.cs index e4a7b9b8d23..3d944d09390 100644 --- a/test/Garnet.test/RespHashTests.cs +++ b/test/Garnet.test/RespHashTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -15,22 +16,22 @@ namespace Garnet.test [TestFixture] public class RespHashTests { - GarnetServer server; + GarnetApplication server; static readonly HashEntry[] entries = new HashEntry[100]; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespInfoTests.cs b/test/Garnet.test/RespInfoTests.cs index c6c5e077f99..d242725d48b 100644 --- a/test/Garnet.test/RespInfoTests.cs +++ b/test/Garnet.test/RespInfoTests.cs @@ -4,6 +4,8 @@ using System; using System.Linq; using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -13,22 +15,22 @@ namespace Garnet.test [TestFixture] public class RespInfoTests { - GarnetServer server; + GarnetApplication server; Random r; [SetUp] - public void Setup() + public async Task Setup() { r = new Random(674386); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, disablePubSub: true, latencyMonitor: true, metricsSamplingFreq: 1, DisableObjects: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespListGarnetClientTests.cs b/test/Garnet.test/RespListGarnetClientTests.cs index 44137a37e35..9cb5b2e4a59 100644 --- a/test/Garnet.test/RespListGarnetClientTests.cs +++ b/test/Garnet.test/RespListGarnetClientTests.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Garnet.client; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -12,14 +13,14 @@ namespace Garnet.test [TestFixture] public class RespListGarnetClientTests { - private GarnetServer server; + private GarnetApplication server; [OneTimeSetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } private static object[] LeftPushTestCases = @@ -271,9 +272,9 @@ private static async Task ValidateListContentAsync(GarnetClient db, string key, } [OneTimeTearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespListTests.cs b/test/Garnet.test/RespListTests.cs index fbf140c13d7..9e865496e06 100644 --- a/test/Garnet.test/RespListTests.cs +++ b/test/Garnet.test/RespListTests.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -17,22 +18,22 @@ namespace Garnet.test [TestFixture] class RespListTests { - GarnetServer server; + GarnetApplication server; Random r; [SetUp] - public void Setup() + public async Task Setup() { r = new Random(674386); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespLowMemoryTests.cs b/test/Garnet.test/RespLowMemoryTests.cs index 091d100637f..534d2a33a94 100644 --- a/test/Garnet.test/RespLowMemoryTests.cs +++ b/test/Garnet.test/RespLowMemoryTests.cs @@ -2,6 +2,8 @@ // Licensed under the MIT license. using System; +using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -11,20 +13,20 @@ namespace Garnet.test [TestFixture] public class RespLowMemoryTests { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespMetricsTest.cs b/test/Garnet.test/RespMetricsTest.cs index 024cd94954b..cb768911924 100644 --- a/test/Garnet.test/RespMetricsTest.cs +++ b/test/Garnet.test/RespMetricsTest.cs @@ -4,7 +4,9 @@ using System; using System.Linq; using System.Threading; +using System.Threading.Tasks; using Garnet.common; +using Garnet.host; using Microsoft.Extensions.Logging; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -15,14 +17,14 @@ namespace Garnet.test [TestFixture] public class RespMetricsTest { - GarnetServer server; + GarnetApplication server; ILoggerFactory loggerFactory; Random r; - private void StartServer(int metricsSamplingFreq = -1, bool latencyMonitor = false) + private async Task StartServer(int metricsSamplingFreq = -1, bool latencyMonitor = false) { server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, metricsSamplingFreq: metricsSamplingFreq, latencyMonitor: latencyMonitor); - server.Start(); + await server.RunAsync(); } [SetUp] @@ -35,9 +37,9 @@ public void Setup() } [TearDown] - public void TearDown() + public async Task TearDown() { - server?.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); } diff --git a/test/Garnet.test/RespModuleTests.cs b/test/Garnet.test/RespModuleTests.cs index ae88521a2c9..7125a95afd3 100644 --- a/test/Garnet.test/RespModuleTests.cs +++ b/test/Garnet.test/RespModuleTests.cs @@ -4,6 +4,8 @@ using System.IO; using System.Reflection; using System.Runtime.InteropServices; +using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -13,11 +15,11 @@ namespace Garnet.test [TestFixture] public class RespModuleTests { - GarnetServer server; + GarnetApplication server; private string testModuleDir; [SetUp] - public void Setup() + public async Task Setup() { testModuleDir = Path.Combine(TestUtils.MethodTestDir, "testModules"); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); @@ -25,13 +27,13 @@ public void Setup() disablePubSub: true, extensionBinPaths: [testModuleDir], extensionAllowUnsignedAssemblies: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); TestUtils.DeleteDirectory(Directory.GetParent(testModuleDir)?.FullName); } @@ -174,7 +176,7 @@ public void TestModuleLoad() [Test] - public void TestModuleLoadUsingGarnetOptions() + public async Task TestModuleLoadUsingGarnetOptions() { var onLoad = @"context.Initialize(""TestModule1"", 1); @@ -194,7 +196,7 @@ public void TestModuleLoadUsingGarnetOptions() server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, disablePubSub: true, loadModulePaths: [module1Path, module2Path]); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); diff --git a/test/Garnet.test/RespPubSubTests.cs b/test/Garnet.test/RespPubSubTests.cs index 35b1d631681..a6c7ed0951a 100644 --- a/test/Garnet.test/RespPubSubTests.cs +++ b/test/Garnet.test/RespPubSubTests.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Security.Cryptography; using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -14,20 +16,20 @@ namespace Garnet.test [TestFixture] class RespPubSubTests { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, pubSubPageSize: "256k"); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespScanCommandsTests.cs b/test/Garnet.test/RespScanCommandsTests.cs index bba4077d188..40437d3c325 100644 --- a/test/Garnet.test/RespScanCommandsTests.cs +++ b/test/Garnet.test/RespScanCommandsTests.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -15,23 +17,23 @@ namespace Garnet.test [TestFixture] public class RespScanCommandsTests { - GarnetServer server; + GarnetApplication server; private IReadOnlyDictionary respCustomCommandsInfo; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); ClassicAssert.IsTrue(TestUtils.TryGetCustomCommandsInfo(out respCustomCommandsInfo)); ClassicAssert.IsNotNull(respCustomCommandsInfo); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespSetTest.cs b/test/Garnet.test/RespSetTest.cs index 59344b462d4..222ae83fa96 100644 --- a/test/Garnet.test/RespSetTest.cs +++ b/test/Garnet.test/RespSetTest.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -17,20 +18,20 @@ namespace Garnet.test [TestFixture] public class RespSetTest { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespSortedSetGarnetClientTests.cs b/test/Garnet.test/RespSortedSetGarnetClientTests.cs index ef7d4563811..39af4ef36ea 100644 --- a/test/Garnet.test/RespSortedSetGarnetClientTests.cs +++ b/test/Garnet.test/RespSortedSetGarnetClientTests.cs @@ -12,6 +12,7 @@ using Garnet.client; using Garnet.client.GarnetClientAPI; using Garnet.common; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -21,7 +22,7 @@ namespace Garnet.test [TestFixture] public class RespSortedSetGarnetClientTests { - protected GarnetServer server; + protected GarnetApplication server; ManualResetEventSlim waiter; const int maxIterations = 3; @@ -41,19 +42,19 @@ public class RespSortedSetGarnetClientTests [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, enableAOF: true); - server.Start(); + await server.RunAsync(); waiter = new ManualResetEventSlim(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespSortedSetGeoTests.cs b/test/Garnet.test/RespSortedSetGeoTests.cs index b7c6d1cc883..284dfe91646 100644 --- a/test/Garnet.test/RespSortedSetGeoTests.cs +++ b/test/Garnet.test/RespSortedSetGeoTests.cs @@ -5,7 +5,9 @@ using System.Globalization; using System.Linq; using System.Text; +using System.Threading.Tasks; using Garnet.common; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -16,7 +18,7 @@ namespace Garnet.test [TestFixture] public class RespSortedSetGeoTests { - GarnetServer server; + GarnetApplication server; readonly string[,] cities = new string[,] { {"-74.0059413", "40.7127837", "New York"}, {"-118.2436849", "34.0522342", "Los Angeles"}, @@ -126,17 +128,17 @@ public class RespSortedSetGeoTests [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespSortedSetTests.cs b/test/Garnet.test/RespSortedSetTests.cs index 3abfaa67c24..66f61b92506 100644 --- a/test/Garnet.test/RespSortedSetTests.cs +++ b/test/Garnet.test/RespSortedSetTests.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Embedded.server; using Garnet.common; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -27,7 +28,7 @@ namespace Garnet.test [TestFixture] public class RespSortedSetTests { - protected GarnetServer server; + protected GarnetApplication server; static readonly SortedSetEntry[] entries = [ @@ -73,18 +74,18 @@ public class RespSortedSetTests [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespTests.cs b/test/Garnet.test/RespTests.cs index 86c0adfa96e..5a2a402e858 100644 --- a/test/Garnet.test/RespTests.cs +++ b/test/Garnet.test/RespTests.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Garnet.client; using Garnet.common; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -20,22 +21,22 @@ namespace Garnet.test [TestFixture] public class RespTests { - GarnetServer server; + GarnetApplication server; Random r; [SetUp] - public void Setup() + public async Task Setup() { r = new Random(674386); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, disablePubSub: false); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } @@ -1053,13 +1054,13 @@ public void SingleDelete() } [Test] - public void SingleDeleteWithObjectStoreDisabled() + public async Task SingleDeleteWithObjectStoreDisabled() { TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: true); - server.Start(); + await server.RunAsync(); var key = "delKey"; var value = "1234"; @@ -1085,13 +1086,13 @@ private string GetRandomString(int len) } [Test] - public void SingleDeleteWithObjectStoreDisable_LTM() + public async Task SingleDeleteWithObjectStoreDisable_LTM() { TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, DisableObjects: true); - server.Start(); + await server.RunAsync(); using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -1125,14 +1126,14 @@ public void SingleDeleteWithObjectStoreDisable_LTM() } [Test] - public void MultiKeyDelete([Values] bool withoutObjectStore) + public async Task MultiKeyDelete([Values] bool withoutObjectStore) { if (withoutObjectStore) { TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: true); - server.Start(); + await server.RunAsync(); } using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); @@ -1193,14 +1194,14 @@ public void MultiKeyDeleteObjectStore() } [Test] - public void MultiKeyUnlink([Values] bool withoutObjectStore) + public async Task MultiKeyUnlink([Values] bool withoutObjectStore) { if (withoutObjectStore) { TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: true); - server.Start(); + await server.RunAsync(); } using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); @@ -1259,14 +1260,14 @@ public void MultiKeyUnlinkObjectStore() } [Test] - public void SingleExists([Values] bool withoutObjectStore) + public async Task SingleExists([Values] bool withoutObjectStore) { if (withoutObjectStore) { TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: true); - server.Start(); + await server.RunAsync(); } using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -1524,14 +1525,14 @@ public void SingleRenameWithExpiry() } [Test] - public void SingleRenameKeyEdgeCase([Values] bool withoutObjectStore) + public async Task SingleRenameKeyEdgeCase([Values] bool withoutObjectStore) { if (withoutObjectStore) { TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, DisableObjects: true); - server.Start(); + await server.RunAsync(); } using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig()); var db = redis.GetDatabase(0); @@ -3382,13 +3383,13 @@ public void HelloTest1() } [Test] - public void AsyncTest1() + public async Task AsyncTest1() { // Set up low-memory database TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true, DisableObjects: true); - server.Start(); + await server.RunAsync(); string firstKey = null, firstValue = null, lastKey = null, lastValue = null; diff --git a/test/Garnet.test/RespTlsTests.cs b/test/Garnet.test/RespTlsTests.cs index 7e612405167..5cca1d7d814 100644 --- a/test/Garnet.test/RespTlsTests.cs +++ b/test/Garnet.test/RespTlsTests.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Garnet.common; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -17,20 +18,20 @@ namespace Garnet.test [TestFixture] public class RespTlsTests { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, EnableTLS: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/RespTransactionProcTests.cs b/test/Garnet.test/RespTransactionProcTests.cs index b3f3c05c29e..d32e5970815 100644 --- a/test/Garnet.test/RespTransactionProcTests.cs +++ b/test/Garnet.test/RespTransactionProcTests.cs @@ -2,6 +2,8 @@ // Licensed under the MIT license. using System.Threading; +using System.Threading.Tasks; +using Garnet.host; using Garnet.server; using NUnit.Framework; using NUnit.Framework.Legacy; @@ -12,20 +14,20 @@ namespace Garnet.test [TestFixture] public class RespTransactionProcTests { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, disablePubSub: true); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } diff --git a/test/Garnet.test/TestUtils.cs b/test/Garnet.test/TestUtils.cs index 7e9698a4940..890c5bd4c21 100644 --- a/test/Garnet.test/TestUtils.cs +++ b/test/Garnet.test/TestUtils.cs @@ -184,7 +184,7 @@ internal static void IgnoreIfNotRunningAzureTests() /// /// Create GarnetServer /// - public static GarnetServer CreateGarnetServer( + public static GarnetApplication CreateGarnetServer( string logCheckpointDir, bool disablePubSub = false, bool tryRecover = false, @@ -342,7 +342,7 @@ public static GarnetServer CreateGarnetServer( var app = builder.Build(); - return app.Services.GetRequiredService(); + return app; } else { @@ -350,7 +350,7 @@ public static GarnetServer CreateGarnetServer( var app = builder.Build(); - return app.Services.GetRequiredService(); + return app; } } diff --git a/test/Garnet.test/TransactionTests.cs b/test/Garnet.test/TransactionTests.cs index 76e91799b1f..f1d1620b546 100644 --- a/test/Garnet.test/TransactionTests.cs +++ b/test/Garnet.test/TransactionTests.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using Garnet.host; using NUnit.Framework; using NUnit.Framework.Legacy; using StackExchange.Redis; @@ -12,29 +13,29 @@ namespace Garnet.test [TestFixture] public class TransactionTests { - GarnetServer server; + GarnetApplication server; [SetUp] - public void Setup() + public async Task Setup() { TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir); - server.Start(); + await server.RunAsync(); } [TearDown] - public void TearDown() + public async Task TearDown() { - server.Dispose(); + await server.StopAsync(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir); } - public void SetUpWithLowMemory() + public async Task SetUpWithLowMemory() { TearDown(); TestUtils.DeleteDirectory(TestUtils.MethodTestDir, wait: true); server = TestUtils.CreateGarnetServer(TestUtils.MethodTestDir, lowMemory: true); - server.Start(); + await server.RunAsync(); } [Test]