public class TestTransactionService extends TestCase2
AbstractTransactionService
using a mock client.Modifier and Type | Class and Description |
---|---|
protected static class |
TestTransactionService.MockTransactionService |
TestCase2.MyProperties, TestCase2.RandomType
_randomType, log
Constructor and Description |
---|
TestTransactionService() |
TestTransactionService(String arg0) |
Modifier and Type | Method and Description |
---|---|
protected TestTransactionService.MockTransactionService |
newFixture()
Implementation uses a mock client.
|
protected TestTransactionService.MockTransactionService |
newFixture(Properties p)
Implementation uses a mock client.
|
void |
test_abortAll()
Test for
AbstractTransactionService.abortAllTx() . |
void |
test_newTx_nothingCommitted_readOnlyTx()
Verify the behavior of the
AbstractTransactionService when there
are no commit points and a read-only transaction is requested. |
void |
test_newTx_nothingCommitted_readWriteTx()
Verify the behavior of the
AbstractTransactionService when there
are no commit points and a read-write transaction is requested. |
void |
test_newTx_readCommitted01()
Test ability to start a read-committed tx when [lastCommitTime] is
non-zero.
|
void |
test_newTx_readCommitted02()
Unit test when [lastCommitTime] is zero.
|
void |
test_newTx_readOnly_contention()
Unit test in which all possible start times for a read-only transaction
are used, forcing the caller to block.
|
void |
test_newTx_readOnly_historyGone()
Verify that a request for an historical state that is no longer available
will be rejected.
|
void |
test_newTx_readOnly_historyGone2()
This is a variant on
test_newTx_readOnly_historyGone() where we
do not start tx2. |
void |
test_newTx_readOnly_releaseTimeRespectsReadsOnCommitTime()
Unit test verifies that the release time does NOT advance when the
earliest running transaction terminates but a second transaction is still
active which reads on the same commit time.
|
void |
test_newTx_readOnly_timestamp_is_lastCommitTime()
Verify that you can create a read-only transaction by providing the
lastCommitTime as the timestamp.
|
void |
test_newTx_readOnly_timestampInFuture()
Verify that you can create a read-only transaction using a timestamp that
is in the future.
|
void |
test_newTx_readOnly_txComplete_postConditions()
Create a read-only transaction, commit it, and then attempt to re-commit
it and to abort it - those operations should fail with an
IllegalStateException . |
void |
test_newTx_readOnly()
Unit test for a new read-only transaction.
|
void |
test_newTx_readWrite_01()
Create a new read-write tx and then abort it.
|
void |
test_newTx_readWrite_02()
Create a new read-write tx and then commit it.
|
void |
test_newTx_readWrite_03()
Create two read-write transactions and commit both.
|
void |
test_newTx_readWrite_txComplete_postConditions()
Create a read-write transaction, commit it, and then attempt to re-commit
it and to abort it - those operations should fail with an
IllegalStateException . |
void |
test_shutdown_interrupted()
Test that shutdown() may be interrupted while waiting for a tx to
complete and that it will convert to shutdownNow() which does not wait.
|
void |
test_shutdown_newTxNotAllowed()
Test that shutdown() does not permit new tx to start (a variety of things
are not permitted during shutdown).
|
void |
test_shutdown_nothingRunning()
Verifies that we can shutdown() the service when there are no
active transactions.
|
void |
test_shutdown_waitsForReadOnlyTx_aborts()
Test that the service will wait for a read-only tx to abort.
|
void |
test_shutdown_waitsForReadOnlyTx_commits()
Test that the service will wait for a read-only tx to commit.
|
void |
test_shutdown_waitsForReadWriteTx_aborts()
Test that the service will wait for a read-write tx to abort.
|
void |
test_shutdown_waitsForReadWriteTx_commits()
Test that the service will wait for a read-write tx to commit.
|
void |
test_updateReleaseTime_noTxRemaining()
Test verifies the advance of the release time when the earliest running
transaction completes.
|
void |
test_updateReleaseTime_otherTxStillActive()
A unit test of advancing the last release time for the case where there
are still active transactions running once the earliest active
transaction commits.
|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsWithinUlps, assertSameArray, assertSameArray, assertSameBigDecimal, assertSameBigDecimal, assertSameBigInteger, assertSameBigInteger, assertSameIterator, assertSameIterator, assertSameIteratorAnyOrder, assertSameIteratorAnyOrder, assertSameValue, assertSameValue, assertZeroUlps, assertZeroUlps, fail, getInnerCause, getNormalInt, getProjectBuildPath, getProperties, getRandomObject, getRandomObject, getRandomOrder, getRandomString, getTestInputStream, getTestResource, getTestResource, getUlps, getUlps, isDEBUG, isDEBUG, isINFO, isINFO, isInnerCause, logProperties
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
public TestTransactionService()
public TestTransactionService(String arg0)
arg0
- protected TestTransactionService.MockTransactionService newFixture()
protected TestTransactionService.MockTransactionService newFixture(Properties p)
public void test_newTx_readWrite_01()
Note: New read-write transaction identifiers are assigned using
ITimestampService.nextTimestamp()
. Therefore they are
monotonically increasing. New read-write transactions may be created at
any time - there are no preconditions other than that the transaction
service is running. Likewise there is no contention other than for the
next distinct timestamp.
public void test_newTx_readWrite_02()
public void test_newTx_readWrite_03()
public void test_newTx_readWrite_txComplete_postConditions()
IllegalStateException
.public void test_newTx_readCommitted01() throws IOException
Note: A "read-committed" transactions is just a shorthand for a read-only transaction whose start time is the last commit time on the database. As such the abort and commit procedure are the same as for a read-only transaction. The only difference is in how the start time of the transaction is generated, so that is all we test here.
IOException
public void test_newTx_readCommitted02()
public void test_newTx_readOnly() throws IOException
Read-only transactions are allowed to read on historical commit points of the database. The edge case is allowed where the callers timestamp exactly corresponds to the lastCommitTime, but it is not permitted to be GT the lastCommitTime since that could allow data not yet committed to become visible during the transaction (breaking isolation).
A commitTime is identified by looking up the callers timestamp in a log of the historical commit times and returning the first historical commit time LTE the callers timestamp.
The transaction start time is then chosen from the half-open interval commitTime (inclusive lower bound) : nextCommitTime (exclusive upper bound).
Note: This test (used to) fail occasionally. This occured if the
timestamps assigned by the TestTransactionService.MockTransactionService
are only 1 unit
apart. When that happens, there are not enough distinct values available
to allow 2 concurrent read-only transactions. See ISSUE#145 .
Also see TestTransactionService.MockTransactionService.nextTimestamp()
which has been
overridden to guarantee that there are at least two distinct values such
that this test will pass.
IOException
public void test_newTx_readOnly_contention() throws IOException
IOException
public void test_newTx_readOnly_timestamp_is_lastCommitTime() throws IOException
IOException
public void test_newTx_nothingCommitted_readOnlyTx()
AbstractTransactionService
when there
are no commit points and a read-only transaction is requested. Since
there are no commit points, the transaction service will return the next
timestamp. That value will be GT the requested timestamp and LT any
commit point (all commit points are in the future).public void test_newTx_nothingCommitted_readWriteTx()
AbstractTransactionService
when there
are no commit points and a read-write transaction is requested. You can
always obtain a read-write transaction, even when there are no commit
points on the database.public void test_newTx_readOnly_timestampInFuture()
public void test_newTx_readOnly_releaseTimeRespectsReadsOnCommitTime() throws IOException
IOException
https://sourceforge.net/apps/trac/bigdata/ticket/467
public void test_newTx_readOnly_historyGone() throws IOException
The test is setup as follows:
+------tx2--------------- +-----------------tx1---------------+ +-----------tx0---------+ +=====================================================+ +======================== 0-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ tx0 | tx1 | | | tx2 | | (0) ts1 (0) ts2 | ts3 (ct0) ts4 | ct0 ct1 rt=0 rt=ct0-1where tx0, ... are transactions.
Any transaction which starts before ct1 will see the history going back to commitTime=0. This commit time is initially available because there is no committed data. It is pinned by tx0 and then by tx1. Once both of those transactions complete, that commit time is released (minReleaseAge is zero).
When tx1 completes, the release time is advanced (rt=ct0-1).
Any transaction which starts after tx2 will see history back to ct0.
IOException
public void test_newTx_readOnly_historyGone2() throws IOException
test_newTx_readOnly_historyGone()
where we
do not start tx2. In this case, when we end tx1 the release time will
advance right up to the most recent commit time.
The test is setup as follows:
+-----------------tx1---------------+ +-----------tx0---------+ +=====================================================+ 0-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ tx0 | tx1 | | | | | (0) ts1 (0) ts2 | ts3 | ct0 ct1 rt=0 rt=now-1where tx0, ... are transactions.
Any transaction which starts before ct1 will see the history going back to commitTime=0. This commit time is initially available because there is no committed data. It is pinned by tx0 and then by tx1. Once both of those transactions complete, that commit time is released (minReleaseAge is zero).
When tx1 completes, the release time is advanced (rt=now-1).
Any transaction which starts after ct1 will see read on ct1.
IOException
public void test_updateReleaseTime_noTxRemaining() throws IOException
IOException
public void test_updateReleaseTime_otherTxStillActive() throws IOException
IOException
public void test_newTx_readOnly_txComplete_postConditions() throws IOException
IllegalStateException
.IOException
public void test_shutdown_nothingRunning()
public void test_shutdown_waitsForReadWriteTx_commits() throws InterruptedException
InterruptedException
public void test_shutdown_waitsForReadWriteTx_aborts() throws InterruptedException
InterruptedException
public void test_shutdown_newTxNotAllowed() throws InterruptedException
InterruptedException
public void test_shutdown_waitsForReadOnlyTx_commits() throws InterruptedException
InterruptedException
public void test_shutdown_waitsForReadOnlyTx_aborts() throws InterruptedException
InterruptedException
public void test_shutdown_interrupted() throws InterruptedException
InterruptedException
public void test_abortAll() throws InterruptedException
AbstractTransactionService.abortAllTx()
.InterruptedException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.