public long ShouldUseNewPartitionOnRecreate(bool clearPartition1, int days) { var server = new AsyncJournalServer(TimeSpan.FromSeconds(1)); using (IJournal <PocoType> journal = WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days, server)) { using (var rtx = journal.OpenReadTx()) { var newVersion = new PartitionDate(START_DATE, 1, EPartitionType.Month).Name; var newPartitionPath = Path.Combine(_directoryPath, newVersion); Directory.CreateDirectory(newPartitionPath); using (var rtx2 = journal.OpenReadTx()) { var len = rtx2.All().Length.Value; } } // Act. server.DoEvents(); // Verify. using (var rtx = journal.OpenReadTx()) { return(rtx.All().Length.Value); } } }
public void ShouldDeleteOutDatedPartitionVersionWhenNotInUse() { int days = 40; var server = new AsyncJournalServer(TimeSpan.FromSeconds(1)); using (IJournal <PocoType> journal = WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days, server)) { using (var rtx = journal.OpenReadTx()) { var newVersion = new PartitionDate(START_DATE, 1, EPartitionType.Month).Name; var newPartitionPath = Path.Combine(_directoryPath, newVersion); Directory.CreateDirectory(newPartitionPath); using (var rtx2 = journal.OpenReadTx()) { var len = rtx.All().Length.Value; } } // Act. server.DoEvents(); // Verify. var oldVersion = new PartitionDate(START_DATE, 0, EPartitionType.Month).Name; var oldPartitionPath = Path.Combine(_directoryPath, oldVersion); Assert.That(Directory.Exists(oldPartitionPath), Is.EqualTo(false)); } }
public void ShouldReadWriteEpochMillisecondsDatTime() { using (IJournal <File> journal = CreateJournal(DateTimeMode.EpochMilliseconds)) { TestUtils.GenerateRecords(journal, 1000, 2, GenerateFile); IQuery <File> r2 = journal.OpenReadTx(); int i = 0; foreach (File file in r2.All()) { Assert.That(file.Path, Is.EqualTo(i.ToString(CultureInfo.InvariantCulture))); DateTime expectedModifedDate = TestUtils.START.AddMilliseconds(i * _timeIncrement); Assert.That(DateUtils.DateTimeToUnixTimeStamp(file.Modified) , Is.EqualTo(DateUtils.DateTimeToUnixTimeStamp(expectedModifedDate))); DateTime?expectedCreatedDate = i % 2 == 0 ? TestUtils.START.AddMilliseconds(i * _timeIncrement * 2) : (DateTime?)null; Assert.That(file.Created, Is.EqualTo(expectedCreatedDate)); i++; } } }
public void ShouldKeepBothPartitionVersionWhenInUse() { int days = 40; using (IJournal <PocoType> journal = WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days)) { using (var rtx = journal.OpenReadTx()) { var newVersion = new PartitionDate(START_DATE, 1, EPartitionType.Month).Name; Directory.CreateDirectory(Path.Combine(_directoryPath, newVersion)); using (var rtx2 = journal.OpenReadTx()) { Assert.That(rtx2.All().Length.Value, Is.EqualTo(days - 31)); } Assert.That(rtx.All().Length.Value, Is.EqualTo(days)); } } }
public long ShouldDiscoverPartitionNewVersionsOnNewTransactions(bool clearPartition1, int days) { using (IJournal <PocoType> journal = WriteJournal(EPartitionType.Month, TimeSpan.FromDays(1), days)) { if (clearPartition1) { var newVersion = new PartitionDate(START_DATE, 1, EPartitionType.Month).Name; Directory.CreateDirectory(Path.Combine(_directoryPath, newVersion)); } using (var rtx = journal.OpenReadTx()) { return(rtx.All().Length ?? 0L); } } }
public void ShouldReadWriteNetDateTimes() { using (IJournal <File> journal = CreateJournal(DateTimeMode.DotNetDateTime)) { TestUtils.GenerateRecords(journal, 1000, 2, GenerateFile); IQuery <File> r2 = journal.OpenReadTx(); int i = 0; foreach (File file in r2.All()) { Assert.That(file.Path, Is.EqualTo(i.ToString(CultureInfo.InvariantCulture))); Assert.That(file.Modified, Is.EqualTo(TestUtils.START.AddMilliseconds(i * _timeIncrement))); Assert.That(file.Created, Is.EqualTo( i % 2 == 0 ? TestUtils.START.AddMilliseconds(i * _timeIncrement * 2) : (DateTime?)null)); i++; } } }
public void ShouldSupportSearchByDateTimeTimestamp() { using (IJournal <File> journal = CreateJournal(DateTimeMode.DotNetDateTime)) { const int count = 1000; TestUtils.GenerateRecords(journal, count, 2, GenerateFile); IQuery <File> r2 = journal.OpenReadTx(); for (int i = 0; i < count; i++) { var recordTimestamp = TestUtils.START.AddMilliseconds(i * _timeIncrement); var file = r2.Items.Single(j => j.Modified == recordTimestamp); Assert.That(file.Path, Is.EqualTo(i.ToString(CultureInfo.InvariantCulture))); Assert.That(file.Created, Is.EqualTo( i % 2 == 0 ? TestUtils.START.AddMilliseconds(i * _timeIncrement * 2) : (DateTime?)null)); i++; } } }