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

Method setUp

test/simpledb/TransactionTest.java:25–54  ·  view source on GitHub ↗

Set up initial resources for each unit test.

()

Source from the content-addressed store, hash-verified

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

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