Skip to content

Category:RandomQueryGeneratorReporters

philip-stoev edited this page Jul 17, 2012 · 1 revision

Category:RandomQueryGenerator

Overview

The Reporters are extra modules that perform checks on the server while the test is running and after the test has terminated. Unlike Validators, they are not related to the result of a particular query and are run in a separate monitoring process. By default, the Deadlock, ErrorLog and Backtrace are enabled.

Interface

A Reporter is a Perl module that inherits from the GenTest::Reporter class. It has the following methods:

  • type()
Returns the type of the reporter, which may be one or more (OR-ed) of the following constants:

- REPORTER_TYPE_PERIODIC - the Reporter's monitor() method is called once every 10 seconds during the test;

- REPORTER_TYPE_CRASH - the Reporter's report() method is called if the test fails due to a server crash. This is used by the Backtrace reporter to print the crash backtrace from the core file;

- REPORTER_TYPE_DEADLOCK - the report() method is called if a server deadlock or hang is detected;

- REPORTER_TYPE_DATA - the report() method is called if the test was terminated due to a data length or content mismatch;

- REPORTER_TYPE_SERVER_KILLED - report() is called in case the server was killed or shut down during the test;

- REPORTER_TYPE_SUCCESS - the report() method is called if the test was successfull;

- REPORTER_TYPE_ALWAYS - report() is called at the end of the test regardless of how the test ended;

  • monitor()
If the Reporter is defined as REPORTER_TYPE_PERIODIC, its monitor() method will be called once every 10 seconds. Since individual Reporters are executed sequentially within the same thread, it is important not to sleep() inside monitor() so that the other Reporters also have their chance to run.

If you wish to execute a particular action at a particular time, rather than periodically, return STATUS_OK until it is time to act:

   if (time() > $reporter->testEnd() - 10) {
     # Test will terminate in 10 seconds, so it is time to do our thing
     ...
   } else {
     return STATUS_OK;
   }
 }

Available Reporters

The following Reporters are available:

  • Deadlock - this Reporter checks whether the server has deadlocked. It A deadlock is declared if the server does not accept new connections or there are more than three queries that have taken more than 5 minutes to run. Once a deadlock is declared, the server process is forced to produce a core (either by killing it with SIGSEGV or by using cdb). This would trigger the Backtrace reporter to actually dump the backtraces of the deadlocked threads.
  • ErrorLog - this reporter prints the last 100 lines from the server error log to stdout. Those lines are likely to contain the backtrace as produced by the server, and possibly deadlock information (for the Falcon storage engine). Printing those lines to STDOUT makes this information visible in the test output.
  • Backtrace - if the test results in a crash or a deadlock, this Reporter prints a backtrace of the currently executing thread and all threads from the server. The Reporter attempts to call a platform-specific debugger on every platform, in order to produce useable backtraces. The following debuggers are used: gdb (GNU), mdb (Solaris) and cdb (Windows), with the hope that at least of one them will produce a useable result.
  • Recovery - if enabled, this monitor will kill the server about 20 seconds before the expected end of the test (based on the --duration parameter. A recovery will then be initiated and failure will be reported in case the recovery did not succeed. In addition, each table on the server will be read using various index access methods, and any discrepancies in the result sets will be reported. (Killing the server while the testing processes are still running will inevitably produce some "connection lost" messages. However, waiting for the testing processes to complete before killing the server would mean no active transactions will be present, possibly masking bugs in the recovery.)
  • Shutdown - initiates a graceful shutdown at the end of the test.