public class TestTxDag
extends junit.framework.TestCase
Modifier and Type | Field and Description |
---|---|
static org.apache.log4j.Logger |
log |
Modifier and Type | Method and Description |
---|---|
void |
assertSameEdges(TxDag.Edge[] expected,
TxDag.Edge[] actual)
Compares two Edge[]s and verifies that the same edges are defined without
regard to order.
|
void |
assertSamePathCounts(int[][] expected,
int[][] actual)
Compares two path count matrices for equality.
|
void |
assertSameValues(int[] expected,
int[] actual)
Verifies that actual contains all of the same values as
expected in the same order.
|
void |
assertSameValuesAnyOrder(int[] expected,
int[] actual)
Verifies that actual contains all of the same values as
expected without regard to order.
|
void |
doSymmetricOperationsTest(Random r,
TxDag dag)
Implements the performance test for
testSymmetricOperations() . |
void |
test_addEdge_001()
Simple tests of
TxDag.addEdge(Object, Object) ,
TxDag.hasEdge(Object, Object) and friends. |
void |
test_addEdge_correctRejection_001()
Test for correct rejection of addEdge() when edge already exists.
|
void |
test_addEdge_correctRejection_002()
Test for correct rejection of addEdge() when either parameter is
null or when both parameters are the same.
|
void |
test_addEdges_correctRejection_001()
Test for correct rejection of addEdges() when an edge already exists.
|
void |
test_addEdges_correctRejection_002()
Test for correct rejection of addEdge() when either parameter is
null, when one of the targets is null, or when one of the targets
is given more than once.
|
void |
test_capacity_001()
Test capacity limits.
|
void |
test_ctor()
Constructor tests.
|
void |
test_deadlock_001()
The first in a series of simple tests which verify that the DAG is
correctly detecting updates when a set of new edges would result in a
cycle.
|
void |
test_deadlock_002() |
void |
test_deadlock_003() |
void |
test_deadlock_batch_001() |
void |
test_getOrder_001()
Verify that
TxDag.lookup(Object, boolean) does not cause
TxDag.getOrder() to include the new vertex until an edge has been
asserted for that vertex. |
void |
test_lookup_001()
Test ability to generate unique transaction identifier used by
TxDag to index into its internal arrays. |
void |
test_lookup_002()
Correct rejection test when transaction object is
null . |
void |
test_noCycles__batch_001()
Verify that the DAG state is correctly updated when adding a variety of
WAITS_FOR relationships that do NOT form cycles (using the batch
operation to add edges).
|
void |
test_noCycles_001()
Verify that the DAG state is correctly updated when adding a variety of
WAITS_FOR relationships that do NOT form cycles.
|
void |
test_recyclingIndices()
Verify that we can recycle the internal transaction identifiers when a
transaction is removed from the DAG (either through abort or commit
actions).
|
void |
test_updateClosure_001()
Tests of the update to the internal matrix M[u,v].
|
void |
test_updateClosure_002()
A sequence of tests of the internal state of the
TxDag with a
capacity of 4 after adding an edge. |
void |
testAssertSameEdges()
Some tests to verify
#assertSameEdges(Edge[], Edge[]) . |
void |
testSymmetricOperations()
Test adds N random edges to the graph and then removes them and verifies
that removal correctly reproduces each intermediate state following an
edge addition.
|
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 TestTxDag()
public TestTxDag(String name)
public void test_ctor()
public void test_lookup_001()
TxDag
to index into its internal arrays. This test verifies that
insert is conditional, that lookup fails if tx was not registered, and
that we can insert and then lookup a transaction in the DAG. The test
also verifies that the TxDag.size()
updates as vertices are added
to the graph and does not update when the vertex already exists in the
graph.public void test_lookup_002()
null
.public void test_capacity_001()
public void test_addEdge_001()
TxDag.addEdge(Object, Object)
,
TxDag.hasEdge(Object, Object)
and friends.public void test_addEdge_correctRejection_001()
public void test_addEdge_correctRejection_002()
public void test_addEdges_correctRejection_001()
public void test_addEdges_correctRejection_002()
public void test_getOrder_001()
TxDag.lookup(Object, boolean)
does not cause
TxDag.getOrder()
to include the new vertex until an edge has been
asserted for that vertex.
This also tests TxDag.getOrder(int t, int u)
, which is similar
to TxDag.getOrder()
but it always includes the specified vertices
in the returned int[].
public void assertSameValues(int[] expected, int[] actual)
expected
- An integer array.actual
- Another integer array.public void assertSameValuesAnyOrder(int[] expected, int[] actual)
expected
- An integer array.actual
- Another integer array.public void test_updateClosure_001()
Note: These tests are written directly using the
TxDag.updateClosure(int, int, boolean)
method, so the matrix W is
not actually updated.
public void test_updateClosure_002()
TxDag
with a
capacity of 4
after adding an edge.public void doSymmetricOperationsTest(Random r, TxDag dag)
testSymmetricOperations()
.
Performs random additive operations on the DAG until a deadlock results. The initial state and the state after each additive operation is stored. Once a deadlock is reached, verifies that the last stored state is still valid (deadlock should not update the state of the DAG) and then performs the inverse of each of the addition operations in the reverse order in which they were applied. After each inverse operation, verifies that the state of the DAG corresponds to the state before the corresponding additive operation.
The additive operations and their inverses are:
r
- A random number generator.dag
- A dag with a maximum capacity.public void assertSamePathCounts(int[][] expected, int[][] actual)
expected
- An int[][] matrix with at least two rows and two columns.actual
- Another int[][] matrix with the same dimensions.public void assertSameEdges(TxDag.Edge[] expected, TxDag.Edge[] actual)
expected
- The expected Edge[].actual
- The actual Edge[].public void testAssertSameEdges()
#assertSameEdges(Edge[], Edge[])
.public void test_recyclingIndices()
Transaction objects are application defined. They are mapped into indices
for the internal arrays by TxDag.lookup(Object, boolean)
. Those
indices must be released for reuse by TxDag.releaseVertex(Object)
of the capacity of the graph will be exhausted. This test verifies that
they are.
The test creates and removes vertices repeatedly and verifies that we can create more vertices than would be allowed for by the capacity (therefore suggesting that vertices are being recycled correctly).
public void test_noCycles_001()
public void test_noCycles__batch_001()
public void test_deadlock_001()
public void test_deadlock_002()
public void test_deadlock_003()
public void test_deadlock_batch_001()
public void testSymmetricOperations()
Test adds N random edges to the graph and then removes them and verifies that removal correctly reproduces each intermediate state following an edge addition. Edges are added until a deadlock results. We verify that the deadlock did not update the internal matrix M and then backup state by state removing each edge in the reverse order and verifying that the correct state is reproduced as the edge is removed.
Note: This test uses "small" matrices (20 vertices) to keep the memory footprint down since it makes a copy of the state of the DAG after each action. As the capacity of the graph goes up, this test will begin to stress the garbage collector so more trials and moderate capacity makes more sense.
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.