Rollback test for sbtree v1 delete + add operations is implemented.
@@ -354,33 +354,40 @@ public class SBTreeV1TestIT {
Assert.assertEquals(sbTree.get(i), new ORecordId(i % 32000, i));
}
- for (int i = 0; i < keysCount; i++) {
- if (i % 3 == 0)
- Assert.assertEquals(sbTree.remove(i), new ORecordId(i % 32000, i));
+ final int rollbackInterval = 100;
+ final OAtomicOperationsManager atomicOperationsManager = storage.getAtomicOperationsManager();
- if (i % 2 == 0)
- sbTree.put(keysCount + i, new ORecordId((keysCount + i) % 32000, keysCount + i));
+ for (int i = 0; i < keysCount / rollbackInterval; i++) {
+ for (int n = 0; n < 2; n++) {
+ atomicOperationsManager.startAtomicOperation((String) null, false);
- }
+ for (int j = 0; j < rollbackInterval; j++) {
+ final int key = i * rollbackInterval + j;
- final Integer firstKey = sbTree.firstKey();
- Assert.assertNotNull(firstKey);
- Assert.assertEquals((int) firstKey, 1);
+ if (key % 3 == 0) {
+ Assert.assertEquals(sbTree.remove(key), new ORecordId(key % 32000, key));
+ }
- final Integer lastKey = sbTree.lastKey();
- Assert.assertNotNull(lastKey);
- Assert.assertEquals((int) lastKey, 2 * keysCount - 2);
+ if (key % 2 == 0) {
+ sbTree.put(keysCount + key, new ORecordId((keysCount + key) % 32000, keysCount + key));
+ }
+ }
+ atomicOperationsManager.endAtomicOperation(n == 0);
+ }
+ }
for (int i = 0; i < keysCount; i++) {
- if (i % 3 == 0)
+ if (i % 3 == 0) {
Assert.assertNull(sbTree.get(i));
- else
+ } else {
Assert.assertEquals(sbTree.get(i), new ORecordId(i % 32000, i));
+ }
- if (i % 2 == 0)
+ if (i % 2 == 0) {
Assert.assertEquals(sbTree.get(keysCount + i), new ORecordId((keysCount + i) % 32000, keysCount + i));
}
}
+ }
@Test
public void testIterateEntriesMajor() throws Exception {
