forked from MIT-DB-Class/simple-db-hw-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Split TransactionTest into TransactionTest{One, Two, Five, Ten, AllDirty} - Updated build.xml to make the timeout configurable - Improved comments in DeadlockTest, LockingTest, and TransactionTest Co-authored-by: Geoffrey Yu <[email protected]> Co-authored-by: Anna Zeng <[email protected]>
- Loading branch information
Showing
11 changed files
with
173 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package simpledb.systemtest; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import simpledb.common.Database; | ||
import simpledb.common.DbException; | ||
import simpledb.storage.*; | ||
import simpledb.transaction.Transaction; | ||
import simpledb.transaction.TransactionAbortedException; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class TransactionTestAllDirty extends SimpleDbTestBase { | ||
@Test public void testAllDirtyFails() | ||
throws IOException, DbException, TransactionAbortedException { | ||
// Allocate a file with ~10 pages of data | ||
HeapFile f = SystemTestUtil.createRandomHeapFile(2, 512*10, null, null); | ||
Database.resetBufferPool(1); | ||
|
||
// BEGIN TRANSACTION | ||
Transaction t = new Transaction(); | ||
t.start(); | ||
|
||
// Insert a new row | ||
AbortEvictionTest.insertRow(f, t); | ||
|
||
// Scanning the table must fail because it can't evict the dirty page | ||
try { | ||
AbortEvictionTest.findMagicTuple(f, t); | ||
fail("Expected scan to run out of available buffer pages"); | ||
} catch (DbException ignored) {} | ||
t.commit(); | ||
} | ||
|
||
/** Make test compatible with older version of ant. */ | ||
public static junit.framework.Test suite() { | ||
return new junit.framework.JUnit4TestAdapter(TransactionTestAllDirty.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package simpledb.systemtest; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import simpledb.common.DbException; | ||
import simpledb.transaction.TransactionAbortedException; | ||
|
||
/** | ||
* Tests running concurrent transactions. | ||
* You do not need to pass this test until Lab 4. | ||
* @see simpledb.systemtest.TransactionTestShared | ||
*/ | ||
public class TransactionTestFive extends SimpleDbTestBase { | ||
@Test public void testFiveThreads() | ||
throws IOException, DbException, TransactionAbortedException { | ||
TransactionTestUtil.validateTransactions(5); | ||
} | ||
|
||
/** Make test compatible with older version of ant. */ | ||
public static junit.framework.Test suite() { | ||
return new junit.framework.JUnit4TestAdapter(TransactionTestFive.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package simpledb.systemtest; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import simpledb.common.DbException; | ||
import simpledb.transaction.TransactionAbortedException; | ||
|
||
/** | ||
* Tests running concurrent transactions. | ||
* You do not need to pass this test until Lab 4. | ||
* @see simpledb.systemtest.TransactionTestShared | ||
*/ | ||
public class TransactionTestOne extends SimpleDbTestBase { | ||
@Test public void testSingleThread() | ||
throws IOException, DbException, TransactionAbortedException { | ||
TransactionTestUtil.validateTransactions(1); | ||
} | ||
|
||
/** Make test compatible with older version of ant. */ | ||
public static junit.framework.Test suite() { | ||
return new junit.framework.JUnit4TestAdapter(TransactionTestOne.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package simpledb.systemtest; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import simpledb.common.DbException; | ||
import simpledb.transaction.TransactionAbortedException; | ||
|
||
/** | ||
* Tests running concurrent transactions. | ||
* You do not need to pass this test until Lab 4. | ||
* @see simpledb.systemtest.TransactionTestShared | ||
*/ | ||
public class TransactionTestTen extends SimpleDbTestBase { | ||
@Test public void testTenThreads() | ||
throws IOException, DbException, TransactionAbortedException { | ||
TransactionTestUtil.validateTransactions(10); | ||
} | ||
|
||
/** Make test compatible with older version of ant. */ | ||
public static junit.framework.Test suite() { | ||
return new junit.framework.JUnit4TestAdapter(TransactionTestTen.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package simpledb.systemtest; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import simpledb.common.DbException; | ||
import simpledb.transaction.TransactionAbortedException; | ||
|
||
/** | ||
* Tests running concurrent transactions. | ||
* You do not need to pass this test until Lab 4. | ||
* @see simpledb.systemtest.TransactionTestShared | ||
*/ | ||
public class TransactionTestTwo extends SimpleDbTestBase { | ||
@Test public void testTwoThreads() | ||
throws IOException, DbException, TransactionAbortedException { | ||
TransactionTestUtil.validateTransactions(2); | ||
} | ||
|
||
/** Make test compatible with older version of ant. */ | ||
public static junit.framework.Test suite() { | ||
return new junit.framework.JUnit4TestAdapter(TransactionTestTwo.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters