

Public Member Functions | |
| void | testSendLogRecords () |
| void | testFlushByRecordNumber () |
| void | testPeriodicFlush () |
| void | testUnavailableRemoteLogService () throws Exception |
| void | testFailingRecords () |
| void | testQueueOverflow () |
Protected Member Functions | |
| void | setUp () throws Exception |
| void | tearDown () throws Exception |
Private Member Functions | |
| void | sleep (long millis) |
Private Attributes | |
| ORB | orb |
| TestLogDispatcher | dispatcher |
| DispatchingLogQueue | queue |
| CollectingLogger | collectingLogger |
| TestAcsXMLLogFormatter | formatter |
| void alma::acs::logging::RemoteLogDispatcherTest::setUp | ( | ) | throws Exception [inline, protected] |
JUnit's class re-loading strategy fails for these tests, so the setUp must reset the state of the member variables
References alma::acs::testsupport::LogRecordCollectingLogger::clearLogRecords(), collectingLogger, dispatcher, formatter, alma::acs::testsupport::LogRecordCollectingLogger::getCollectingLogger(), orb, queue, and alma::acs::testsupport::LogRecordCollectingLogger::suppressLogs().
| void alma::acs::logging::RemoteLogDispatcherTest::sleep | ( | long | millis | ) | [inline, private] |
Referenced by testFlushByRecordNumber(), testPeriodicFlush(), testQueueOverflow(), and testUnavailableRemoteLogService().
| void alma::acs::logging::RemoteLogDispatcherTest::tearDown | ( | ) | throws Exception [inline, protected] |
References queue, and alma::acs::logging::DispatchingLogQueue::shutDown().
| void alma::acs::logging::RemoteLogDispatcherTest::testFailingRecords | ( | ) | [inline] |
Tests that a failure in XML formatting leads to dropping of the records.
Then tests that even with a 70% chance of failure in dispatching the log records will eventually send all records, due to the records being taken out and re-inserted in the queue. Chances to add an additional record to the queue are fairly low because the simulated failure in writeRecords(..) occurs immediately (before the 200ms sleep we otherwise get)
References collectingLogger, dispatcher, alma::acs::logging::DispatchingLogQueue::flushAllAndWait(), formatter, alma::acs::testsupport::LogRecordCollectingLogger::getCollectedLogRecords(), alma::acs::logging::TestLogDispatcher::getCollectedXmlLogRecords(), alma::acs::logging::DispatchingLogQueue::log(), alma::acs::logging::CollectingLogger::produceLogs1(), queue, alma::acs::logging::RemoteLogDispatcher::setBufferSize(), alma::acs::logging::TestAcsXMLLogFormatter::setFormatFailureChance(), alma::acs::logging::DispatchingLogQueue::setRemoteLogDispatcher(), and alma::acs::logging::TestLogDispatcher::setWriteFailureChance().
| void alma::acs::logging::RemoteLogDispatcherTest::testFlushByRecordNumber | ( | ) | [inline] |
Sends as many LogRecords via DispatchingLogQueue#log(LogRecord) that the buffer size ("dispatchPacketSize") is not quite reached, and verifies that all these logs are still queued.
Then sends another LogRecord and verifies that (now that the buffer was full) all LogRecords are forwarded from the queue to the dispatcher.
Finally this test verifies that the dispatcher applies the time sorting correctly, thus restoring the original order of LogRecords. (The queue should sort by log level, but since in this test all records fit into one buffer, the original order should be restored.)
References collectingLogger, dispatcher, alma::acs::testsupport::LogRecordCollectingLogger::getCollectedLogRecords(), alma::acs::logging::TestLogDispatcher::getCollectedXmlLogRecords(), alma::acs::logging::DispatchingLogQueue::log(), alma::acs::logging::CollectingLogger::produceLogs1(), queue, alma::acs::logging::RemoteLogDispatcher::setBufferSize(), alma::acs::logging::DispatchingLogQueue::setRemoteLogDispatcher(), and sleep().
| void alma::acs::logging::RemoteLogDispatcherTest::testPeriodicFlush | ( | ) | [inline] |
Sets up DispatchingLogQueue for periodic flushing every 2 seconds (cp. CDB attribute "flushPeriodSeconds") and sends some LogRecords to the queue. (Flushing by record number is disabled by using a sufficiently large buffer, see also testFlushByRecordNumber()). Then verifies that after the flushing period the log records have been forwarded to the dispatcher.
Then sends many more log records than fit into one buffer, thus testing the triggering of subsequent flushes until the queue is drained, and that this mechanism still works while we have scheduled flushing in place.
Finally stops the scheduled flushing and verifies that it's gone.
References alma::acs::logging::TestLogDispatcher::clearCollectedXmlLogRecords(), alma::acs::testsupport::LogRecordCollectingLogger::clearLogRecords(), collectingLogger, dispatcher, alma::acs::logging::DispatchingLogQueue::flushesPeriodically(), alma::acs::testsupport::LogRecordCollectingLogger::getCollectedLogRecords(), alma::acs::logging::TestLogDispatcher::getCollectedXmlLogRecords(), alma::acs::logging::DispatchingLogQueue::log(), alma::acs::logging::DispatchingLogQueue::pendingFlushes(), alma::acs::logging::CollectingLogger::produceLogs1(), queue, alma::acs::logging::DispatchingLogQueue::realQueueSize(), alma::acs::logging::RemoteLogDispatcher::setBufferSize(), alma::acs::logging::DispatchingLogQueue::setPeriodicFlushing(), alma::acs::logging::DispatchingLogQueue::setRemoteLogDispatcher(), and sleep().
| void alma::acs::logging::RemoteLogDispatcherTest::testQueueOverflow | ( | ) | [inline] |
TODO: investigate the occasional test failure overflowing log queue accepted/rejected wrong number of records ('filterThreshold'=700) expected: 850 but was:851
Most likely this comes from log records being temporarily removed and then reinserted to the queue.
References collectingLogger, dispatcher, alma::acs::logging::RemoteLogDispatcher::getBufferSize(), alma::acs::testsupport::LogRecordCollectingLogger::getCollectedLogRecords(), alma::acs::logging::DispatchingLogQueue::getMaxQueueSize(), alma::acs::logging::DispatchingLogQueue::log(), alma::acs::logging::CollectingLogger::produceLogs1(), queue, alma::acs::logging::DispatchingLogQueue::recordQueueSize(), alma::acs::logging::DispatchingLogQueue::setRemoteLogDispatcher(), alma::acs::logging::TestLogDispatcher::setVerbose(), alma::acs::logging::TestLogDispatcher::setWriteFailureChance(), and sleep().
| void alma::acs::logging::RemoteLogDispatcherTest::testSendLogRecords | ( | ) | [inline] |
Sends a sequence of LogRecords to the TestLogDispatcher and compares the number and ordering of the gathered XML records with those sent. This effectively tests RemoteLogDispatcher#sendLogRecords(LogRecord[]).
References alma::acs::testsupport::LogRecordCollectingLogger::clearLogRecords(), collectingLogger, dispatcher, formatter, alma::acs::testsupport::LogRecordCollectingLogger::getCollectedLogRecords(), alma::acs::logging::TestLogDispatcher::getCollectedXmlLogRecords(), orb, alma::acs::logging::CollectingLogger::produceLogs1(), alma::acs::logging::RemoteLogDispatcher::sendLogRecords(), and alma::acs::logging::RemoteLogDispatcher::useAcsLogServiceExtensions.
| void alma::acs::logging::RemoteLogDispatcherTest::testUnavailableRemoteLogService | ( | ) | throws Exception [inline] |
Submits LogRecords to DispatchingLogQueue without having hooked up the RemoteLogDispatcher yet (as it happens during a container start), and checks that all records are queued.
Then adds the dispatcher, flushes the queue, and verifies that DispatchingLogQueue#flush() flushes some records, while a subsequent DispatchingLogQueue#flushAllAndWait() flushes all records and leaves the queue in a clean state without further flushing requests.
References alma::acs::logging::TestLogDispatcher::clearCollectedXmlLogRecords(), collectingLogger, dispatcher, alma::acs::logging::DispatchingLogQueue::flush(), alma::acs::logging::DispatchingLogQueue::flushAllAndWait(), alma::acs::testsupport::LogRecordCollectingLogger::getCollectedLogRecords(), alma::acs::logging::TestLogDispatcher::getCollectedXmlLogRecords(), alma::acs::logging::DispatchingLogQueue::log(), alma::acs::logging::DispatchingLogQueue::pendingFlushes(), alma::acs::logging::CollectingLogger::produceLogs1(), queue, alma::acs::logging::DispatchingLogQueue::recordQueueSize(), alma::acs::logging::RemoteLogDispatcher::setBufferSize(), alma::acs::logging::DispatchingLogQueue::setRemoteLogDispatcher(), alma::acs::logging::TestLogDispatcher::setVerbose(), and sleep().
Referenced by setUp(), testFailingRecords(), and testSendLogRecords().
ORB alma::acs::logging::RemoteLogDispatcherTest::orb [private] |
Referenced by setUp(), and testSendLogRecords().
1.6.2