Receiving and storing debug information

Use the TestDriver API to set up a test driver instance that receives debug information from specified solution agents and caches the information. You can load test entities into the grid and submit test events for processing. From a test driver instance, use the DebugReceiver interface to capture outbound information from the events for debugging and problem determination.

About this task

Create a test driver instance by using the methods in the TestDriver API. The test driver instance connects to the server over a specific port or ports and sends the server a solution identifier and list of solution agents. This list, which is stored as properties in the testdriver.properties file, indicates which agents can send information to the test driver instance. When an event is received by a server and an agent that matches the properties, the event is sent to the test driver instance. Using the DebugReceiver interface, you can create an event cache to capture the information for debugging and problem determination.

The testdriver.properties file contains connectivity and server properties to set up the test driver instance, control which solutions and agents send information, and limit the amount of information that is cached. You can set several key properties to enable the test driver instance to receive debug information, including debugServers and debugAgentList in the properties file, and debugPort on the server.

The TestDriver API helps you monitor and capture event debug information that is generated by an external system and then picked up by an Insight Server. If a test driver instance is connected to the server and the agent that processes events is listed in the testdriver.properties file, then the debug information from the events is received and stored regardless of where the debug information originated.

Procedure

  1. Create a Java™ project by using the TestDriver API methods as described in Creating a test client project.
  2. Run the propertyManager set command to configure the server debug port property, or range of ports. For example:
    propertyManager set --username=tester --password=tester debugPort=6543
    The following example sets a range of possible debug ports:
    propertyManager set --username=tester --password=tester debugPort=6543-6600 
  3. Configure a test driver instance to receive debug information. Using a text editor, add property names and values to the testdriver.properties file. The host and port that is specified in the debugServers property must match the debugPort property that you set in the previous step. The following example shows a testdriver.properties file that modifies the default host name and port, and provides the solution name and authentication credentials for the tester account.
    solutionName=OilServiceSolution
    host=server1
    port=9443
    debugServers=localhost:6543
    debugAgentList=agent1,agent2
    username=tester
    password=tester
    See Test driver properties for property descriptions and examples. You can also set the test driver properties programmatically by calling the DriverProperties class from a Java project.
    Tip: Create the properties file in the current directory where the Java application is started, or in a location that is defined by the TESTDRIVER_HOME environment variable.
  4. Use the DebugReceiver interface to create a debug receiver instance. The interface defines an entry point for DebugInfo by using the addDebugInfo method. The addDebugInfo method is called when the server sends debug information to the test driver client. For example, the following method captures global aggregate values at the time of the test and emits an event with this data:
    public void addDebugInfo(DebugInfo debugInfo, String sourceAgent) {
       Event event = driver.getAgentEvent(debugInfo);
       if (event instanceof TransactionReceipt) {
          TransactionReceipt txReceipt = (TransactionReceipt) event;
          String customerId = txReceipt.getCustomer().getKey();
          double avgTxAmtLast24hrs = txReceipt.getAvgTxAmtLast24hrs();
          double maxTxAmtLast24hrs = txReceipt.getMaxTransactionAmountLast24hrs();
          double numBronze = txReceipt.getNumberOfBronzeCustomers();
          double numGold = txReceipt.getNumberOfGoldCustomers();
          double numPlat = txReceipt.getNumberOfPlatinumCustomers();
          Duration d = Duration.between(firstEventTime, event.get$Timestamp());
          System.out.println(String.format("TXRecepit [%s] hoursSinceFirstEvent=%s, avgTxAmtLast24hrs=%s, maxTxAmtLast24hrs=%s, numPlat=%s, numGold=%s, numBronze=%s, customer=%s, amount=%s",
          event.get$Timestamp(), d.toHours(), avgTxAmtLast24hrs, maxTxAmtLast24hrs, numPlat, numGold, numBronze, customerId, txReceipt.getAmount()));
       }
    }
    where the debugInfo parameter represents the debug information and sourceAgent is the name of the agent that generated the information.

    Start with the sample implementation IADebugReceiver and then customize the debug receiver to work in your environment.

  5. Add the debug receiver instance to the test driver client by calling the addDebugReceiver method in the client. For example:
    TestDriver testDriver = null;
    testDriver = new TestDriver();
    DebugReceiver r = new IADebugReceiver();
    testDriver.addDebugReceiver( r );
    testDriver.connect();

Results

The test driver instance connects to the server that is specified in the testdriver.properties file, or in the DriverProperties class. When the connection to the server is established, the server detects all events that are emitted by specific solutions and agents that match the solutionname and debugagentlist properties in the testdriver.properties file. The server then sends debug information from the events to the test driver instance. The test driver instance calls the debug receiver, which captures the information and caches it in memory or stores it in a file.