Skip to content

Commit

Permalink
Added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc committed Oct 7, 2019
1 parent c55de3f commit db68ae0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cs/test/FasterLogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using FASTER.core;
using NUnit.Framework;

Expand Down Expand Up @@ -66,5 +67,43 @@ public void FasterLogTest1()
log.ReleaseThread();
log.Dispose();
}

[Test]
public async Task FasterLogTest2()
{
log = new FasterLog(new FasterLogSettings { LogDevice = device });
byte[] data1 = new byte[10000];
for (int i = 00; i < 10000; i++) data1[i] = (byte)i;

using (var iter = log.Scan(0, long.MaxValue, scanBufferingMode: ScanBufferingMode.SinglePageBuffering))
{
int i = 0;
while (i++ < 500)
{
var waitingReader = iter.WaitAsync();
Assert.IsTrue(!waitingReader.IsCompleted);

while (!log.TryAppend(data1, out _)) ;
Assert.IsFalse(waitingReader.IsCompleted);

await log.FlushAndCommitAsync();
while (!waitingReader.IsCompleted) ;
Assert.IsTrue(waitingReader.IsCompleted);

var result = GetNext(iter);
Assert.IsTrue(result.SequenceEqual(data1));

var next = iter.GetNext(out _, out _);
Assert.IsFalse(next);
}
}
log.Dispose();
}

private byte[] GetNext(FasterLogScanIterator iter)
{
iter.GetNext(out Span<byte> entry, out _);
return entry.ToArray();
}
}
}

0 comments on commit db68ae0

Please sign in to comment.