private void construct_valid_cache_for_any_combination_of_params(int maxIndexEntries) { var rnd = new Random(123987); for (int count = 0; count < maxIndexEntries; ++count) { for (int depth = 0; depth < 15; ++depth) { PTable ptable = null; try { Log.Trace("Creating PTable with count {0}, depth {1}", count, depth); ptable = ConstructPTable(GetFilePathFor(string.Format("{0}-{1}-indexv{2}.ptable", count, depth, _ptableVersion)), count, rnd, depth); ValidateCache(ptable.GetMidPoints(), count, depth); } finally { if (ptable != null) { ptable.Dispose(); } } } } }
public override Task TestFixtureTearDown() { _oldTable.Dispose(); _newtable.Dispose(); return(base.TestFixtureTearDown()); }
public void when_ptable_hash_is_corrupted() { _ptable.Dispose(); _ptable = null; using (var fs = File.Open(_ptableFileName, FileMode.Open)) { fs.Seek(-PTable.MD5Size, SeekOrigin.End); var b = (byte)fs.ReadByte(); b ^= 1; fs.Seek(-PTable.MD5Size, SeekOrigin.End); fs.WriteByte(b); } Assert.Throws <CorruptIndexException>(() => IndexMap.FromFile(_indexMapFileName, x => false, 2)); }
public override void TestFixtureTearDown() { _oldTable.Dispose(); _newtable.Dispose(); base.TestFixtureTearDown(); }
public override void SetUp() { base.SetUp(); _filename = GetTempFilePath(); _copiedfilename = GetTempFilePath(); var mtable = new HashListMemTable(_ptableVersion, maxSize: 1024); long logPosition = 0; long eventNumber = 1; ulong streamId = 0x010100000000; for (var i = 0; i < 1337; i++) { logPosition++; if (i % 37 == 0) { streamId -= 0x1337; eventNumber = 1; } else { eventNumber++; } mtable.Add(streamId, eventNumber, logPosition); } _table = PTable.FromMemtable(mtable, _filename, skipIndexVerify: _skipIndexVerify); _table.Dispose(); File.Copy(_filename, _copiedfilename); }
public override void TestFixtureTearDown() { _newtable.Dispose(); foreach (var ssTable in _tables) { ssTable.Dispose(); } base.TestFixtureTearDown(); }
public override Task TestFixtureTearDown() { _newtable.Dispose(); foreach (var ssTable in _tables) { ssTable.Dispose(); } return(base.TestFixtureTearDown()); }
public void throw_exception_if_index_entries_not_descending_during_ptable_get_range_2(byte version, bool skipIndexVerify) { string ptableFileName = ConstructPTable(version); CorruptPTableFile(ptableFileName, version, "maxOutMiddleEntries"); //loading with a depth of 1 should load only 2 midpoints (first and last index entry) PTable pTable = PTable.FromFile(ptableFileName, 1, skipIndexVerify); Assert.Throws <MaybeCorruptIndexException>(() => pTable.GetRange(GetOriginalHash(numIndexEntries / 2, version), 1, 1)); pTable.Dispose(); }
public void Teardown() { _newtable.Dispose(); foreach (var ssTable in _tables) { ssTable.Dispose(); } foreach (var f in _files) { File.Delete(f); } }
public void throw_exception_if_index_entries_not_descending_during_ptable_get_one_value_2(byte version, bool skipIndexVerify) { string ptableFileName = ConstructPTable(version); CorruptPTableFile(ptableFileName, version, "maxOutMiddleEntries"); //loading with a depth of 1 should load only 2 midpoints (first and last index entry) PTable pTable = PTable.FromFile(ptableFileName, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, 1, skipIndexVerify); long position; Assert.Throws <MaybeCorruptIndexException>(() => pTable.TryGetOneValue(GetOriginalHash(numIndexEntries / 2, version), 1, out position)); pTable.Dispose(); }
public void throw_exception_if_index_entries_not_descending_during_ptable_get_latest_entry(byte version, bool skipIndexVerify) { string ptableFileName = ConstructPTable(version); CorruptPTableFile(ptableFileName, version, "zeroOutMiddleEntries"); //loading with a depth of 1 should load only 2 midpoints (first and last index entry) PTable pTable = PTable.FromFile(ptableFileName, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, 1, skipIndexVerify); IndexEntry entry; Assert.Throws <MaybeCorruptIndexException>(() => // changed 2 to 4 here because the corruption actually removes the stream at /2, so it isn't in the bloom filter pTable.TryGetLatestEntry(GetOriginalHash(numIndexEntries / 4, version), out entry)); pTable.Dispose(); }
public void Setup() { _filename = GetTempFilePath(); _copiedfilename = GetTempFilePath(); var mtable = new HashListMemTable(_ptableVersion, maxSize: 10); mtable.Add(0x010100000000, 0x0001, 0x0001); mtable.Add(0x010500000000, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, _filename); _table.Dispose(); File.Copy(_filename, _copiedfilename); using (var f = new FileStream(_copiedfilename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) { f.Seek(22, SeekOrigin.Begin); f.WriteByte(0x22); } }
public override async Task SetUp() { await base.SetUp(); _filename = GetTempFilePath(); _copiedfilename = GetTempFilePath(); var mtable = new HashListMemTable(_ptableVersion, maxSize: 10); mtable.Add(0x010100000000, 0x0001, 0x0001); mtable.Add(0x010500000000, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, _filename, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault); _table.Dispose(); File.Copy(_filename, _copiedfilename); using (var f = new FileStream(_copiedfilename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) { f.Seek(130, SeekOrigin.Begin); f.WriteByte(0x22); } }
public override void SetUp() { base.SetUp(); _filename = GetTempFilePath(); _copiedfilename = GetTempFilePath(); var mtable = new HashListMemTable(maxSize: 10); mtable.Add(0x0101, 0x0001, 0x0001); mtable.Add(0x0105, 0x0001, 0x0002); _table = PTable.FromMemtable(mtable, _filename); _table.Dispose(); File.Copy(_filename, _copiedfilename); using (var f = new FileStream(_copiedfilename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) { f.Seek(130, SeekOrigin.Begin); f.WriteByte(0x22); } _table = PTable.FromFile(_copiedfilename); }
public override void TearDown() { PTable.Dispose(); base.TearDown(); }
public void Teardown() { PTable.Dispose(); File.Delete(_filename); }