|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.hd.d.pg2k.test.dev.SystemVariablesTest
public final class SystemVariablesTest
Test the behaviour of system variables. This includes as stand-alone objects, in variable-manager caches, in pipelines and tunnels, etc.
| Nested Class Summary | |
|---|---|
(package private) static class |
SystemVariablesTest.BasicVarMgrEndpoint
Simple final pipeline stage (a master endpoint) variable values. |
(package private) static class |
SystemVariablesTest.EventValueRequestMonitor
Observe upstream accesses to event values. |
(package private) static class |
SystemVariablesTest.LocalTunnelServer
Class to encapsulate "local" tunnel "server". |
(package private) static class |
SystemVariablesTest.LocalTunnelSource
Local tunnel client/source, for connecting to LocalTunnelServer. |
(package private) static class |
SystemVariablesTest.TestVarCacheStage
Simple pipeline stage that caches variable values. |
| Field Summary | |
|---|---|
private static SimpleLoggerIF |
logger
|
private static boolean |
RANDOMISE_VARIABLE_TEST_ORDER
If true, randomise order of variable tests (and skip some if we are short of time). |
private static java.util.Random |
rnd
Private source of OK pseudo-random numbers. |
private java.util.Timer |
t
Timer that we can use to run pipelines; never null during tests. |
| Constructor Summary | |
|---|---|
SystemVariablesTest(java.lang.String name)
|
|
| Method Summary | |
|---|---|
private static void |
_checkGlobalMerge(java.util.List<BasicVarMgrInterface[]> livePipes,
long stopBy)
Check global variable propagation and merge. |
private static void |
_setUpLocalVars(SimpleVariableDefinition[] localWritableTestVars,
BasicVarMgrInterface[][] pipelines,
int nPipes,
java.util.List<SimpleVariableDefinition>[] what,
SimpleVariableValue[] values)
Set random variables on random pipes for testing later. |
private static void |
_testLocalNonPropagation(SimpleVariableValue[] values,
int nPipes,
BasicVarMgrInterface[][] pipelines,
java.util.List[] what)
Run after _setUpLocalVars() to ensure that locals did NOT propagate between pipelines. |
private static void |
checkIllegalGetSetOpsVetoedCorrectly(BasicVarMgrInterface[] pipeline,
long stopBy)
This checks that operations are vetoed when they should be. |
private void |
checkShortPipelineVarMgr(boolean writeThrough)
Check a short pipeline with a single PipelineVarMgr stage. |
private static void |
checkSimpleSetGet(SimpleVariablePipelineIF[] pipeline,
long stopBy)
Test set and get of globals and locals. |
private static InstanceID |
checkSystemIDHandling(BasicVarMgrInterface[] pipeline,
long stopBy)
Check that the pipeline handles system ID correctly. |
static boolean |
checkValuePresent(SimpleVariableValue[] vars,
SimpleVariableValue svv)
Returns true iff the specified variable is present in the array with the specified value. |
(package private) static SimpleVariableDefinition |
makeRandomSimpleVariableDefinition()
Makes a random definition; never returns null. |
(package private) static SimpleVariableValue |
makeRandomSimpleVariableValue(SimpleVariableDefinition def)
Given a variable definition, make a random value for it; never null. |
private static boolean |
notAfter(long stopBy)
Returns true if time is not after that stated. |
static void |
pipelineVariableTest(SimpleVariablePipelineIF[] slave1,
SimpleVariablePipelineIF[] slave2,
SimpleVariablePipelineIF[] master,
long stopBy)
Driver routine to test variable handling in pipelines. |
protected void |
setUp()
Do any setup needed for the tests. |
static InstanceID |
singlePipelineTest(SimpleVariablePipelineIF[] pipeline,
long stopBy)
Run variable tests on one pipeline ans returns the InstanceID; never null. |
protected void |
tearDown()
Do any clearup needed after the tests. |
void |
testArbitraryVarConstruction()
Test that variables of fairly arbitrary names/types can be constructed. |
void |
testAuthEventValueGenerationAndCacheing()
Test correct generation and handling of authoritative event values. |
void |
testBasicEventHandling()
Do very basic event-handling tests. |
void |
testBasicVarMgrAsEndPoint()
Test basic variable manager behaviour for the endpoint. |
void |
testBasicVarMgrAsPipelineEndpoint()
Check BasicVarMgr embedded at the end of a pipeline. |
void |
testEPCMComputationDoesNotRefetchEventHistory()
Test that (re)computing ExhibitPropsComputableMutable data does not cause redundant event data fetches. |
void |
testEventBucketting()
Check that events are correctly split into multiple periods. |
void |
testEventCollectionSerialisation()
Check that the various event objects/collections can be (de)serialised. |
void |
testEventHistoryPeristence()
Test that we can persist the event histories. |
void |
testGlobalVariableOps()
Test basic setting/getting of global variables. |
void |
testInstanceID()
Do simple tests on InstanceID type... |
void |
testLocalTunnelEventSimple()
Do simple test of tunnel connectivity for set()ting and get()ting events. |
void |
testLocalTunnelFull()
Run full tunnel variable test. |
void |
testLocalTunnelSimple()
Do simple test of tunnel connectivity. |
void |
testLocalVariableOps()
Test basic setting/getting of local variables. |
void |
testPipelineVarMgrLong()
Test several PipelineVarMgr stages in a long pipeline. |
void |
testPipelineVarMgrSimpleNonWriteThrough()
Test PipelineVarMgr in pipeline in non-write-through mode. |
void |
testPipelineVarMgrSimpleWriteThrough()
Test PipelineVarMgr in pipeline in write-through mode. |
void |
testSimpleExhibitPipelineFilterVariableHandling()
Check vanilla SimpleExhibitPipelineFilter embedded in a pipeline. |
void |
testSimpleNumberStats()
Test that we can correctly generate stats safely. |
void |
testSimpleSerialisation()
Check some simple (de)serialistion works as expected. |
void |
testSimpleVarStats()
Test simple variable stats. |
void |
testTypeNumber()
Test handling of TYPE_NUMBER values. |
| Methods inherited from class junit.framework.TestCase |
|---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString |
| Methods inherited from class junit.framework.Assert |
|---|
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, fail, fail |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final SimpleLoggerIF logger
private java.util.Timer t
private static final boolean RANDOMISE_VARIABLE_TEST_ORDER
This allows us to do as few as one test each time, on the grounds that we will test the entire range over time.
private static final java.util.Random rnd
| Constructor Detail |
|---|
public SystemVariablesTest(java.lang.String name)
| Method Detail |
|---|
protected void setUp()
setUp in class junit.framework.TestCaseprotected void tearDown()
tearDown in class junit.framework.TestCase
public void testSimpleSerialisation()
throws java.lang.Exception
However, it should still be possible to (de)serialise definitions (and compound values containing them) that are no longer legitimate system variable (and do not conflict with them) so that we can examine historical data for example.
java.lang.Exception
public void testInstanceID()
throws java.lang.Exception
java.lang.Exception
public void testArbitraryVarConstruction()
throws java.lang.Exception
java.lang.Exceptionpublic void testBasicVarMgrAsEndPoint()
public void testLocalVariableOps()
throws java.lang.Exception
java.lang.Exception
public void testGlobalVariableOps()
throws java.lang.Exception
java.lang.Exception
public void testTypeNumber()
throws java.lang.Exception
java.lang.Exception
public void testBasicVarMgrAsPipelineEndpoint()
throws java.lang.Exception
java.lang.Exception
public void testSimpleExhibitPipelineFilterVariableHandling()
throws java.lang.Exception
java.lang.Exception
public void testPipelineVarMgrSimpleWriteThrough()
throws java.lang.Exception
Write-though mode is faster and "safer" but may incur higher costs, eg sending updates over a tunnel.
java.lang.Exception
public void testPipelineVarMgrSimpleNonWriteThrough()
throws java.lang.Exception
Non-write-though mode groups writes together and eliminates redundant writes for efficiency, but delays writes and thus information propagation.
java.lang.Exception
private void checkShortPipelineVarMgr(boolean writeThrough)
throws java.lang.InterruptedException,
java.io.IOException
We run this stand-alonw because as of 20040808 the non-write-though implementation was buggy/lossy.
writeThrough -
java.lang.InterruptedException
java.io.IOException
public void testPipelineVarMgrLong()
throws java.lang.Exception
Normally it would not be sensible to stack several cache stages like this because of latency problems, so this is somewhat harsh.
java.lang.Exception
public static boolean checkValuePresent(SimpleVariableValue[] vars,
SimpleVariableValue svv)
svv - variable/value to check for; must not be null
public static void pipelineVariableTest(SimpleVariablePipelineIF[] slave1,
SimpleVariablePipelineIF[] slave2,
SimpleVariablePipelineIF[] master,
long stopBy)
throws java.io.IOException,
java.lang.InterruptedException
The pipeline order is downstream-first, end-point-last, eg the persistent store or tunnel for a pipeline would be at the highest-numbered index, and the normal access point for the tunnel (eg as exposed by the DataSourceBean) is at index 0.
Takes in-order lists of taps/entrypoints on a data pipeline, the first (two) being separate slaves (before a tunnel) and the last being in a master (after a tunnel). All but one of the lists can be null (but never empty).
Internal correctness tests will be run on each of the constituent slave/master pipelines.
The parameter arrays must not be altered while the tests are running.
This checks that:
slave1 - pipeline for slave 1; null or non-emptyslave2 - pipeline for slave 2; null or non-emptymaster - pipeline for master; null or non-empty
java.io.IOException - if an inappropriate IOException is thrown by
the pipeline under test
java.lang.InterruptedException
private static void _checkGlobalMerge(java.util.List<BasicVarMgrInterface[]> livePipes,
long stopBy)
throws java.lang.InterruptedException
This does not alter its parameters, though sets/gets values in them.
livePipes - list of pipelines of participating systems;
no pipelines are null or emptystopBy - time to attempt to stop by
java.lang.InterruptedExceptionstatic SimpleVariableValue makeRandomSimpleVariableValue(SimpleVariableDefinition def)
Conversely, for restricted types such as TYPE_NONE, little or no practical variation is possible.
Non-local values are generated without a globalMap; the results of several calls to this function can be merged with put() to generate a non-empty globalMap if desired.
Package-visible so as to be available to other test routines.
def - definition for which value is wanted; never null
private static void _testLocalNonPropagation(SimpleVariableValue[] values,
int nPipes,
BasicVarMgrInterface[][] pipelines,
java.util.List[] what)
values - nPipes - pipelines - what -
private static void _setUpLocalVars(SimpleVariableDefinition[] localWritableTestVars,
BasicVarMgrInterface[][] pipelines,
int nPipes,
java.util.List<SimpleVariableDefinition>[] what,
SimpleVariableValue[] values)
There must be at least a master and one slave for this to be meaningful.
localWritableTestVars - pipelines - nPipes - what - values -
public static InstanceID singlePipelineTest(SimpleVariablePipelineIF[] pipeline,
long stopBy)
throws java.io.IOException,
java.lang.InterruptedException
Used by pipelineVariableTest().
Throws an exception, assertion or fail()s upon discovering a problem.
Tests that:
The pipeline order is downstream-first, end-point-last, eg the persistent store or tunnel for a pipeline would be at the highest-numbered index, and the normal access point for the tunnel (eg as exposed by the DataSourceBean) is at index 0.
pipeline - one or more stages/taps on a pipeline in order,
downstream first,
never null nor empty nor containing null or duplicate entriesstopBy - stop testing by or soon after this time,
having done at least one of each type of test
java.io.IOException - if an inappropriate IOException is thrown by
the pipeline under test
java.lang.InterruptedException
private static void checkSimpleSetGet(SimpleVariablePipelineIF[] pipeline,
long stopBy)
throws java.lang.InterruptedException
Also tests that variable set operations are not visibly reordered, eg that cacheing and tunnel (etc) staged do not cause re-ordering.
Tests that locals (that we set) never get a (non-null) globalMap.
pipeline - pipeline; non-null, non-zero-lengthstopBy - time to stop running tests by, if possible
java.lang.InterruptedException
private static InstanceID checkSystemIDHandling(BasicVarMgrInterface[] pipeline,
long stopBy)
throws java.io.IOException
pipeline - pipeline; non-null, non-zero-lengthstopBy - time to stop running tests by, if possible
java.io.IOException
private static void checkIllegalGetSetOpsVetoedCorrectly(BasicVarMgrInterface[] pipeline,
long stopBy)
pipeline - pipeline; non-null, non-zero-lengthstopBy - time to stop running tests by, if possiblestatic SimpleVariableDefinition makeRandomSimpleVariableDefinition()
Package-visible so as to be available to other test routines.
public void testLocalTunnelSimple()
throws java.lang.Exception
We explicitly check that getting/setting a novel variable on the slave (ie not known to the master) is quietly ignored and does not cause any exception/failure.
This is a very simple test; look elsewhere for comprehensive tests!
java.lang.Exception
public void testLocalTunnelFull()
throws java.lang.Exception
One of the tunnels forces full (de)serialisation of its RPC traffic, thus exercising much of the HTTP tunnel code in passing.
We poll() all the pipelines at different speeds to ensure that rate synchronisation is not critical to correct functioning.
java.lang.Exceptionpublic void testSimpleNumberStats()
TODO: Test with local value
public void testSimpleVarStats()
public void testBasicEventHandling()
throws java.lang.Exception
java.lang.Exception
public void testEventBucketting()
throws java.lang.Exception
java.lang.Exception
public void testLocalTunnelEventSimple()
throws java.lang.Exception
This is a very simple test; look elsewhere for comprehensive tests!
java.lang.Exception
public void testEventCollectionSerialisation()
throws java.lang.Exception
java.lang.Exception
public void testEventHistoryPeristence()
throws java.lang.Exception
java.lang.Exception
public void testAuthEventValueGenerationAndCacheing()
throws java.io.IOException
Check that these are cached correctly by a pipeline cache stage and not redundantly requested from the source. This is important to ensure that slaves do not waste time and bandwidth in redundantly re-requesting past values from the master.
java.io.IOException
public void testEPCMComputationDoesNotRefetchEventHistory()
throws java.lang.Exception
java.lang.Exceptionprivate static boolean notAfter(long stopBy)
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||