From a27f0b56c804c4c36a23991bd1edbe6da18e187b Mon Sep 17 00:00:00 2001 From: Ted Hart <15467143+TedHartMS@users.noreply.github.com> Date: Sun, 29 Nov 2020 14:16:43 -0800 Subject: [PATCH] [C#] Clean up TargetFramework defines, enable IAsyncEnumerable on netstandard2.0/net461 (#377) * Clean up targetframework stuff: - Change the order in the csproj so netstandard2.1 is first, which appears to be the one that's used by the IDE for #if resolution - Switch to the TargetFramework preprocessor symbols already defined by the build system (we use NETSTANDARD and NETSTANDARD2_1) - Add Microsoft.Bcl.AsyncInterfaces for pre-netstandard2.1 frameworks, which allows IAsyncEnumerable to work - Added tests for FasterLogIterator.GetAsyncEnumerable() - Enable netcore2.2 in FASTER.tests.csproj * Fix DeviceFasterLogTests hang with IAsyncEnumerator; add tests for FasterLogIterator.GetAsyncEnumerable(MemoryPool) * Update azure-pipelines.yml Put UseDotNet@2 task in the right place * Drop FASTER.test netcoreapp v2.2 to 2.1 (2.2 isn't needed and 2.1 is on the pipeline by default) * Add VSTest2 pipeline task for Linux * use DotNetCoreCLI@2 task to run Linux tests * Specify framework version on C# Linux dotnetcorecli task * Replace directory separator in tests with front slash (/) for Linux compatibility. * Fixed SharedDirectoryTests to work on Linux * change !NET461 to NETCOREAPP; restore previous LocalStorageDevice GetSectorSize behavior Co-authored-by: Badrish Chandramouli --- azure-pipelines.yml | 24 +- cs/benchmark/ConcurrentDictionaryBenchmark.cs | 4 +- cs/benchmark/FasterSpanByteYcsbBenchmark.cs | 4 +- cs/benchmark/FasterYcsbBenchmark.cs | 4 +- cs/playground/CacheStoreConcurrent/Program.cs | 2 +- cs/playground/SumStore/ConcurrencyTest.cs | 2 +- cs/playground/SumStore/RecoveryTest.cs | 2 +- cs/samples/CacheStore/Program.cs | 2 +- cs/samples/FasterLogPubSub/Program.cs | 2 +- cs/samples/FasterLogSample/Program.cs | 2 +- cs/samples/HelloWorld/Program.cs | 2 +- cs/samples/SecondaryReaderStore/Program.cs | 2 +- cs/samples/StoreAsyncApi/Program.cs | 2 +- cs/samples/StoreCheckpointRecover/Program.cs | 2 +- cs/samples/StoreCustomTypes/Program.cs | 2 +- cs/samples/StoreDiskReadBenchmark/Program.cs | 2 +- cs/src/core/Device/Devices.cs | 2 +- .../core/Device/ManagedLocalStorageDevice.cs | 31 +-- cs/src/core/FASTER.core.csproj | 11 +- .../core/Index/FasterLog/FasterLogIterator.cs | 4 +- .../Index/Interfaces/ICompactionFunctions.cs | 4 +- cs/src/core/Index/Interfaces/IFunctions.cs | 2 +- cs/src/core/Utilities/Native32.cs | 6 +- cs/src/core/VarLen/IVariableLengthStruct.cs | 6 +- .../AzureStorageDevice/AzureStorageDevice.cs | 4 +- cs/test/AsyncLargeObjectTests.cs | 10 +- cs/test/AsyncTests.cs | 10 +- cs/test/BasicDiskFASTERTests.cs | 10 +- cs/test/BasicFASTERTests.cs | 2 +- cs/test/BlittableIterationTests.cs | 2 +- cs/test/BlittableLogCompactionTests.cs | 2 +- cs/test/BlittableLogScanTests.cs | 2 +- cs/test/ComponentRecoveryTests.cs | 6 +- cs/test/DeviceFasterLogTests.cs | 58 +++- cs/test/FASTER.test.csproj | 6 +- cs/test/FasterLogResumeTests.cs | 48 ++-- cs/test/FasterLogTests.cs | 256 ++++++++++++++---- cs/test/FunctionPerSessionTests.cs | 2 +- cs/test/GenericByteArrayTests.cs | 4 +- cs/test/GenericDiskDeleteTests.cs | 4 +- cs/test/GenericIterationTests.cs | 4 +- cs/test/GenericLogCompactionTests.cs | 4 +- cs/test/GenericLogScanTests.cs | 4 +- cs/test/GenericStringTests.cs | 4 +- cs/test/LargeObjectTests.cs | 10 +- cs/test/MemoryLogCompactionTests.cs | 2 +- cs/test/MiscFASTERTests.cs | 6 +- cs/test/NativeReadCacheTests.cs | 2 +- cs/test/NeedCopyUpdateTests.cs | 4 +- cs/test/ObjectFASTERTests.cs | 4 +- cs/test/ObjectReadCacheTests.cs | 4 +- cs/test/ObjectRecoveryTest.cs | 6 +- cs/test/ObjectRecoveryTest2.cs | 2 +- cs/test/ObjectRecoveryTest3.cs | 2 +- cs/test/RecoverContinueTests.cs | 12 +- cs/test/RecoveryChecks.cs | 2 +- cs/test/RecoveryTests.cs | 4 +- cs/test/SessionFASTERTests.cs | 2 +- cs/test/SharedDirectoryTests.cs | 40 ++- cs/test/SimpleAsyncTests.cs | 2 +- cs/test/SimpleRecoveryTest.cs | 22 +- cs/test/SpanByteTests.cs | 2 +- cs/test/StateMachineTests.cs | 10 +- cs/test/VariableLengthIteratorTests.cs | 2 +- cs/test/VariableLengthStructFASTERTests.cs | 4 +- 65 files changed, 452 insertions(+), 260 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e1201b647..6adef189e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -64,8 +64,20 @@ jobs: - task: VSTest@2 inputs: testAssemblyVer2: | - **\$(BuildConfiguration)\netcoreapp*\*test.dll - **\$(BuildConfiguration)\**\netcoreapp*\*test.dll + **\$(BuildConfiguration)\netcoreapp2*\*test.dll + **\$(BuildConfiguration)\**\netcoreapp2*\*test.dll + !**\*Microsoft.VisualStudio.TestPlatform* + !**\obj\** + !**\*TestAdapter.dll + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)' + otherConsoleOptions: '/Framework:.NETCoreApp,Version=v2.2' + + - task: VSTest@2 + inputs: + testAssemblyVer2: | + **\$(BuildConfiguration)\netcoreapp3*\*test.dll + **\$(BuildConfiguration)\**\netcoreapp3*\*test.dll !**\*Microsoft.VisualStudio.TestPlatform* !**\obj\** !**\*TestAdapter.dll @@ -169,7 +181,13 @@ jobs: msbuild /t:restore $(solution) msbuild /p:Configuration=Release $(solution) displayName: 'Build' - + + - task: DotNetCoreCLI@2 + inputs: + command: test + projects: '**/test/*.csproj' + arguments: '--configuration $(buildConfiguration) --framework netcoreapp3.1' + # - job: 'cppBlobsWindows' # pool: # vmImage: vs2017-win2016 diff --git a/cs/benchmark/ConcurrentDictionaryBenchmark.cs b/cs/benchmark/ConcurrentDictionaryBenchmark.cs index e4a09e8bb..36946ed25 100644 --- a/cs/benchmark/ConcurrentDictionaryBenchmark.cs +++ b/cs/benchmark/ConcurrentDictionaryBenchmark.cs @@ -409,8 +409,8 @@ void DoContinuousMeasurements() private void LoadDataFromFile(string filePath) { - string init_filename = filePath + "\\load_" + distribution + "_250M_raw.dat"; - string txn_filename = filePath + "\\run_" + distribution + "_250M_1000M_raw.dat"; + string init_filename = filePath + "/load_" + distribution + "_250M_raw.dat"; + string txn_filename = filePath + "/run_" + distribution + "_250M_1000M_raw.dat"; long count = 0; using (FileStream stream = File.Open(init_filename, FileMode.Open, FileAccess.Read, diff --git a/cs/benchmark/FasterSpanByteYcsbBenchmark.cs b/cs/benchmark/FasterSpanByteYcsbBenchmark.cs index 8f7b24bab..504337df6 100644 --- a/cs/benchmark/FasterSpanByteYcsbBenchmark.cs +++ b/cs/benchmark/FasterSpanByteYcsbBenchmark.cs @@ -506,8 +506,8 @@ void DoContinuousMeasurements() private unsafe void LoadDataFromFile(string filePath) { - string init_filename = filePath + "\\load_" + distribution + "_250M_raw.dat"; - string txn_filename = filePath + "\\run_" + distribution + "_250M_1000M_raw.dat"; + string init_filename = filePath + "/load_" + distribution + "_250M_raw.dat"; + string txn_filename = filePath + "/run_" + distribution + "_250M_1000M_raw.dat"; long count = 0; using (FileStream stream = File.Open(init_filename, FileMode.Open, FileAccess.Read, diff --git a/cs/benchmark/FasterYcsbBenchmark.cs b/cs/benchmark/FasterYcsbBenchmark.cs index 247875aa6..996efd7f3 100644 --- a/cs/benchmark/FasterYcsbBenchmark.cs +++ b/cs/benchmark/FasterYcsbBenchmark.cs @@ -498,8 +498,8 @@ void DoContinuousMeasurements() private unsafe void LoadDataFromFile(string filePath) { - string init_filename = filePath + "\\load_" + distribution + "_250M_raw.dat"; - string txn_filename = filePath + "\\run_" + distribution + "_250M_1000M_raw.dat"; + string init_filename = filePath + "/load_" + distribution + "_250M_raw.dat"; + string txn_filename = filePath + "/run_" + distribution + "_250M_1000M_raw.dat"; long count = 0; using (FileStream stream = File.Open(init_filename, FileMode.Open, FileAccess.Read, diff --git a/cs/playground/CacheStoreConcurrent/Program.cs b/cs/playground/CacheStoreConcurrent/Program.cs index 4bb562e53..369b4d1c6 100644 --- a/cs/playground/CacheStoreConcurrent/Program.cs +++ b/cs/playground/CacheStoreConcurrent/Program.cs @@ -34,7 +34,7 @@ static void Main() // Number of caches and number of threads can be varied. h = new FasterKV[kNumTables]; - var path = Path.GetTempPath() + "CacheStoreConcurrent\\"; + var path = Path.GetTempPath() + "CacheStoreConcurrent/"; for (int ht = 0; ht < kNumTables; ht++) { diff --git a/cs/playground/SumStore/ConcurrencyTest.cs b/cs/playground/SumStore/ConcurrencyTest.cs index 4be3a035f..4dd79e90e 100644 --- a/cs/playground/SumStore/ConcurrencyTest.cs +++ b/cs/playground/SumStore/ConcurrencyTest.cs @@ -26,7 +26,7 @@ public ConcurrencyTest(int threadCount) this.threadCount = threadCount; // Create FASTER index - var log = Devices.CreateLogDevice("logs\\hlog"); + var log = Devices.CreateLogDevice("logs/hlog"); fht = new FasterKV (keySpace, new LogSettings { LogDevice = log }, new CheckpointSettings { CheckpointDir = "logs" }); diff --git a/cs/playground/SumStore/RecoveryTest.cs b/cs/playground/SumStore/RecoveryTest.cs index 078953d89..970c2d134 100644 --- a/cs/playground/SumStore/RecoveryTest.cs +++ b/cs/playground/SumStore/RecoveryTest.cs @@ -28,7 +28,7 @@ public RecoveryTest(int threadCount) this.threadCount = threadCount; // Create FASTER index - var log = Devices.CreateLogDevice("logs\\hlog"); + var log = Devices.CreateLogDevice("logs/hlog"); fht = new FasterKV (indexSize, new LogSettings { LogDevice = log }, new CheckpointSettings { CheckpointDir = "logs" }); diff --git a/cs/samples/CacheStore/Program.cs b/cs/samples/CacheStore/Program.cs index d20d5e14c..0bdc404d0 100644 --- a/cs/samples/CacheStore/Program.cs +++ b/cs/samples/CacheStore/Program.cs @@ -22,7 +22,7 @@ static void Main() // Use blittable structs for *much* better performance // Create files for storing data - var path = Path.GetTempPath() + "ClassCache\\"; + var path = Path.GetTempPath() + "ClassCache/"; var log = Devices.CreateLogDevice(path + "hlog.log"); // Log for storing serialized objects; needed only for class keys/values diff --git a/cs/samples/FasterLogPubSub/Program.cs b/cs/samples/FasterLogPubSub/Program.cs index 29afae23f..cffd53798 100644 --- a/cs/samples/FasterLogPubSub/Program.cs +++ b/cs/samples/FasterLogPubSub/Program.cs @@ -14,7 +14,7 @@ class Program { const int commitPeriodMs = 2000; const int restorePeriodMs = 1000; - static string path = Path.GetTempPath() + "FasterLogPubSub\\"; + static string path = Path.GetTempPath() + "FasterLogPubSub/"; static async Task Main() { diff --git a/cs/samples/FasterLogSample/Program.cs b/cs/samples/FasterLogSample/Program.cs index 9dd8315df..466a63057 100644 --- a/cs/samples/FasterLogSample/Program.cs +++ b/cs/samples/FasterLogSample/Program.cs @@ -31,7 +31,7 @@ static void Main() staticEntry[i] = (byte)i; } - var path = Path.GetTempPath() + "FasterLogSample\\"; + var path = Path.GetTempPath() + "FasterLogSample/"; IDevice device = Devices.CreateLogDevice(path + "hlog.log"); // FasterLog will recover and resume if there is a previous commit found diff --git a/cs/samples/HelloWorld/Program.cs b/cs/samples/HelloWorld/Program.cs index dda76d08b..e04b2387a 100644 --- a/cs/samples/HelloWorld/Program.cs +++ b/cs/samples/HelloWorld/Program.cs @@ -17,7 +17,7 @@ static void Main() // This is a simple in-memory sample of FASTER using value types // Create device for FASTER log - var path = Path.GetTempPath() + "HelloWorld\\"; + var path = Path.GetTempPath() + "HelloWorld/"; var log = Devices.CreateLogDevice(Path.GetTempPath() + "hlog.log"); // Create store instance diff --git a/cs/samples/SecondaryReaderStore/Program.cs b/cs/samples/SecondaryReaderStore/Program.cs index 4e9ccd075..12adf06b5 100644 --- a/cs/samples/SecondaryReaderStore/Program.cs +++ b/cs/samples/SecondaryReaderStore/Program.cs @@ -19,7 +19,7 @@ class Program static void Main() { // Create files for storing data - var path = Path.GetTempPath() + "SecondaryReaderStore\\"; + var path = Path.GetTempPath() + "SecondaryReaderStore/"; if (Directory.Exists(path)) new DirectoryInfo(path).Delete(true); diff --git a/cs/samples/StoreAsyncApi/Program.cs b/cs/samples/StoreAsyncApi/Program.cs index ca74d8a78..245683a45 100644 --- a/cs/samples/StoreAsyncApi/Program.cs +++ b/cs/samples/StoreAsyncApi/Program.cs @@ -20,7 +20,7 @@ public class Program /// static void Main() { - var path = Path.GetTempPath() + "StoreAsyncApi\\"; + var path = Path.GetTempPath() + "StoreAsyncApi/"; // Since the example runs forever, we set option to auto-delete files on close // Note that this setting precludes recovery diff --git a/cs/samples/StoreCheckpointRecover/Program.cs b/cs/samples/StoreCheckpointRecover/Program.cs index 27abcda73..619f8e0b8 100644 --- a/cs/samples/StoreCheckpointRecover/Program.cs +++ b/cs/samples/StoreCheckpointRecover/Program.cs @@ -14,7 +14,7 @@ static void Main() // We use classes in this example, replace with blittable structs for // much better performance - var path = Path.GetTempPath() + "StoreCheckpointRecover\\"; + var path = Path.GetTempPath() + "StoreCheckpointRecover/"; // Main hybrid log device var log = Devices.CreateLogDevice(path + "hlog.log"); diff --git a/cs/samples/StoreCustomTypes/Program.cs b/cs/samples/StoreCustomTypes/Program.cs index 3293b9d0f..f8d8dbce2 100644 --- a/cs/samples/StoreCustomTypes/Program.cs +++ b/cs/samples/StoreCustomTypes/Program.cs @@ -18,7 +18,7 @@ static void Main() // (2) Provide IFasterEqualityComparer instance as param to FASTER constructor // Main hybrid log device - var path = Path.GetTempPath() + "StoreCustomTypes\\"; + var path = Path.GetTempPath() + "StoreCustomTypes/"; var log = Devices.CreateLogDevice(path + "hlog.log"); // With non-blittable types, you need an object log device in addition to the diff --git a/cs/samples/StoreDiskReadBenchmark/Program.cs b/cs/samples/StoreDiskReadBenchmark/Program.cs index 403ce3e03..db54c3a0b 100644 --- a/cs/samples/StoreDiskReadBenchmark/Program.cs +++ b/cs/samples/StoreDiskReadBenchmark/Program.cs @@ -31,7 +31,7 @@ public class Program /// static void Main() { - var path = Path.GetTempPath() + "FasterKVDiskReadBenchmark\\"; + var path = Path.GetTempPath() + "FasterKVDiskReadBenchmark/"; if (Directory.Exists(path)) new DirectoryInfo(path).Delete(true); diff --git a/cs/src/core/Device/Devices.cs b/cs/src/core/Device/Devices.cs index fa70db4e3..ee91e5197 100644 --- a/cs/src/core/Device/Devices.cs +++ b/cs/src/core/Device/Devices.cs @@ -28,7 +28,7 @@ public static IDevice CreateLogDevice(string logPath, bool preallocateFile = fal { IDevice logDevice; -#if DOTNETCORE +#if NETSTANDARD if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { logDevice = new ManagedLocalStorageDevice(logPath, preallocateFile, deleteOnClose, capacity, recoverDevice); diff --git a/cs/src/core/Device/ManagedLocalStorageDevice.cs b/cs/src/core/Device/ManagedLocalStorageDevice.cs index 7f543fa7e..2d8f2bb38 100644 --- a/cs/src/core/Device/ManagedLocalStorageDevice.cs +++ b/cs/src/core/Device/ManagedLocalStorageDevice.cs @@ -109,7 +109,7 @@ public override unsafe void ReadAsync(int segmentId, ulong sourceAddress, logReadHandle.Seek((long)sourceAddress, SeekOrigin.Begin); Interlocked.Increment(ref numPending); -#if NETSTANDARD21 +#if NETSTANDARD2_1 var umm = new UnmanagedMemoryManager((byte*)destinationAddress, (int)readLength); logReadHandle.ReadAsync(umm.Memory).AsTask() #else @@ -121,16 +121,7 @@ public override unsafe void ReadAsync(int segmentId, ulong sourceAddress, Interlocked.Decrement(ref numPending); uint errorCode = 0; - if (!t.IsFaulted) - { -#if !NETSTANDARD21 - fixed (void* source = memory.buffer) - { - Buffer.MemoryCopy(source, (void*)destinationAddress, readLength, readLength); - } -#endif - } - else + if (t.IsFaulted) { if (t.Exception.InnerException is IOException) { @@ -142,12 +133,9 @@ public override unsafe void ReadAsync(int segmentId, ulong sourceAddress, errorCode = uint.MaxValue; } } -#if !NETSTANDARD21 - memory.Return(); -#endif // Sequentialize all reads from same handle on non-windows -#if DOTNETCORE +#if NETSTANDARD if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (offset >= 0) streampool?.Return(offset); @@ -158,7 +146,7 @@ public override unsafe void ReadAsync(int segmentId, ulong sourceAddress, } ); -#if DOTNETCORE +#if NETSTANDARD if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (offset >= 0) streampool?.Return(offset); #else @@ -194,7 +182,7 @@ public override unsafe void WriteAsync(IntPtr sourceAddress, logWriteHandle.Seek((long)destinationAddress, SeekOrigin.Begin); Interlocked.Increment(ref numPending); -#if NETSTANDARD21 +#if NETSTANDARD2_1 var umm = new UnmanagedMemoryManager((byte*)sourceAddress, (int)numBytesToWrite); logWriteHandle.WriteAsync(umm.Memory).AsTask() #else @@ -222,12 +210,9 @@ public override unsafe void WriteAsync(IntPtr sourceAddress, errorCode = uint.MaxValue; } } -#if !NETSTANDARD21 - memory.Return(); -#endif // Sequentialize all writes to same handle on non-windows -#if DOTNETCORE +#if NETSTANDARD if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { ((FileStream)logWriteHandle).Flush(true); @@ -239,7 +224,7 @@ public override unsafe void WriteAsync(IntPtr sourceAddress, } ); -#if DOTNETCORE +#if NETSTANDARD if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (offset >= 0) streampool?.Return(offset); #else @@ -296,7 +281,7 @@ private string GetSegmentName(int segmentId) private static uint GetSectorSize(string filename) { -#if DOTNETCORE +#if NETSTANDARD if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Debug.WriteLine("Assuming 512 byte sector alignment for disk with file " + filename); diff --git a/cs/src/core/FASTER.core.csproj b/cs/src/core/FASTER.core.csproj index a47ed971a..5f7d444a1 100644 --- a/cs/src/core/FASTER.core.csproj +++ b/cs/src/core/FASTER.core.csproj @@ -1,7 +1,7 @@  - net461;netstandard2.0;netstandard2.1 + netstandard2.1;netstandard2.0;net461 AnyCPU;x64 8 @@ -32,14 +32,6 @@ bin\$(Platform)\Release\ - - $(DefineConstants);DOTNETCORE - - - - $(DefineConstants);NETSTANDARD21 - - @@ -51,6 +43,7 @@ + diff --git a/cs/src/core/Index/FasterLog/FasterLogIterator.cs b/cs/src/core/Index/FasterLog/FasterLogIterator.cs index deba470fb..477b8e830 100644 --- a/cs/src/core/Index/FasterLog/FasterLogIterator.cs +++ b/cs/src/core/Index/FasterLog/FasterLogIterator.cs @@ -95,7 +95,6 @@ internal unsafe FasterLogScanIterator(FasterLog fasterLog, BlittableAllocator /// Async enumerable for iterator /// @@ -123,7 +122,7 @@ internal unsafe FasterLogScanIterator(FasterLog fasterLog, BlittableAllocator /// Entry, actual entry length, logical address of entry, logical address of next entry - public async IAsyncEnumerable<(IMemoryOwner, int entryLength, long currentAddress, long nextAddress)> GetAsyncEnumerable(MemoryPool pool, [EnumeratorCancellation] CancellationToken token = default) + public async IAsyncEnumerable<(IMemoryOwner entry, int entryLength, long currentAddress, long nextAddress)> GetAsyncEnumerable(MemoryPool pool, [EnumeratorCancellation] CancellationToken token = default) { while (!disposed) { @@ -141,7 +140,6 @@ internal unsafe FasterLogScanIterator(FasterLog fasterLog, BlittableAllocator /// Wait for iteration to be ready to continue diff --git a/cs/src/core/Index/Interfaces/ICompactionFunctions.cs b/cs/src/core/Index/Interfaces/ICompactionFunctions.cs index d82d10c7c..f551c9977 100644 --- a/cs/src/core/Index/Interfaces/ICompactionFunctions.cs +++ b/cs/src/core/Index/Interfaces/ICompactionFunctions.cs @@ -43,7 +43,7 @@ public interface ICompactionFunctions /// [Can be null] Variable length struct functions /// void Copy(ref Value src, ref Value dst, IVariableLengthStruct valueLength) -#if NETSTANDARD21 +#if NETSTANDARD2_1 { } #else ; @@ -64,7 +64,7 @@ void Copy(ref Value src, ref Value dst, IVariableLengthStruct valueLength /// managed pointer to new record. /// bool CopyInPlace(ref Value src, ref Value dst, IVariableLengthStruct valueLength) -#if NETSTANDARD21 +#if NETSTANDARD2_1 => true #endif ; diff --git a/cs/src/core/Index/Interfaces/IFunctions.cs b/cs/src/core/Index/Interfaces/IFunctions.cs index a32e4c067..61df47f5c 100644 --- a/cs/src/core/Index/Interfaces/IFunctions.cs +++ b/cs/src/core/Index/Interfaces/IFunctions.cs @@ -70,7 +70,7 @@ public interface IFunctions /// /// bool NeedCopyUpdate(ref Key key, ref Input input, ref Value oldValue) -#if NETSTANDARD21 +#if NETSTANDARD2_1 => true #endif ; diff --git a/cs/src/core/Utilities/Native32.cs b/cs/src/core/Utilities/Native32.cs index 8eb0604ce..ff02fd8ff 100644 --- a/cs/src/core/Utilities/Native32.cs +++ b/cs/src/core/Utilities/Native32.cs @@ -272,7 +272,7 @@ public static void AffinitizeThreadShardedNuma(uint threadIdx, ushort nrOfProces /// public static bool EnableProcessPrivileges() { -#if DOTNETCORE +#if NETSTANDARD if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return false; #endif @@ -308,7 +308,7 @@ private static uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint A internal static bool EnableVolumePrivileges(string filename, SafeFileHandle handle) { -#if DOTNETCORE +#if NETSTANDARD if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return false; #endif @@ -346,7 +346,7 @@ internal static bool EnableVolumePrivileges(string filename, SafeFileHandle hand /// public static bool SetFileSize(SafeFileHandle file_handle, long file_size) { -#if DOTNETCORE +#if NETSTANDARD if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return false; #endif diff --git a/cs/src/core/VarLen/IVariableLengthStruct.cs b/cs/src/core/VarLen/IVariableLengthStruct.cs index d29bdb968..2de57d7dd 100644 --- a/cs/src/core/VarLen/IVariableLengthStruct.cs +++ b/cs/src/core/VarLen/IVariableLengthStruct.cs @@ -33,7 +33,7 @@ public interface IVariableLengthStruct /// /// unsafe void Serialize(ref T source, void* destination) -#if NETSTANDARD21 +#if NETSTANDARD2_1 => Buffer.MemoryCopy(Unsafe.AsPointer(ref source), destination, GetLength(ref source), GetLength(ref source)) #endif ; @@ -44,7 +44,7 @@ unsafe void Serialize(ref T source, void* destination) /// /// unsafe ref T AsRef(void* source) -#if NETSTANDARD21 +#if NETSTANDARD2_1 => ref Unsafe.AsRef(source) #endif ; @@ -56,7 +56,7 @@ unsafe ref T AsRef(void* source) /// /// unsafe void Initialize(void* source, void* end) -#if NETSTANDARD21 +#if NETSTANDARD2_1 { } #else ; diff --git a/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs b/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs index c2992ca6b..6b2be40bd 100644 --- a/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs +++ b/cs/src/devices/AzureStorageDevice/AzureStorageDevice.cs @@ -53,7 +53,7 @@ public class AzureStorageDevice : StorageDeviceBase /// /// The maximum number of bytes this storage device can accommondate, or CAPACITY_UNSPECIFIED if there is no such limit public AzureStorageDevice(CloudBlobDirectory cloudBlobDirectory, string blobName, IBlobManager blobManager = null, bool underLease = false, bool deleteOnClose = false, long capacity = Devices.CAPACITY_UNSPECIFIED) - : base($"{cloudBlobDirectory}\\{blobName}", PAGE_BLOB_SECTOR_SIZE, capacity) + : base($"{cloudBlobDirectory}/{blobName}", PAGE_BLOB_SECTOR_SIZE, capacity) { this.blobs = new ConcurrentDictionary(); this.blobDirectory = cloudBlobDirectory; @@ -83,7 +83,7 @@ public AzureStorageDevice(CloudBlobDirectory cloudBlobDirectory, string blobName /// /// The maximum number of bytes this storage device can accommondate, or CAPACITY_UNSPECIFIED if there is no such limit public AzureStorageDevice(string connectionString, string containerName, string directoryName, string blobName, IBlobManager blobManager = null, bool underLease = false, bool deleteOnClose = false, long capacity = Devices.CAPACITY_UNSPECIFIED) - : base($"{connectionString}\\{containerName}\\{directoryName}\\{blobName}", PAGE_BLOB_SECTOR_SIZE, capacity) + : base($"{connectionString}/{containerName}/{directoryName}/{blobName}", PAGE_BLOB_SECTOR_SIZE, capacity) { var storageAccount = CloudStorageAccount.Parse(connectionString); var client = storageAccount.CreateCloudBlobClient(); diff --git a/cs/test/AsyncLargeObjectTests.cs b/cs/test/AsyncLargeObjectTests.cs index 2b40c7567..b08527c89 100644 --- a/cs/test/AsyncLargeObjectTests.cs +++ b/cs/test/AsyncLargeObjectTests.cs @@ -28,7 +28,7 @@ public void Setup() { if (test_path == null) { - test_path = TestContext.CurrentContext.TestDirectory + "\\" + Path.GetRandomFileName(); + test_path = TestContext.CurrentContext.TestDirectory + "/" + Path.GetRandomFileName(); if (!Directory.Exists(test_path)) Directory.CreateDirectory(test_path); } @@ -68,8 +68,8 @@ public async Task LargeObjectTest(CheckpointType checkpointType) MyInput input = default; MyLargeOutput output = new MyLargeOutput(); - log = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.log"); - objlog = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.obj.log"); + log = Devices.CreateLogDevice(test_path + "/LargeObjectTest.log"); + objlog = Devices.CreateLogDevice(test_path + "/LargeObjectTest.obj.log"); fht1 = new FasterKV (128, @@ -99,8 +99,8 @@ public async Task LargeObjectTest(CheckpointType checkpointType) log.Dispose(); objlog.Dispose(); - log = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.log"); - objlog = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.obj.log"); + log = Devices.CreateLogDevice(test_path + "/LargeObjectTest.log"); + objlog = Devices.CreateLogDevice(test_path + "/LargeObjectTest.obj.log"); fht2 = new FasterKV (128, diff --git a/cs/test/AsyncTests.cs b/cs/test/AsyncTests.cs index a8c9854a8..d8e4a642b 100644 --- a/cs/test/AsyncTests.cs +++ b/cs/test/AsyncTests.cs @@ -28,20 +28,20 @@ public class RecoveryTests [TestCase(CheckpointType.Snapshot)] public async Task AsyncRecoveryTest1(CheckpointType checkpointType) { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest2.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/SimpleRecoveryTest2.log", deleteOnClose: true); - Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints4"); + Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "/checkpoints4"); fht1 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, PageSizeBits = 10, MemorySizeBits = 13 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = checkpointType } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints4", CheckPointType = checkpointType } ); fht2 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, PageSizeBits = 10, MemorySizeBits = 13 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = checkpointType } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints4", CheckPointType = checkpointType } ); int numOps = 5000; @@ -107,7 +107,7 @@ public async Task AsyncRecoveryTest1(CheckpointType checkpointType) fht2.Dispose(); log.Dispose(); - new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints4").Delete(true); + new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "/checkpoints4").Delete(true); } } diff --git a/cs/test/BasicDiskFASTERTests.cs b/cs/test/BasicDiskFASTERTests.cs index 2e2952b69..c45bc89d4 100644 --- a/cs/test/BasicDiskFASTERTests.cs +++ b/cs/test/BasicDiskFASTERTests.cs @@ -25,7 +25,7 @@ internal class BasicStorageFASTERTests [Test] public void LocalStorageWriteRead() { - TestDeviceWriteRead(Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BasicDiskFASTERTests.log", deleteOnClose: true)); + TestDeviceWriteRead(Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BasicDiskFASTERTests.log", deleteOnClose: true)); } [Test] @@ -39,7 +39,7 @@ public void PageBlobWriteRead() public void TieredWriteRead() { IDevice tested; - IDevice localDevice = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BasicDiskFASTERTests.log", deleteOnClose: true, capacity: 1 << 30); + IDevice localDevice = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BasicDiskFASTERTests.log", deleteOnClose: true, capacity: 1 << 30); if ("yes".Equals(Environment.GetEnvironmentVariable("RunAzureTests"))) { IDevice cloudDevice = new AzureStorageDevice(EMULATED_STORAGE_STRING, TEST_CONTAINER, "TieredWriteRead", "BasicDiskFASTERTests"); @@ -48,7 +48,7 @@ public void TieredWriteRead() else { // If no Azure is enabled, just use another disk - IDevice localDevice2 = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BasicDiskFASTERTests2.log", deleteOnClose: true, capacity: 1 << 30); + IDevice localDevice2 = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BasicDiskFASTERTests2.log", deleteOnClose: true, capacity: 1 << 30); tested = new TieredStorageDevice(1, localDevice, localDevice2); } @@ -58,8 +58,8 @@ public void TieredWriteRead() [Test] public void ShardedWriteRead() { - IDevice localDevice1 = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BasicDiskFASTERTests1.log", deleteOnClose: true, capacity: 1 << 30); - IDevice localDevice2 = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BasicDiskFASTERTests2.log", deleteOnClose: true, capacity: 1 << 30); + IDevice localDevice1 = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BasicDiskFASTERTests1.log", deleteOnClose: true, capacity: 1 << 30); + IDevice localDevice2 = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BasicDiskFASTERTests2.log", deleteOnClose: true, capacity: 1 << 30); var device = new ShardedStorageDevice(new UniformPartitionScheme(512, localDevice1, localDevice2)); TestDeviceWriteRead(device); } diff --git a/cs/test/BasicFASTERTests.cs b/cs/test/BasicFASTERTests.cs index 60ec59646..8e47f479e 100644 --- a/cs/test/BasicFASTERTests.cs +++ b/cs/test/BasicFASTERTests.cs @@ -24,7 +24,7 @@ internal class BasicFASTERTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/hlog1.log", deleteOnClose: true); fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 29 }); session = fht.For(new Functions()).NewSession(); diff --git a/cs/test/BlittableIterationTests.cs b/cs/test/BlittableIterationTests.cs index 09f9a282f..50d01c81a 100644 --- a/cs/test/BlittableIterationTests.cs +++ b/cs/test/BlittableIterationTests.cs @@ -23,7 +23,7 @@ internal class BlittableIterationTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BlittableIterationTests.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BlittableIterationTests.log", deleteOnClose: true); fht = new FasterKV (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 7 }); } diff --git a/cs/test/BlittableLogCompactionTests.cs b/cs/test/BlittableLogCompactionTests.cs index 976214300..8a57dcddb 100644 --- a/cs/test/BlittableLogCompactionTests.cs +++ b/cs/test/BlittableLogCompactionTests.cs @@ -23,7 +23,7 @@ internal class BlittableLogCompactionTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BlittableLogCompactionTests.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BlittableLogCompactionTests.log", deleteOnClose: true); fht = new FasterKV (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 7 }); } diff --git a/cs/test/BlittableLogScanTests.cs b/cs/test/BlittableLogScanTests.cs index 9977876f0..3599041fe 100644 --- a/cs/test/BlittableLogScanTests.cs +++ b/cs/test/BlittableLogScanTests.cs @@ -24,7 +24,7 @@ internal class BlittableFASTERScanTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\BlittableFASTERScanTests.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/BlittableFASTERScanTests.log", deleteOnClose: true); fht = new FasterKV (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 7 }); } diff --git a/cs/test/ComponentRecoveryTests.cs b/cs/test/ComponentRecoveryTests.cs index 26301c967..0fbbe006a 100644 --- a/cs/test/ComponentRecoveryTests.cs +++ b/cs/test/ComponentRecoveryTests.cs @@ -16,7 +16,7 @@ private static unsafe void Setup_MallocFixedPageSizeRecoveryTest(out int seed, o { seed = 123; var rand1 = new Random(seed); - device = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\MallocFixedPageSizeRecoveryTest.dat", deleteOnClose: true); + device = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/MallocFixedPageSizeRecoveryTest.dat", deleteOnClose: true); var allocator = new MallocFixedPageSize(); //do something @@ -89,8 +89,8 @@ private static unsafe void Setup_FuzzyIndexRecoveryTest(out int seed, out int si seed = 123; size = 1 << 16; numAdds = 1 << 18; - ht_device = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\TestFuzzyIndexRecoveryht.dat", deleteOnClose: true); - ofb_device = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\TestFuzzyIndexRecoveryofb.dat", deleteOnClose: true); + ht_device = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/TestFuzzyIndexRecoveryht.dat", deleteOnClose: true); + ofb_device = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/TestFuzzyIndexRecoveryofb.dat", deleteOnClose: true); hash_table1 = new FasterBase(); hash_table1.Initialize(size, 512); diff --git a/cs/test/DeviceFasterLogTests.cs b/cs/test/DeviceFasterLogTests.cs index ebfde57b3..aafee92f0 100644 --- a/cs/test/DeviceFasterLogTests.cs +++ b/cs/test/DeviceFasterLogTests.cs @@ -2,10 +2,8 @@ // Licensed under the MIT license. using System; -using System.IO; +using System.Buffers; using System.Linq; -using System.Security.AccessControl; -using System.Threading; using System.Threading.Tasks; using FASTER.core; using FASTER.devices; @@ -24,7 +22,7 @@ internal class DeviceFasterLogTests public const string TEST_CONTAINER = "test"; [Test] - public void PageBlobFasterLogTest1([Values] LogChecksumType logChecksum) + public async ValueTask PageBlobFasterLogTest1([Values] LogChecksumType logChecksum, [Values]FasterLogTests.IteratorType iteratorType) { if ("yes".Equals(Environment.GetEnvironmentVariable("RunAzureTests"))) { @@ -32,14 +30,14 @@ public void PageBlobFasterLogTest1([Values] LogChecksumType logChecksum) var checkpointManager = new DeviceLogCommitCheckpointManager( new AzureStorageNamedDeviceFactory(EMULATED_STORAGE_STRING), new DefaultCheckpointNamingScheme($"{TEST_CONTAINER}/PageBlobFasterLogTest1")); - FasterLogTest1(logChecksum, device, checkpointManager); + await FasterLogTest1(logChecksum, device, checkpointManager, iteratorType); device.Dispose(); checkpointManager.PurgeAll(); checkpointManager.Dispose(); } } - private void FasterLogTest1(LogChecksumType logChecksum, IDevice device, ILogCommitManager logCommitManager) + private async ValueTask FasterLogTest1(LogChecksumType logChecksum, IDevice device, ILogCommitManager logCommitManager, FasterLogTests.IteratorType iteratorType) { log = new FasterLog(new FasterLogSettings { PageSizeBits = 20, SegmentSizeBits = 20, LogDevice = device, LogChecksum = logChecksum, LogCommitManager = logCommitManager }); @@ -55,15 +53,49 @@ private void FasterLogTest1(LogChecksumType logChecksum, IDevice device, ILogCom using (var iter = log.Scan(0, long.MaxValue)) { - int count = 0; - while (iter.GetNext(out byte[] result, out int length, out long currentAddress)) + var counter = new FasterLogTests.Counter(log); + + switch (iteratorType) { - count++; - Assert.IsTrue(result.SequenceEqual(entry)); - if (count % 100 == 0) - log.TruncateUntil(iter.NextAddress); + case FasterLogTests.IteratorType.AsyncByteVector: + await foreach ((byte[] result, _, _, long nextAddress) in iter.GetAsyncEnumerable()) + { + Assert.IsTrue(result.SequenceEqual(entry)); + counter.IncrementAndMaybeTruncateUntil(nextAddress); + + // MoveNextAsync() would hang at TailAddress, waiting for more entries (that we don't add). + // Note: If this happens and the test has to be canceled, there may be a leftover blob from the log.Commit(), because + // the log device isn't Dispose()d; the symptom is currently a numeric string format error in DefaultCheckpointNamingScheme. + if (nextAddress == log.TailAddress) + break; + } + break; + case FasterLogTests.IteratorType.AsyncMemoryOwner: + await foreach ((IMemoryOwner result, int _, long _, long nextAddress) in iter.GetAsyncEnumerable(MemoryPool.Shared)) + { + Assert.IsTrue(result.Memory.Span.ToArray().Take(entry.Length).SequenceEqual(entry)); + result.Dispose(); + counter.IncrementAndMaybeTruncateUntil(nextAddress); + + // MoveNextAsync() would hang at TailAddress, waiting for more entries (that we don't add). + // Note: If this happens and the test has to be canceled, there may be a leftover blob from the log.Commit(), because + // the log device isn't Dispose()d; the symptom is currently a numeric string format error in DefaultCheckpointNamingScheme. + if (nextAddress == log.TailAddress) + break; + } + break; + case FasterLogTests.IteratorType.Sync: + while (iter.GetNext(out byte[] result, out _, out _)) + { + Assert.IsTrue(result.SequenceEqual(entry)); + counter.IncrementAndMaybeTruncateUntil(iter.NextAddress); + } + break; + default: + Assert.Fail("Unknown IteratorType"); + break; } - Assert.IsTrue(count == numEntries); + Assert.IsTrue(counter.count == numEntries); } log.Dispose(); diff --git a/cs/test/FASTER.test.csproj b/cs/test/FASTER.test.csproj index d291270a6..220e97104 100644 --- a/cs/test/FASTER.test.csproj +++ b/cs/test/FASTER.test.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp3.1 + netcoreapp3.1;netcoreapp2.1;net461 AnyCPU;x64 true 8 @@ -34,10 +34,6 @@ bin\$(Platform)\Release\ - - $(DefineConstants);DOTNETCORE - - 1701;1702;1591 diff --git a/cs/test/FasterLogResumeTests.cs b/cs/test/FasterLogResumeTests.cs index 43529ff6b..deb172d1d 100644 --- a/cs/test/FasterLogResumeTests.cs +++ b/cs/test/FasterLogResumeTests.cs @@ -19,7 +19,7 @@ internal class FasterLogResumeTests [SetUp] public void Setup() { - commitPath = TestContext.CurrentContext.TestDirectory + "\\" + TestContext.CurrentContext.Test.Name + "\\"; + commitPath = TestContext.CurrentContext.TestDirectory + "/" + TestContext.CurrentContext.Test.Name + "/"; if (Directory.Exists(commitPath)) DeleteDirectory(commitPath); @@ -51,22 +51,18 @@ public async Task FasterLogResumePersistedReaderSpec([Values] LogChecksumType lo await l.EnqueueAsync(input3); await l.CommitAsync(); - using (var originalIterator = l.Scan(0, long.MaxValue, readerName)) - { - originalIterator.GetNext(out _, out _, out _, out long recoveryAddress); - originalIterator.CompleteUntil(recoveryAddress); - originalIterator.GetNext(out _, out _, out _, out _); // move the reader ahead - await l.CommitAsync(); - } + using var originalIterator = l.Scan(0, long.MaxValue, readerName); + Assert.IsTrue(originalIterator.GetNext(out _, out _, out _, out long recoveryAddress)); + originalIterator.CompleteUntil(recoveryAddress); + Assert.IsTrue(originalIterator.GetNext(out _, out _, out _, out _)); // move the reader ahead + await l.CommitAsync(); } using (var l = new FasterLog(new FasterLogSettings { LogDevice = device, PageSizeBits = 16, MemorySizeBits = 16, LogChecksum = logChecksum, LogCommitFile = commitPath })) { - using (var recoveredIterator = l.Scan(0, long.MaxValue, readerName)) - { - recoveredIterator.GetNext(out byte[] outBuf, out _, out _, out _); - Assert.True(input2.SequenceEqual(outBuf)); // we should have read in input2, not input1 or input3 - } + using var recoveredIterator = l.Scan(0, long.MaxValue, readerName); + Assert.IsTrue(recoveredIterator.GetNext(out byte[] outBuf, out _, out _, out _)); + Assert.True(input2.SequenceEqual(outBuf)); // we should have read in input2, not input1 or input3 } } @@ -92,27 +88,23 @@ public async Task FasterLogResumePersistedReader2([Values] LogChecksumType logCh await l.EnqueueAsync(input3); await l.CommitAsync(); - using (var originalIterator = l.Scan(0, long.MaxValue, readerName)) - { - originalIterator.GetNext(out _, out _, out _, out long recoveryAddress); - originalIterator.CompleteUntil(recoveryAddress); - originalIterator.GetNext(out _, out _, out _, out _); // move the reader ahead - await l.CommitAsync(); - originalCompleted = originalIterator.CompletedUntilAddress; - } + using var originalIterator = l.Scan(0, long.MaxValue, readerName); + Assert.IsTrue(originalIterator.GetNext(out _, out _, out _, out long recoveryAddress)); + originalIterator.CompleteUntil(recoveryAddress); + Assert.IsTrue(originalIterator.GetNext(out _, out _, out _, out _)); // move the reader ahead + await l.CommitAsync(); + originalCompleted = originalIterator.CompletedUntilAddress; } using (var l = new FasterLog(new FasterLogSettings { LogDevice = device, PageSizeBits = 16, MemorySizeBits = 16, LogChecksum = logChecksum, LogCommitManager = logCommitManager })) { - using (var recoveredIterator = l.Scan(0, long.MaxValue, readerName)) - { - recoveredIterator.GetNext(out byte[] outBuf, out _, out _, out _); + using var recoveredIterator = l.Scan(0, long.MaxValue, readerName); + Assert.IsTrue(recoveredIterator.GetNext(out byte[] outBuf, out _, out _, out _)); - // we should have read in input2, not input1 or input3 - Assert.True(input2.SequenceEqual(outBuf), $"Original: {input2[0]}, Recovered: {outBuf[0]}, Original: {originalCompleted}, Recovered: {recoveredIterator.CompletedUntilAddress}"); + // we should have read in input2, not input1 or input3 + Assert.True(input2.SequenceEqual(outBuf), $"Original: {input2[0]}, Recovered: {outBuf[0]}, Original: {originalCompleted}, Recovered: {recoveredIterator.CompletedUntilAddress}"); - // TestContext.Progress.WriteLine($"Original: {originalCompleted}, Recovered: {recoveredIterator.CompletedUntilAddress}"); - } + // TestContext.Progress.WriteLine($"Original: {originalCompleted}, Recovered: {recoveredIterator.CompletedUntilAddress}"); } } } diff --git a/cs/test/FasterLogTests.cs b/cs/test/FasterLogTests.cs index 75b5eec8e..b6d3b952f 100644 --- a/cs/test/FasterLogTests.cs +++ b/cs/test/FasterLogTests.cs @@ -2,9 +2,10 @@ // Licensed under the MIT license. using System; +using System.Buffers; +using System.Collections.Generic; using System.IO; using System.Linq; -using System.Security.AccessControl; using System.Threading; using System.Threading.Tasks; using FASTER.core; @@ -12,7 +13,6 @@ namespace FASTER.test { - [TestFixture] internal class FasterLogTests { @@ -26,7 +26,7 @@ internal class FasterLogTests [SetUp] public void Setup() { - commitPath = TestContext.CurrentContext.TestDirectory + "\\" + TestContext.CurrentContext.Test.Name + "\\"; + commitPath = TestContext.CurrentContext.TestDirectory + "/" + TestContext.CurrentContext.Test.Name + "/"; if (Directory.Exists(commitPath)) DeleteDirectory(commitPath); @@ -45,8 +45,74 @@ public void TearDown() DeleteDirectory(commitPath); } + internal class Counter + { + internal int count; + private readonly FasterLog log; + + internal Counter(FasterLog fasterLog) + { + this.count = 0; + this.log = fasterLog; + } + + internal void IncrementAndMaybeTruncateUntil(long nextAddr) + { + this.count++; + if (this.count % 100 == 0) + this.log.TruncateUntil(nextAddr); + } + + public override string ToString() => $"{this.count}"; + } + + public enum IteratorType + { + AsyncByteVector, + AsyncMemoryOwner, + Sync + } + + private static bool IsAsync(IteratorType iterType) => iterType == IteratorType.AsyncByteVector || iterType == IteratorType.AsyncMemoryOwner; + + private async ValueTask AssertGetNext(IAsyncEnumerator<(byte[] entry, int entryLength, long currentAddress, long nextAddress)> asyncByteVectorIter, + IAsyncEnumerator<(IMemoryOwner entry, int entryLength, long currentAddress, long nextAddress)> asyncMemoryOwnerIter, + FasterLogScanIterator iter, byte[] expectedData = default, bool verifyAtEnd = false) + { + if (asyncByteVectorIter is {}) + { + Assert.IsTrue(await asyncByteVectorIter.MoveNextAsync()); + if (expectedData is {}) + Assert.IsTrue(asyncByteVectorIter.Current.entry.SequenceEqual(expectedData)); + + // MoveNextAsync() would hang here waiting for more entries + if (verifyAtEnd) + Assert.IsTrue(asyncByteVectorIter.Current.nextAddress == log.TailAddress); + return; + } + + if (asyncMemoryOwnerIter is {}) + { + Assert.IsTrue(await asyncMemoryOwnerIter.MoveNextAsync()); + if (expectedData is {}) + Assert.IsTrue(asyncMemoryOwnerIter.Current.entry.Memory.Span.ToArray().Take(expectedData.Length).SequenceEqual(expectedData)); + asyncMemoryOwnerIter.Current.entry.Dispose(); + + // MoveNextAsync() would hang here waiting for more entries + if (verifyAtEnd) + Assert.IsTrue(asyncMemoryOwnerIter.Current.nextAddress == log.TailAddress); + return; + } + + Assert.IsTrue(iter.GetNext(out byte[] result, out _, out _)); + if (expectedData is {}) + Assert.IsTrue(result.SequenceEqual(expectedData)); + if (verifyAtEnd) + Assert.IsFalse(iter.GetNext(out _, out _, out _)); + } + [Test] - public void FasterLogTest1([Values]LogChecksumType logChecksum) + public async ValueTask FasterLogTest1([Values]LogChecksumType logChecksum, [Values]IteratorType iteratorType) { log = new FasterLog(new FasterLogSettings { LogDevice = device, LogChecksum = logChecksum, LogCommitManager = manager }); @@ -60,31 +126,58 @@ public void FasterLogTest1([Values]LogChecksumType logChecksum) } log.Commit(true); - using (var iter = log.Scan(0, long.MaxValue)) + // If endAddress > log.TailAddress then GetAsyncEnumerable() will wait until more entries are added. + var endAddress = IsAsync(iteratorType) ? log.TailAddress : long.MaxValue; + using (var iter = log.Scan(0, endAddress)) { - int count = 0; - while (iter.GetNext(out byte[] result, out _, out _)) + var counter = new Counter(log); + switch (iteratorType) { - count++; - Assert.IsTrue(result.SequenceEqual(entry)); - if (count % 100 == 0) - log.TruncateUntil(iter.NextAddress); + case IteratorType.AsyncByteVector: + await foreach ((byte[] result, int _, long _, long nextAddress) in iter.GetAsyncEnumerable()) + { + Assert.IsTrue(result.SequenceEqual(entry)); + counter.IncrementAndMaybeTruncateUntil(nextAddress); + } + break; + case IteratorType.AsyncMemoryOwner: + await foreach ((IMemoryOwner result, int _, long _, long nextAddress) in iter.GetAsyncEnumerable(MemoryPool.Shared)) + { + Assert.IsTrue(result.Memory.Span.ToArray().Take(entry.Length).SequenceEqual(entry)); + result.Dispose(); + counter.IncrementAndMaybeTruncateUntil(nextAddress); + } + break; + case IteratorType.Sync: + while (iter.GetNext(out byte[] result, out _, out _)) + { + Assert.IsTrue(result.SequenceEqual(entry)); + counter.IncrementAndMaybeTruncateUntil(iter.NextAddress); + } + break; + default: + Assert.Fail("Unknown IteratorType"); + break; } - Assert.IsTrue(count == numEntries); + Assert.IsTrue(counter.count == numEntries); } log.Dispose(); } [Test] - public async Task FasterLogTest2([Values]LogChecksumType logChecksum) + public async ValueTask FasterLogTest2([Values]LogChecksumType logChecksum, [Values]IteratorType iteratorType) { log = new FasterLog(new FasterLogSettings { LogDevice = device, LogChecksum = logChecksum, LogCommitManager = manager }); - byte[] data1 = new byte[10000]; - for (int i = 0; i < 10000; i++) data1[i] = (byte)i; + + const int dataLength = 10000; + byte[] data1 = new byte[dataLength]; + for (int i = 0; i < dataLength; i++) data1[i] = (byte)i; using (var iter = log.Scan(0, long.MaxValue, scanBufferingMode: ScanBufferingMode.SinglePageBuffering)) { + var asyncByteVectorIter = iteratorType == IteratorType.AsyncByteVector ? iter.GetAsyncEnumerable().GetAsyncEnumerator() : default; + var asyncMemoryOwnerIter = iteratorType == IteratorType.AsyncMemoryOwner ? iter.GetAsyncEnumerable(MemoryPool.Shared).GetAsyncEnumerator() : default; int i = 0; while (i++ < 500) { @@ -107,19 +200,14 @@ public async Task FasterLogTest2([Values]LogChecksumType logChecksum) while (!waitingReader.IsCompleted) ; Assert.IsTrue(waitingReader.IsCompleted); - var curr = iter.GetNext(out byte[] result, out _, out _); - Assert.IsTrue(curr); - Assert.IsTrue(result.SequenceEqual(data1)); - - var next = iter.GetNext(out _, out _, out _); - Assert.IsFalse(next); + await AssertGetNext(asyncByteVectorIter, asyncMemoryOwnerIter, iter, data1, verifyAtEnd :true); } } log.Dispose(); } [Test] - public async Task FasterLogTest3([Values]LogChecksumType logChecksum) + public async ValueTask FasterLogTest3([Values]LogChecksumType logChecksum, [Values]IteratorType iteratorType) { log = new FasterLog(new FasterLogSettings { LogDevice = device, PageSizeBits = 14, LogChecksum = logChecksum, LogCommitManager = manager }); byte[] data1 = new byte[10000]; @@ -127,38 +215,73 @@ public async Task FasterLogTest3([Values]LogChecksumType logChecksum) using (var iter = log.Scan(0, long.MaxValue, scanBufferingMode: ScanBufferingMode.SinglePageBuffering)) { + var asyncByteVectorIter = iteratorType == IteratorType.AsyncByteVector ? iter.GetAsyncEnumerable().GetAsyncEnumerator() : default; + var asyncMemoryOwnerIter = iteratorType == IteratorType.AsyncMemoryOwner ? iter.GetAsyncEnumerable(MemoryPool.Shared).GetAsyncEnumerator() : default; + var appendResult = log.TryEnqueue(data1, out _); Assert.IsTrue(appendResult); await log.CommitAsync(); await iter.WaitAsync(); - var iterResult = iter.GetNext(out byte[] entry, out _, out _); - Assert.IsTrue(iterResult); + await AssertGetNext(asyncByteVectorIter, asyncMemoryOwnerIter, iter, data1); + + // This will fail due to page overflow, leaving a "hole" appendResult = log.TryEnqueue(data1, out _); Assert.IsFalse(appendResult); await iter.WaitAsync(); - // Should read the "hole" and return false - iterResult = iter.GetNext(out entry, out _, out _); - Assert.IsFalse(iterResult); - - // Should wait for next item - var task = iter.WaitAsync(); - Assert.IsFalse(task.IsCompleted); - - appendResult = log.TryEnqueue(data1, out _); - Assert.IsTrue(appendResult); - await log.CommitAsync(); + async Task retryAppend(bool waitTaskIsCompleted) + { + Assert.IsFalse(waitTaskIsCompleted); + Assert.IsTrue(log.TryEnqueue(data1, out _)); + await log.CommitAsync(); + } - await task; - iterResult = iter.GetNext(out entry, out _, out _); - Assert.IsTrue(iterResult); + switch (iteratorType) + { + case IteratorType.Sync: + // Should read the "hole" and return false + Assert.IsFalse(iter.GetNext(out _, out _, out _)); + + // Should wait for next item + var task = iter.WaitAsync(); + await retryAppend(task.IsCompleted); + await task; + + // Now the data is available. + Assert.IsTrue(iter.GetNext(out _, out _, out _)); + break; + case IteratorType.AsyncByteVector: + { + // Because we have a hole, awaiting MoveNextAsync would hang; instead, hold onto the task that results from WaitAsync() inside MoveNextAsync(). + var moveNextTask = asyncByteVectorIter.MoveNextAsync(); + await retryAppend(moveNextTask.IsCompleted); + + // Now the data is available. + Assert.IsTrue(await moveNextTask); + } + break; + case IteratorType.AsyncMemoryOwner: + { + // Because we have a hole, awaiting MoveNextAsync would hang; instead, hold onto the task that results from WaitAsync() inside MoveNextAsync(). + var moveNextTask = asyncMemoryOwnerIter.MoveNextAsync(); + await retryAppend(moveNextTask.IsCompleted); + + // Now the data is available, and must be disposed. + Assert.IsTrue(await moveNextTask); + asyncMemoryOwnerIter.Current.entry.Dispose(); + } + break; + default: + Assert.Fail("Unknown IteratorType"); + break; + } } log.Dispose(); } [Test] - public async Task FasterLogTest4([Values]LogChecksumType logChecksum) + public async ValueTask FasterLogTest4([Values]LogChecksumType logChecksum, [Values]IteratorType iteratorType) { log = new FasterLog(new FasterLogSettings { LogDevice = device, PageSizeBits = 14, LogChecksum = logChecksum, LogCommitManager = manager }); byte[] data1 = new byte[100]; @@ -177,8 +300,11 @@ public async Task FasterLogTest4([Values]LogChecksumType logChecksum) using (var iter = log.Scan(0, long.MaxValue)) { - // Should read the "hole" and return false - var iterResult = iter.GetNext(out byte[] entry, out _, out _); + var asyncByteVectorIter = iteratorType == IteratorType.AsyncByteVector ? iter.GetAsyncEnumerable().GetAsyncEnumerator() : default; + var asyncMemoryOwnerIter = iteratorType == IteratorType.AsyncMemoryOwner ? iter.GetAsyncEnumerable(MemoryPool.Shared).GetAsyncEnumerator() : default; + + await AssertGetNext(asyncByteVectorIter, asyncMemoryOwnerIter, iter, data1); + log.TruncateUntil(iter.NextAddress); Assert.IsTrue(log.CommittedUntilAddress == log.TailAddress); @@ -194,7 +320,7 @@ public async Task FasterLogTest4([Values]LogChecksumType logChecksum) } [Test] - public async Task FasterLogTest5([Values]LogChecksumType logChecksum) + public async ValueTask FasterLogTest5([Values]LogChecksumType logChecksum) { log = new FasterLog(new FasterLogSettings { LogDevice = device, PageSizeBits = 16, MemorySizeBits = 16, LogChecksum = logChecksum, LogCommitManager = manager }); @@ -226,7 +352,7 @@ public async Task FasterLogTest5([Values]LogChecksumType logChecksum) } [Test] - public void FasterLogTest6([Values] LogChecksumType logChecksum) + public async ValueTask FasterLogTest6([Values] LogChecksumType logChecksum, [Values]IteratorType iteratorType) { log = new FasterLog(new FasterLogSettings { LogDevice = device, MemorySizeBits = 20, PageSizeBits = 14, LogChecksum = logChecksum, LogCommitManager = manager }); byte[] data1 = new byte[1000]; @@ -243,15 +369,48 @@ public void FasterLogTest6([Values] LogChecksumType logChecksum) using (var iter = log.Scan(0, long.MaxValue, scanUncommitted: true)) { - while (iter.GetNext(out _, out _, out _)) + var asyncByteVectorIter = iteratorType == IteratorType.AsyncByteVector ? iter.GetAsyncEnumerable().GetAsyncEnumerator() : default; + var asyncMemoryOwnerIter = iteratorType == IteratorType.AsyncMemoryOwner ? iter.GetAsyncEnumerable(MemoryPool.Shared).GetAsyncEnumerator() : default; + + switch (iteratorType) { - log.TruncateUntil(iter.NextAddress); + case IteratorType.Sync: + while (iter.GetNext(out _, out _, out _)) + log.TruncateUntil(iter.NextAddress); + Assert.IsTrue(iter.NextAddress == log.SafeTailAddress); + break; + case IteratorType.AsyncByteVector: + { + while (await asyncByteVectorIter.MoveNextAsync() && asyncByteVectorIter.Current.nextAddress != log.SafeTailAddress) + log.TruncateUntil(asyncByteVectorIter.Current.nextAddress); + } + break; + case IteratorType.AsyncMemoryOwner: + { + while (await asyncMemoryOwnerIter.MoveNextAsync()) { + log.TruncateUntil(asyncMemoryOwnerIter.Current.nextAddress); + asyncMemoryOwnerIter.Current.entry.Dispose(); + if (asyncMemoryOwnerIter.Current.nextAddress == log.SafeTailAddress) + break; + } + } + break; + default: + Assert.Fail("Unknown IteratorType"); + break; } - Assert.IsTrue(iter.NextAddress == log.SafeTailAddress); + + // Enqueue data but do not make it visible log.Enqueue(data1); - Assert.IsFalse(iter.GetNext(out _, out _, out _)); + + // Do this only for sync; MoveNextAsync() would hang here waiting for more entries. + if (!IsAsync(iteratorType)) + Assert.IsFalse(iter.GetNext(out _, out _, out _)); + + // Make the data visible log.RefreshUncommitted(); - Assert.IsTrue(iter.GetNext(out _, out _, out _)); + + await AssertGetNext(asyncByteVectorIter, asyncMemoryOwnerIter, iter, data1, verifyAtEnd: true); } log.Dispose(); } @@ -284,6 +443,5 @@ private static void DeleteDirectory(string path) catch { } } } - } } diff --git a/cs/test/FunctionPerSessionTests.cs b/cs/test/FunctionPerSessionTests.cs index d90cd75e8..3614e1ab3 100644 --- a/cs/test/FunctionPerSessionTests.cs +++ b/cs/test/FunctionPerSessionTests.cs @@ -107,7 +107,7 @@ public class FunctionPerSessionTests [SetUp] public void Setup() { - _log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\FunctionPerSessionTests1.log", deleteOnClose: true); + _log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/FunctionPerSessionTests1.log", deleteOnClose: true); _faster = new FasterKV(128, new LogSettings() { diff --git a/cs/test/GenericByteArrayTests.cs b/cs/test/GenericByteArrayTests.cs index cfdbbf0d9..f05d86f67 100644 --- a/cs/test/GenericByteArrayTests.cs +++ b/cs/test/GenericByteArrayTests.cs @@ -19,8 +19,8 @@ internal class GenericByteArrayTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericStringTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericStringTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericStringTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericStringTests.obj.log", deleteOnClose: true); fht = new FasterKV( diff --git a/cs/test/GenericDiskDeleteTests.cs b/cs/test/GenericDiskDeleteTests.cs index 8a86e6279..0e6d64a46 100644 --- a/cs/test/GenericDiskDeleteTests.cs +++ b/cs/test/GenericDiskDeleteTests.cs @@ -17,8 +17,8 @@ internal class GenericDiskDeleteTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericDiskDeleteTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericDiskDeleteTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericDiskDeleteTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericDiskDeleteTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, diff --git a/cs/test/GenericIterationTests.cs b/cs/test/GenericIterationTests.cs index a45517e82..5b66a1096 100644 --- a/cs/test/GenericIterationTests.cs +++ b/cs/test/GenericIterationTests.cs @@ -24,8 +24,8 @@ internal class GenericIterationTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericIterationTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericIterationTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericIterationTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericIterationTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, diff --git a/cs/test/GenericLogCompactionTests.cs b/cs/test/GenericLogCompactionTests.cs index ecd02aa55..1124373c7 100644 --- a/cs/test/GenericLogCompactionTests.cs +++ b/cs/test/GenericLogCompactionTests.cs @@ -24,8 +24,8 @@ internal class GenericLogCompactionTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericLogCompactionTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericLogCompactionTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericLogCompactionTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericLogCompactionTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, diff --git a/cs/test/GenericLogScanTests.cs b/cs/test/GenericLogScanTests.cs index 0cad439ea..cf3c3c9f9 100644 --- a/cs/test/GenericLogScanTests.cs +++ b/cs/test/GenericLogScanTests.cs @@ -24,8 +24,8 @@ internal class GenericFASTERScanTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericFASTERScanTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericFASTERScanTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericFASTERScanTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericFASTERScanTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, diff --git a/cs/test/GenericStringTests.cs b/cs/test/GenericStringTests.cs index c268b0be1..fb809ccd9 100644 --- a/cs/test/GenericStringTests.cs +++ b/cs/test/GenericStringTests.cs @@ -18,8 +18,8 @@ internal class GenericStringTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericStringTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\GenericStringTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericStringTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/GenericStringTests.obj.log", deleteOnClose: true); fht = new FasterKV( diff --git a/cs/test/LargeObjectTests.cs b/cs/test/LargeObjectTests.cs index 0f5333c44..548edec4c 100644 --- a/cs/test/LargeObjectTests.cs +++ b/cs/test/LargeObjectTests.cs @@ -27,7 +27,7 @@ public void Setup() { if (test_path == null) { - test_path = TestContext.CurrentContext.TestDirectory + "\\" + Path.GetRandomFileName(); + test_path = TestContext.CurrentContext.TestDirectory + "/" + Path.GetRandomFileName(); if (!Directory.Exists(test_path)) Directory.CreateDirectory(test_path); } @@ -67,8 +67,8 @@ public void LargeObjectTest(CheckpointType checkpointType) MyInput input = default; MyLargeOutput output = new MyLargeOutput(); - log = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.log"); - objlog = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.obj.log"); + log = Devices.CreateLogDevice(test_path + "/LargeObjectTest.log"); + objlog = Devices.CreateLogDevice(test_path + "/LargeObjectTest.obj.log"); fht1 = new FasterKV (128, @@ -96,8 +96,8 @@ public void LargeObjectTest(CheckpointType checkpointType) log.Dispose(); objlog.Dispose(); - log = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.log"); - objlog = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.obj.log"); + log = Devices.CreateLogDevice(test_path + "/LargeObjectTest.log"); + objlog = Devices.CreateLogDevice(test_path + "/LargeObjectTest.obj.log"); fht2 = new FasterKV (128, diff --git a/cs/test/MemoryLogCompactionTests.cs b/cs/test/MemoryLogCompactionTests.cs index 346d3b094..d10b24d5a 100644 --- a/cs/test/MemoryLogCompactionTests.cs +++ b/cs/test/MemoryLogCompactionTests.cs @@ -19,7 +19,7 @@ internal class MemoryLogCompactionTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\MemoryLogCompactionTests1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/MemoryLogCompactionTests1.log", deleteOnClose: true); fht = new FasterKV, Memory> (1L << 20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 12 }); } diff --git a/cs/test/MiscFASTERTests.cs b/cs/test/MiscFASTERTests.cs index 607c7172b..8cc815452 100644 --- a/cs/test/MiscFASTERTests.cs +++ b/cs/test/MiscFASTERTests.cs @@ -23,8 +23,8 @@ internal class MiscFASTERTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\MiscFASTERTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\MiscFASTERTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/MiscFASTERTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/MiscFASTERTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, @@ -115,7 +115,7 @@ public void ShouldCreateNewRecordIfConcurrentWriterReturnsFalse() var log = default(IDevice); try { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/hlog1.log", deleteOnClose: true); using var fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 29 }); using var session = fht.NewSession(copyOnWrite); diff --git a/cs/test/NativeReadCacheTests.cs b/cs/test/NativeReadCacheTests.cs index 3f48f3f38..a4967effe 100644 --- a/cs/test/NativeReadCacheTests.cs +++ b/cs/test/NativeReadCacheTests.cs @@ -24,7 +24,7 @@ internal class NativeReadCacheTests public void Setup() { var readCacheSettings = new ReadCacheSettings { MemorySizeBits = 15, PageSizeBits = 10 }; - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\NativeReadCacheTests.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/NativeReadCacheTests.log", deleteOnClose: true); fht = new FasterKV (1L<<20, new LogSettings { LogDevice = log, MemorySizeBits = 15, PageSizeBits = 10, ReadCacheSettings = readCacheSettings }); } diff --git a/cs/test/NeedCopyUpdateTests.cs b/cs/test/NeedCopyUpdateTests.cs index 40be16b37..05b279753 100644 --- a/cs/test/NeedCopyUpdateTests.cs +++ b/cs/test/NeedCopyUpdateTests.cs @@ -23,8 +23,8 @@ internal class NeedCopyUpdateTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\NeedCopyUpdateTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\NeedCopyUpdateTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/NeedCopyUpdateTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/NeedCopyUpdateTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, diff --git a/cs/test/ObjectFASTERTests.cs b/cs/test/ObjectFASTERTests.cs index af88f08d3..327850291 100644 --- a/cs/test/ObjectFASTERTests.cs +++ b/cs/test/ObjectFASTERTests.cs @@ -23,8 +23,8 @@ internal class ObjectFASTERTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\ObjectFASTERTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\ObjectFASTERTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/ObjectFASTERTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/ObjectFASTERTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, diff --git a/cs/test/ObjectReadCacheTests.cs b/cs/test/ObjectReadCacheTests.cs index 83311100e..dd39f5a33 100644 --- a/cs/test/ObjectReadCacheTests.cs +++ b/cs/test/ObjectReadCacheTests.cs @@ -17,8 +17,8 @@ internal class ObjectReadCacheTests public void Setup() { var readCacheSettings = new ReadCacheSettings { MemorySizeBits = 15, PageSizeBits = 10 }; - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\ObjectReadCacheTests.log", deleteOnClose: true); - objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\ObjectReadCacheTests.obj.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/ObjectReadCacheTests.log", deleteOnClose: true); + objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/ObjectReadCacheTests.obj.log", deleteOnClose: true); fht = new FasterKV (128, diff --git a/cs/test/ObjectRecoveryTest.cs b/cs/test/ObjectRecoveryTest.cs index f7265379b..4a5c3aec2 100644 --- a/cs/test/ObjectRecoveryTest.cs +++ b/cs/test/ObjectRecoveryTest.cs @@ -33,13 +33,13 @@ public void Setup() { if (test_path == null) { - test_path = TestContext.CurrentContext.TestDirectory + "\\" + Path.GetRandomFileName(); + test_path = TestContext.CurrentContext.TestDirectory + "/" + Path.GetRandomFileName(); if (!Directory.Exists(test_path)) Directory.CreateDirectory(test_path); } - log = Devices.CreateLogDevice(test_path + "\\ObjectRecoveryTests.log", false); - objlog = Devices.CreateLogDevice(test_path + "\\ObjectRecoveryTests.obj.log", false); + log = Devices.CreateLogDevice(test_path + "/ObjectRecoveryTests.log", false); + objlog = Devices.CreateLogDevice(test_path + "/ObjectRecoveryTests.obj.log", false); fht = new FasterKV ( diff --git a/cs/test/ObjectRecoveryTest2.cs b/cs/test/ObjectRecoveryTest2.cs index e478b6511..b6849b9c8 100644 --- a/cs/test/ObjectRecoveryTest2.cs +++ b/cs/test/ObjectRecoveryTest2.cs @@ -18,7 +18,7 @@ public class ObjectRecoveryTests2 [SetUp] public void Setup() { - FasterFolderPath = TestContext.CurrentContext.TestDirectory + "\\" + Path.GetRandomFileName(); + FasterFolderPath = TestContext.CurrentContext.TestDirectory + "/" + Path.GetRandomFileName(); if (!Directory.Exists(FasterFolderPath)) Directory.CreateDirectory(FasterFolderPath); } diff --git a/cs/test/ObjectRecoveryTest3.cs b/cs/test/ObjectRecoveryTest3.cs index 35f1e25cf..01abea530 100644 --- a/cs/test/ObjectRecoveryTest3.cs +++ b/cs/test/ObjectRecoveryTest3.cs @@ -21,7 +21,7 @@ public class ObjectRecoveryTests3 [SetUp] public void Setup() { - FasterFolderPath = TestContext.CurrentContext.TestDirectory + "\\" + Path.GetRandomFileName(); + FasterFolderPath = TestContext.CurrentContext.TestDirectory + "/" + Path.GetRandomFileName(); if (!Directory.Exists(FasterFolderPath)) Directory.CreateDirectory(FasterFolderPath); } diff --git a/cs/test/RecoverContinueTests.cs b/cs/test/RecoverContinueTests.cs index 58b2ff24f..30ebb70b8 100644 --- a/cs/test/RecoverContinueTests.cs +++ b/cs/test/RecoverContinueTests.cs @@ -26,28 +26,28 @@ internal class RecoverContinueTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\RecoverContinueTests.log", deleteOnClose: true); - Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints3"); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/RecoverContinueTests.log", deleteOnClose: true); + Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "/checkpoints3"); fht1 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints3", CheckPointType = CheckpointType.Snapshot } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints3", CheckPointType = CheckpointType.Snapshot } ); fht2 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints3", CheckPointType = CheckpointType.Snapshot } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints3", CheckPointType = CheckpointType.Snapshot } ); fht3 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints3", CheckPointType = CheckpointType.Snapshot } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints3", CheckPointType = CheckpointType.Snapshot } ); numOps = 5000; @@ -63,7 +63,7 @@ public void TearDown() fht2 = null; fht3 = null; log.Dispose(); - Directory.Delete(TestContext.CurrentContext.TestDirectory + "\\checkpoints3", true); + Directory.Delete(TestContext.CurrentContext.TestDirectory + "/checkpoints3", true); } public static void DeleteDirectory(string path) diff --git a/cs/test/RecoveryChecks.cs b/cs/test/RecoveryChecks.cs index b235dc0c1..9422cf902 100644 --- a/cs/test/RecoveryChecks.cs +++ b/cs/test/RecoveryChecks.cs @@ -28,7 +28,7 @@ public void Setup() inputArray[i].adId = i; } - path = TestContext.CurrentContext.TestDirectory + "\\RecoveryChecks\\"; + path = TestContext.CurrentContext.TestDirectory + "/RecoveryChecks/"; log = Devices.CreateLogDevice(path + "hlog.log", deleteOnClose: true); Directory.CreateDirectory(path); fht1 = new FasterKV diff --git a/cs/test/RecoveryTests.cs b/cs/test/RecoveryTests.cs index b8ce9f01a..4b1647c13 100644 --- a/cs/test/RecoveryTests.cs +++ b/cs/test/RecoveryTests.cs @@ -30,12 +30,12 @@ public void Setup() { if (test_path == null) { - test_path = TestContext.CurrentContext.TestDirectory + "\\" + Path.GetRandomFileName(); + test_path = TestContext.CurrentContext.TestDirectory + "/" + Path.GetRandomFileName(); if (!Directory.Exists(test_path)) Directory.CreateDirectory(test_path); } - log = Devices.CreateLogDevice(test_path + "\\FullRecoveryTests.log"); + log = Devices.CreateLogDevice(test_path + "/FullRecoveryTests.log"); fht = new FasterKV (keySpace, diff --git a/cs/test/SessionFASTERTests.cs b/cs/test/SessionFASTERTests.cs index 08441aac8..9418a67d1 100644 --- a/cs/test/SessionFASTERTests.cs +++ b/cs/test/SessionFASTERTests.cs @@ -23,7 +23,7 @@ internal class SessionFASTERTests [SetUp] public void Setup() { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/hlog1.log", deleteOnClose: true); fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 29 }); } diff --git a/cs/test/SharedDirectoryTests.cs b/cs/test/SharedDirectoryTests.cs index 979a696e5..9e37c4a00 100644 --- a/cs/test/SharedDirectoryTests.cs +++ b/cs/test/SharedDirectoryTests.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; namespace FASTER.test.recovery.sumstore @@ -28,9 +29,9 @@ internal class SharedDirectoryTests [SetUp] public void Setup() { - this.rootPath = $"{TestContext.CurrentContext.TestDirectory}\\{Path.GetRandomFileName()}"; + this.rootPath = $"{TestContext.CurrentContext.TestDirectory}/{Path.GetRandomFileName()}"; Directory.CreateDirectory(this.rootPath); - this.sharedLogDirectory = $"{this.rootPath}\\SharedLogs"; + this.sharedLogDirectory = $"{this.rootPath}/SharedLogs"; Directory.CreateDirectory(this.sharedLogDirectory); this.original = new FasterTestInstance(); @@ -54,7 +55,7 @@ public void TearDown() [Test] public async ValueTask SharedLogDirectory([Values]bool isAsync) { - this.original.Initialize($"{this.rootPath}\\OriginalCheckpoint", this.sharedLogDirectory); + this.original.Initialize($"{this.rootPath}/OriginalCheckpoint", this.sharedLogDirectory); Assert.IsTrue(IsDirectoryEmpty(this.sharedLogDirectory)); // sanity check Populate(this.original.Faster); @@ -67,7 +68,7 @@ public async ValueTask SharedLogDirectory([Values]bool isAsync) Test(this.original, checkpointGuid); // Copy checkpoint directory - var cloneCheckpointDirectory = $"{this.rootPath}\\CloneCheckpoint"; + var cloneCheckpointDirectory = $"{this.rootPath}/CloneCheckpoint"; CopyDirectory(new DirectoryInfo(this.original.CheckpointDirectory), new DirectoryInfo(cloneCheckpointDirectory)); // Recover from original checkpoint @@ -82,12 +83,17 @@ public async ValueTask SharedLogDirectory([Values]bool isAsync) Test(this.original, checkpointGuid); Test(this.clone, checkpointGuid); - // Dispose original, files should not be deleted + // Dispose original, files should not be deleted on Windows this.original.TearDown(); - // Clone should still work - Assert.IsFalse(IsDirectoryEmpty(this.sharedLogDirectory)); - Test(this.clone, checkpointGuid); +#if NETCOREAPP + if (RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) +#endif + { + // Clone should still work on Windows + Assert.IsFalse(IsDirectoryEmpty(this.sharedLogDirectory)); + Test(this.clone, checkpointGuid); + } this.clone.TearDown(); @@ -104,11 +110,15 @@ private struct FasterTestInstance public void Initialize(string checkpointDirectory, string logDirectory, bool populateLogHandles = false) { +#if NETCOREAPP + if (!RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) + populateLogHandles = false; +#endif this.CheckpointDirectory = checkpointDirectory; this.LogDirectory = logDirectory; string logFileName = "log"; - string deviceFileName = $"{this.LogDirectory}\\{logFileName}"; + string deviceFileName = $"{this.LogDirectory}/{logFileName}"; KeyValuePair[] initialHandles = null; if (populateLogHandles) { @@ -127,7 +137,17 @@ public void Initialize(string checkpointDirectory, string logDirectory, bool pop } } - this.LogDevice = new LocalStorageDevice(deviceFileName, deleteOnClose: true, disableFileBuffering: false, initialLogFileHandles: initialHandles); +#if NETCOREAPP + if (!RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) + { + this.LogDevice = new ManagedLocalStorageDevice(deviceFileName, deleteOnClose: true); + } + else +#endif + { + this.LogDevice = new LocalStorageDevice(deviceFileName, deleteOnClose: true, disableFileBuffering: false, initialLogFileHandles: initialHandles); + } + this.Faster = new FasterKV( keySpace, new LogSettings { LogDevice = this.LogDevice }, diff --git a/cs/test/SimpleAsyncTests.cs b/cs/test/SimpleAsyncTests.cs index 589de0028..638372775 100644 --- a/cs/test/SimpleAsyncTests.cs +++ b/cs/test/SimpleAsyncTests.cs @@ -28,7 +28,7 @@ public void Setup() inputArray[i].adId = i; } - path = TestContext.CurrentContext.TestDirectory + "\\SimpleAsyncTests\\"; + path = TestContext.CurrentContext.TestDirectory + "/SimpleAsyncTests/"; log = Devices.CreateLogDevice(path + "hlog.log", deleteOnClose: true); Directory.CreateDirectory(path); fht1 = new FasterKV diff --git a/cs/test/SimpleRecoveryTest.cs b/cs/test/SimpleRecoveryTest.cs index ac33a2678..30a676c38 100644 --- a/cs/test/SimpleRecoveryTest.cs +++ b/cs/test/SimpleRecoveryTest.cs @@ -55,12 +55,12 @@ public async ValueTask SimpleRecoveryTest1([Values]CheckpointType checkpointType private async ValueTask SimpleRecoveryTest1_Worker(CheckpointType checkpointType, ICheckpointManager checkpointManager, bool isAsync) { - string checkpointDir = TestContext.CurrentContext.TestDirectory + $"\\{TEST_CONTAINER}"; + string checkpointDir = TestContext.CurrentContext.TestDirectory + $"/{TEST_CONTAINER}"; if (checkpointManager != null) checkpointDir = null; - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/SimpleRecoveryTest1.log", deleteOnClose: true); fht1 = new FasterKV @@ -128,11 +128,11 @@ private async ValueTask SimpleRecoveryTest1_Worker(CheckpointType checkpointType [Test] public async ValueTask SimpleRecoveryTest2([Values]CheckpointType checkpointType, [Values]bool isAsync) { - var checkpointManager = new DeviceLogCommitCheckpointManager(new LocalStorageNamedDeviceFactory(), new DefaultCheckpointNamingScheme(TestContext.CurrentContext.TestDirectory + "\\checkpoints4"), false); + var checkpointManager = new DeviceLogCommitCheckpointManager(new LocalStorageNamedDeviceFactory(), new DefaultCheckpointNamingScheme(TestContext.CurrentContext.TestDirectory + "/checkpoints4"), false); - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest2.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/SimpleRecoveryTest2.log", deleteOnClose: true); - // Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints4"); + // Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "/checkpoints4"); fht1 = new FasterKV @@ -194,28 +194,28 @@ public async ValueTask SimpleRecoveryTest2([Values]CheckpointType checkpointType fht2.Dispose(); checkpointManager.Dispose(); - new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints4").Delete(true); + new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "/checkpoints4").Delete(true); } [Test] public async ValueTask ShouldRecoverBeginAddress([Values]bool isAsync) { - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest2.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/SimpleRecoveryTest2.log", deleteOnClose: true); - Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints6"); + Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "/checkpoints6"); fht1 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints6", CheckPointType = CheckpointType.FoldOver } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints6", CheckPointType = CheckpointType.FoldOver } ); fht2 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints6", CheckPointType = CheckpointType.FoldOver } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints6", CheckPointType = CheckpointType.FoldOver } ); @@ -255,7 +255,7 @@ public async ValueTask ShouldRecoverBeginAddress([Values]bool isAsync) log.Dispose(); fht1.Dispose(); fht2.Dispose(); - new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints6").Delete(true); + new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "/checkpoints6").Delete(true); } } diff --git a/cs/test/SpanByteTests.cs b/cs/test/SpanByteTests.cs index da82033e9..7d1f85bf5 100644 --- a/cs/test/SpanByteTests.cs +++ b/cs/test/SpanByteTests.cs @@ -26,7 +26,7 @@ public unsafe void SpanByteTest1() FasterKV fht; IDevice log; - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/hlog1.log", deleteOnClose: true); fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 17, PageSizeBits = 12 }); diff --git a/cs/test/StateMachineTests.cs b/cs/test/StateMachineTests.cs index 7d6610e88..a7dfc7431 100644 --- a/cs/test/StateMachineTests.cs +++ b/cs/test/StateMachineTests.cs @@ -33,12 +33,12 @@ public void Setup() inputArray[i].adId = i; } - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\StateMachineTest1.log", deleteOnClose: true); - Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints4"); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/StateMachineTest1.log", deleteOnClose: true); + Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "/checkpoints4"); fht1 = new FasterKV (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, PageSizeBits = 10, MemorySizeBits = 13 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = CheckpointType.FoldOver } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints4", CheckPointType = CheckpointType.FoldOver } ); } @@ -47,7 +47,7 @@ public void TearDown() { fht1.Dispose(); log.Dispose(); - new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints4").Delete(true); + new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "/checkpoints4").Delete(true); } @@ -391,7 +391,7 @@ void RecoverAndTest(IDevice log) (128, logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, PageSizeBits = 10, MemorySizeBits = 13 }, - checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = CheckpointType.FoldOver } + checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "/checkpoints4", CheckPointType = CheckpointType.FoldOver } ); fht2.Recover(); // sync, does not require session diff --git a/cs/test/VariableLengthIteratorTests.cs b/cs/test/VariableLengthIteratorTests.cs index 6c9cafe20..8e17339bd 100644 --- a/cs/test/VariableLengthIteratorTests.cs +++ b/cs/test/VariableLengthIteratorTests.cs @@ -16,7 +16,7 @@ public class IteratorTests public void ShouldSkipEmptySpaceAtEndOfPage() { var vlLength = new VLValue(); - var log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog-vl-iter.log", deleteOnClose: true); + var log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/hlog-vl-iter.log", deleteOnClose: true); var fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 17, PageSizeBits = 10 }, // 1KB page diff --git a/cs/test/VariableLengthStructFASTERTests.cs b/cs/test/VariableLengthStructFASTERTests.cs index 4dd0d9d59..2ba6fa4a9 100644 --- a/cs/test/VariableLengthStructFASTERTests.cs +++ b/cs/test/VariableLengthStructFASTERTests.cs @@ -22,7 +22,7 @@ public unsafe void VariableLengthTest1() { FasterKV fht; IDevice log; - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/hlog1.log", deleteOnClose: true); fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 17, PageSizeBits = 12 }, @@ -81,7 +81,7 @@ public unsafe void VariableLengthTest2() { FasterKV fht; IDevice log; - log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog1.log", deleteOnClose: true); + log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "/hlog1.log", deleteOnClose: true); fht = new FasterKV (128, new LogSettings { LogDevice = log, MemorySizeBits = 17, PageSizeBits = 12 },