MCPcopy Create free account
hub / github.com/1345414527/MIT6.830 / setUp

Method setUp

test/simpledb/LockingTest.java:30–59  ·  view source on GitHub ↗

Set up initial resources for each unit test.

()

Source from the content-addressed store, hash-verified

28 * Set up initial resources for each unit test.
29 */
30 @Before public void setUp() throws Exception {
31 super.setUp();
32
33 // clear all state from the buffer pool
34 bp = Database.resetBufferPool(BufferPool.DEFAULT_PAGES);
35
36 // create a new empty HeapFile and populate it with three pages.
37 // we should be able to add 504 tuples on an empty page.
38 TransactionId tid = new TransactionId();
39 for (int i = 0; i < 1025; ++i) {
40 empty.insertTuple(tid, Utility.getHeapTuple(i, 2));
41 }
42
43 // if this fails, complain to the TA
44 assertEquals(3, empty.numPages());
45
46 this.p0 = new HeapPageId(empty.getId(), 0);
47 this.p1 = new HeapPageId(empty.getId(), 1);
48 PageId p2 = new HeapPageId(empty.getId(), 2);
49 this.tid1 = new TransactionId();
50 this.tid2 = new TransactionId();
51
52 // forget about locks associated to tid, so they don't conflict with
53 // test cases
54 bp.getPage(tid, p0, Permissions.READ_WRITE).markDirty(true, tid);
55 bp.getPage(tid, p1, Permissions.READ_WRITE).markDirty(true, tid);
56 bp.getPage(tid, p2, Permissions.READ_WRITE).markDirty(true, tid);
57 bp.flushAllPages();
58 bp = Database.resetBufferPool(BufferPool.DEFAULT_PAGES);
59 }
60
61 /**
62 * Generic unit test structure for BufferPool.getPage() assuming locking.

Callers

nothing calls this directly

Calls 8

resetBufferPoolMethod · 0.95
getHeapTupleMethod · 0.95
flushAllPagesMethod · 0.80
insertTupleMethod · 0.65
getIdMethod · 0.65
markDirtyMethod · 0.65
numPagesMethod · 0.45
getPageMethod · 0.45

Tested by

no test coverage detected