Skip to content

Commit

Permalink
Removing sample test code.
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc committed Aug 12, 2019
1 parent 30adeca commit 9e84d63
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@

<ItemGroup>
<ProjectReference Include="..\..\src\core\FASTER.core.csproj" />
<ProjectReference Include="..\..\test\FASTER.test.csproj" />
</ItemGroup>
</Project>
5 changes: 0 additions & 5 deletions cs/playground/FixedLenStructSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using FASTER.core;
using FASTER.test.recovery.sumstore.simple;
using System;

namespace FixedLenStructSample
Expand All @@ -12,10 +11,6 @@ public class Program
// This sample uses fixed length structs for keys and values
static void Main()
{
while (true)
new SimpleRecoveryTests().SimpleRecoveryTest3();
return;

var log = Devices.CreateLogDevice("hlog.log", deleteOnClose: true);
var fht = new FasterKV<FixedLenKey, FixedLenValue, string, string, Empty, FixedLenFunctions>
(128, new FixedLenFunctions(),
Expand Down
17 changes: 3 additions & 14 deletions cs/test/LargeObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,9 @@ public static void DeleteDirectory(string path)
}
}


[Test]
public void LargeObjectTest1()
{
LargeObjectTest(CheckpointType.Snapshot);
}

[Test]
public void LargeObjectTest2()
{
LargeObjectTest(CheckpointType.FoldOver);
}

private void LargeObjectTest(CheckpointType checkpointType)
[TestCase(CheckpointType.FoldOver)]
[TestCase(CheckpointType.Snapshot)]
public void LargeObjectTest(CheckpointType checkpointType)
{
MyInput input = default(MyInput);
MyLargeOutput output = new MyLargeOutput();
Expand Down
112 changes: 24 additions & 88 deletions cs/test/SimpleRecoveryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public class SimpleRecoveryTests
private IDevice log;


[Test]
public void SimpleRecoveryTest1()
[TestCase(CheckpointType.FoldOver)]
[TestCase(CheckpointType.Snapshot)]
public void SimpleRecoveryTest1(CheckpointType checkpointType)
{
log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest1.log", deleteOnClose: true);

Expand All @@ -33,14 +34,14 @@ public void SimpleRecoveryTest1()
<AdId, NumClicks, Input, Output, Empty, SimpleFunctions>
(128, new SimpleFunctions(),
logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 },
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = CheckpointType.Snapshot }
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = checkpointType }
);

fht2 = new FasterKV
<AdId, NumClicks, Input, Output, Empty, SimpleFunctions>
(128, new SimpleFunctions(),
logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 },
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = CheckpointType.Snapshot }
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = checkpointType }
);


Expand Down Expand Up @@ -86,89 +87,27 @@ public void SimpleRecoveryTest1()
new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints4").Delete(true);
}

[Test]
public void SimpleRecoveryTest2()
{
log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest2.log", deleteOnClose: true);

Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints5");

fht1 = new FasterKV
<AdId, NumClicks, Input, Output, Empty, SimpleFunctions>
(128, new SimpleFunctions(),
logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 },
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints5", CheckPointType = CheckpointType.FoldOver }
);

fht2 = new FasterKV
<AdId, NumClicks, Input, Output, Empty, SimpleFunctions>
(128, new SimpleFunctions(),
logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 },
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints5", CheckPointType = CheckpointType.FoldOver }
);


int numOps = 5000;
var inputArray = new AdId[numOps];
for (int i = 0; i < numOps; i++)
{
inputArray[i].adId = i;
}

NumClicks value;
Input inputArg = default(Input);
Output output = default(Output);

fht1.StartSession();
for (int key = 0; key < numOps; key++)
{
value.numClicks = key;
fht1.Upsert(ref inputArray[key], ref value, Empty.Default, 0);
}
fht1.TakeFullCheckpoint(out Guid token);
fht1.CompleteCheckpoint(true);
fht1.StopSession();

fht2.Recover(token);
fht2.StartSession();
for (int key = 0; key < numOps; key++)
{
var status = fht2.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, 0);

if (status == Status.PENDING)
fht2.CompletePending(true);
else
{
Assert.IsTrue(output.value.numClicks == key);
}
}
fht2.StopSession();

log.Close();
fht1.Dispose();
fht2.Dispose();
new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints5").Delete(true);
}

[Test]
public void SimpleRecoveryTest3()
[TestCase(CheckpointType.FoldOver)]
[TestCase(CheckpointType.Snapshot)]
public void SimpleRecoveryTest2(CheckpointType checkpointType)
{
log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest3.log", deleteOnClose: true);
log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\SimpleRecoveryTest2.log", deleteOnClose: true);

Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints4");

fht1 = new FasterKV
<AdId, NumClicks, Input, Output, Empty, SimpleFunctions>
(128, new SimpleFunctions(),
logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 },
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = CheckpointType.Snapshot }
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = checkpointType }
);

fht2 = new FasterKV
<AdId, NumClicks, Input, Output, Empty, SimpleFunctions>
(128, new SimpleFunctions(),
logSettings: new LogSettings { LogDevice = log, MutableFraction = 0.1, MemorySizeBits = 29 },
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = CheckpointType.Snapshot }
checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints4", CheckPointType = checkpointType }
);


Expand Down Expand Up @@ -207,30 +146,27 @@ public void SimpleRecoveryTest3()
s0.Dispose();
fht1.Dispose();

fht2.Recover(token);
fht2.Recover(token); // sync, does not require session

var guid = s1.ID;
var s3 = fht2.ContinueClientSession(guid, out long lsn);
Console.WriteLine($"Resuming {guid} persisted until offset {lsn}");

// var s3 = fht2.StartClientSession(); // guid, out long lsn);

s3.ResumeThread();

for (int key = 0; key < numOps; key++)
using (var s3 = fht2.ContinueClientSession(guid, out long lsn))
{
var status = fht2.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, 0);
Assert.IsTrue(lsn == numOps - 1);

if (status == Status.PENDING)
fht2.CompletePending(true);
else
for (int key = 0; key < numOps; key++)
{
Assert.IsTrue(output.value.numClicks == key);
var status = s3.Read(ref inputArray[key], ref inputArg, ref output, Empty.Default, 0);

if (status == Status.PENDING)
s3.CompletePending(true);
else
{
Assert.IsTrue(output.value.numClicks == key);
}
}
}
s3.Dispose();
fht2.Dispose();

fht2.Dispose();
log.Close();
new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints4").Delete(true);
}
Expand Down

0 comments on commit 9e84d63

Please sign in to comment.