protected void CheckRecords() { _checked = true; Assert.AreEqual(_keptRecords.Length, _dbResult.Db.Manager.ChunksCount, "Wrong chunks count."); for (int i = 0; i < _keptRecords.Length; ++i) { var chunk = _dbResult.Db.Manager.GetChunk(i); var chunkRecords = new List <LogRecord>(); RecordReadResult result = chunk.TryReadFirst(); while (result.Success) { chunkRecords.Add(result.LogRecord); result = chunk.TryReadClosestForward((int)result.NextPosition); } Assert.AreEqual(_keptRecords[i].Length, chunkRecords.Count, "Wrong number of records in chunk #{0}", i); for (int j = 0; j < _keptRecords[i].Length; ++j) { Assert.AreEqual(_keptRecords[i][j], chunkRecords[j], "Wrong log record #{0} read from chunk #{1}", j, i); } } }
public void sequencial_read_returns_no_records() { var records = new List <LogRecord>(); RecordReadResult res = _scavengedChunk.TryReadFirst(); while (res.Success) { records.Add(res.LogRecord); res = _scavengedChunk.TryReadClosestForward((int)res.NextPosition); } Assert.AreEqual(0, records.Count); }
public void should_change_expected_version_to_deleted_event_number_when_reading() { var chunk = Db.Manager.GetChunk(0); var chunkRecords = new List <LogRecord>(); RecordReadResult result = chunk.TryReadFirst(); while (result.Success) { chunkRecords.Add(result.LogRecord); result = chunk.TryReadClosestForward(result.NextPosition); } Assert.That(chunkRecords.Any(x => x.RecordType == LogRecordType.Commit && ((CommitLogRecord)x).FirstEventNumber == long.MaxValue)); Assert.That(chunkRecords.Any(x => x.RecordType == LogRecordType.Prepare && ((PrepareLogRecord)x).ExpectedVersion == long.MaxValue - 1)); }
public void the_log_records_are_still_version_0() { var chunk = Db.Manager.GetChunk(0); var chunkRecords = new List <LogRecord>(); RecordReadResult result = chunk.TryReadFirst(); while (result.Success) { chunkRecords.Add(result.LogRecord); result = chunk.TryReadClosestForward(result.NextPosition); } Assert.IsTrue(chunkRecords.All(x => x.Version == LogRecordVersion.LogRecordV0)); Assert.AreEqual(10, chunkRecords.Count); }
private static PrepareLogRecord ReadPrepareInternal(TFReaderLease reader, long logPosition) { RecordReadResult result = reader.TryReadAt(logPosition); if (!result.Success) { return(null); } if (result.LogRecord.RecordType != LogRecordType.Prepare) { throw new Exception(string.Format("Incorrect type of log record {0}, expected Prepare record.", result.LogRecord.RecordType)); } return((PrepareLogRecord)result.LogRecord); }
private static Tuple <string, bool> ReadEntry(TFReaderLease reader, long position) { RecordReadResult result = reader.TryReadAt(position); if (!result.Success) { return(new Tuple <string, bool>(String.Empty, false)); } if (result.LogRecord.RecordType != TransactionLog.LogRecords.LogRecordType.Prepare) { throw new Exception(string.Format("Incorrect type of log record {0}, expected Prepare record.", result.LogRecord.RecordType)); } return(new Tuple <string, bool>(((TransactionLog.LogRecords.PrepareLogRecord)result.LogRecord).EventStreamId, true)); }
public void the_log_records_are_unchanged_in_second_chunk() { var chunk = Db.Manager.GetChunk(1); var chunkRecords = new List <ILogRecord>(); RecordReadResult result = chunk.TryReadFirst(); while (result.Success) { chunkRecords.Add(result.LogRecord); result = chunk.TryReadClosestForward(result.NextPosition); } Assert.AreEqual(2, chunkRecords.Count); }
public void should_have_updated_deleted_stream_event_number() { var chunk = Db.Manager.GetChunk(0); var chunkRecords = new List <LogRecord>(); RecordReadResult result = chunk.TryReadFirst(); while (result.Success) { chunkRecords.Add(result.LogRecord); result = chunk.TryReadClosestForward(result.NextPosition); } var deletedRecord = (PrepareLogRecord)chunkRecords.First(x => x.RecordType == LogRecordType.Prepare && ((PrepareLogRecord)x).EventStreamId == _deletedEventStreamId); Assert.AreEqual(EventNumber.DeletedStream - 1, deletedRecord.ExpectedVersion); }
public void should_have_updated_deleted_stream_event_number() { var chunk = Db.Manager.GetChunk(0); var chunkRecords = new List <ILogRecord>(); RecordReadResult result = chunk.TryReadFirst(); while (result.Success) { chunkRecords.Add(result.LogRecord); result = chunk.TryReadClosestForward(result.NextPosition); } _streamNameIndex.GetOrAddId(_deletedEventStreamId, out var id, out _, out _); var deletedRecord = (IPrepareLogRecord <TStreamId>)chunkRecords.First( x => x.RecordType == LogRecordType.Prepare && EqualityComparer <TStreamId> .Default.Equals(((IPrepareLogRecord <TStreamId>)x).EventStreamId, id)); Assert.AreEqual(EventNumber.DeletedStream - 1, deletedRecord.ExpectedVersion); }
public void sequencial_read_returns_no_records() { var records = new List <ILogRecord>(); RecordReadResult res = _scavengedChunk.TryReadFirst(); while (res.Success) { records.Add(res.LogRecord); res = _scavengedChunk.TryReadClosestForward((int)res.NextPosition); } if (LogFormatHelper <TLogFormat, TStreamId> .IsV2) { Assert.AreEqual(0, records.Count); } else { Assert.AreEqual(1, records.Count); } }