forked from microsoft/FASTER
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C#] Test suite for remote FASTER (microsoft#458)
* Initial checkin of test suite for remote * updated configs. * fix sln * Update azure-pipelines.yml * Update azure-pipelines.yml * Update 50-remote-basics.md * Update 50-remote-basics.md
- Loading branch information
Showing
7 changed files
with
249 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
cs/remote/test/FASTER.remote.test/FASTER.remote.test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks> | ||
<Platforms>AnyCPU;x64</Platforms> | ||
<HighEntropyVA>true</HighEntropyVA> | ||
<LangVersion>8</LangVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<RootNamespace>FASTER.remote.test</RootNamespace> | ||
<AssemblyName>FASTER.remote.test</AssemblyName> | ||
<ErrorReport>prompt</ErrorReport> | ||
<SignAssembly>true</SignAssembly> | ||
<ApplicationIcon /> | ||
<OutputType>Library</OutputType> | ||
<StartupObject /> | ||
<AssemblyOriginatorKeyFile>../../../FASTER.snk</AssemblyOriginatorKeyFile> | ||
<DelaySign>false</DelaySign> | ||
<DocumentationFile>bin\$(Platform)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> | ||
<DefineConstants>TRACE;DEBUG</DefineConstants> | ||
<DebugType>full</DebugType> | ||
<OutputPath>bin\$(Platform)\Debug\</OutputPath> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\$(Platform)\Release\</OutputPath> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<NoWarn>1701;1702;1591</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> | ||
<PackageReference Include="NUnit" Version="3.12.0" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\core\FASTER.core.csproj" /> | ||
<ProjectReference Include="..\..\src\FASTER.client\FASTER.client.csproj" /> | ||
<ProjectReference Include="..\..\src\FASTER.server\FASTER.server.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using FASTER.client; | ||
|
||
namespace FASTER.remote.test | ||
{ | ||
[TestFixture] | ||
public class FixedLenBinaryTests | ||
{ | ||
FixedLenServer<long, long> server; | ||
FixedLenClient<long, long> client; | ||
ClientSession<long, long, long, long, long, FixedLenClientFunctions, FixedLenSerializer<long, long, long, long>> session; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
server = new FixedLenServer<long, long>(TestContext.CurrentContext.TestDirectory + "/FixedLenBinaryTests", (a, b) => a + b); | ||
client = new FixedLenClient<long, long>(); | ||
session = client.GetSession(); | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
session.Dispose(); | ||
client.Dispose(); | ||
server.Dispose(); | ||
} | ||
|
||
[Test] | ||
public void UpsertReadTest() | ||
{ | ||
session.Upsert(10, 23); | ||
session.CompletePending(); | ||
session.Read(10, userContext: 23); | ||
session.CompletePending(); | ||
session.RMW(20, 23); | ||
session.RMW(20, 23); | ||
session.RMW(20, 23); | ||
session.CompletePending(); | ||
session.Read(20, userContext: 23 * 3); | ||
session.CompletePending(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using FASTER.client; | ||
using NUnit.Framework; | ||
using System; | ||
|
||
namespace FASTER.remote.test | ||
{ | ||
class FixedLenClient<Key, Value> : IDisposable | ||
where Key : unmanaged | ||
where Value : unmanaged | ||
|
||
{ | ||
readonly FasterKVClient<long, long> client; | ||
|
||
public FixedLenClient(string address = "127.0.0.1", int port = 33278) | ||
{ | ||
client = new FasterKVClient<long, long>(address, port); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
client.Dispose(); | ||
} | ||
|
||
public ClientSession<long, long, long, long, long, FixedLenClientFunctions, FixedLenSerializer<long, long, long, long>> GetSession() | ||
=> client.NewSession<long, long, long, FixedLenClientFunctions, FixedLenSerializer<long, long, long, long>>(new FixedLenClientFunctions()); | ||
} | ||
|
||
/// <summary> | ||
/// Callback functions | ||
/// </summary> | ||
sealed class FixedLenClientFunctions : CallbackFunctionsBase<long, long, long, long, long> | ||
{ | ||
public override void ReadCompletionCallback(ref long key, ref long input, ref long output, long ctx, Status status) | ||
{ | ||
Assert.IsTrue(status == Status.OK); | ||
Assert.IsTrue(output == ctx); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using FASTER.core; | ||
using FASTER.server; | ||
using System; | ||
using System.IO; | ||
|
||
namespace FASTER.remote.test | ||
{ | ||
class FixedLenServer<Key, Value> : IDisposable | ||
where Key : unmanaged | ||
where Value : unmanaged | ||
{ | ||
readonly string folderName; | ||
readonly FasterKVServer<Key, Value, Value, Value, FixedLenServerFunctions<Key, Value>, FixedLenSerializer<Key, Value, Value, Value>> server; | ||
|
||
public FixedLenServer(string folderName, Func<Value, Value, Value> merger, string address = "127.0.0.1", int port = 33278) | ||
{ | ||
this.folderName = folderName; | ||
GetSettings(folderName, out var logSettings, out var checkpointSettings, out var indexSize); | ||
|
||
// We use blittable structs Key and Value to construct a costomized server for fixed-length types | ||
var store = new FasterKV<Key, Value>(indexSize, logSettings, checkpointSettings); | ||
|
||
// We specify FixedLenSerializer as our in-built serializer for blittable (fixed length) types | ||
// This server can be used with compatible clients such as FixedLenClient and FASTER.benchmark | ||
server = new FasterKVServer<Key, Value, Value, Value, FixedLenServerFunctions<Key, Value>, FixedLenSerializer<Key, Value, Value, Value>> | ||
(store, e => new FixedLenServerFunctions<Key, Value>(merger), address, port); | ||
server.Start(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
server.Dispose(); | ||
new DirectoryInfo(folderName).Delete(true); | ||
} | ||
|
||
private void GetSettings(string LogDir, out LogSettings logSettings, out CheckpointSettings checkpointSettings, out int indexSize) | ||
{ | ||
logSettings = new LogSettings { PreallocateLog = false }; | ||
|
||
logSettings.PageSizeBits = 20; | ||
logSettings.MemorySizeBits = 25; | ||
logSettings.SegmentSizeBits = 30; | ||
indexSize = 1 << 20; | ||
|
||
var device = LogDir == "" ? new NullDevice() : Devices.CreateLogDevice(LogDir + "/hlog", preallocateFile: false); | ||
logSettings.LogDevice = device; | ||
|
||
string CheckpointDir = null; | ||
if (CheckpointDir == null && LogDir == null) | ||
checkpointSettings = null; | ||
else | ||
checkpointSettings = new CheckpointSettings | ||
{ | ||
CheckPointType = CheckpointType.FoldOver, | ||
CheckpointDir = CheckpointDir ?? (LogDir + "/checkpoints") | ||
}; | ||
} | ||
} | ||
|
||
sealed class FixedLenServerFunctions<Key, Value> : SimpleFunctions<Key, Value, long> | ||
{ | ||
public FixedLenServerFunctions(Func<Value, Value, Value> merger) : base(merger) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters