CCNxTestrig is an application to perform functional tests for CCNx forwarders. It treats the forwarder as a black box and assesses its packet forwarding functionality for correctness. Tests are prescriptive in nature and are built using compile-time test scripts.
For example, the following test script creates a random Interest with the name prefix "ccnx:/test/b", a matching Content Object, and then ensures that the forwarder-under-test will forward these packets correctly. That is, the Interest and Content Object will be routed to the correct links.
// Create the test packets
CCNxName *testName = _createRandomName("ccnx:/test/c");
assertNotNull(testName, "The name must not be NULL");
// Create the protocol messages
CCNxInterest *interest = ccnxInterest_Create(testName, 1000, NULL, NULL);
PARCBuffer *testPayload = parcBuffer_Allocate(1024);
CCNxContentObject *content = ccnxContentObject_CreateWithNameAndPayload(testName, testPayload);
// Build the script
CCNxTestrigScript *script = ccnxTestrigScript_Create(testCaseName);
CCNxTestrigScriptStep *step1 = ccnxTestrigScript_AddSendStep(script, interest, CCNxTestrigLinkID_LinkA);
CCNxTestrigScriptStep *step2 = ccnxTestrigScript_AddReceiveOneStep(script, step1,
ccnxTestrig_GetLinkVector(rig, CCNxTestrigLinkID_LinkC));
CCNxTestrigScriptStep *step3 = ccnxTestrigScript_AddSendStep(script, content, CCNxTestrigLinkID_LinkC);
CCNxTestrigScriptStep *step4 = ccnxTestrigScript_AddReceiveOneStep(script, step3,
ccnxTestrig_GetLinkVector(rig, CCNxTestrigLinkID_LinkA));
// Execute it
CCNxTestrigSuiteTestResult *testCaseResult = ccnxTestrigScript_Execute(script, rig);
The CCNxTestrig application is composed of five primary elements:
-
Testrig: The main application that creates and configures links to the forwarder and then executes (part of or the entirety of) the test suite.
-
Link: An abstraction of a forwarder link connection. Currently, UDP and TCP links are supported.
-
Test suite: A collection of compiled test scripts that are executed.
-
Test script: A set of steps to interact with the forwarder to send and receive packets on specific links.
-
Reporter: A module that produces the test results.
These modules are composed as follows:
+---------+ uses +------------+
| link <--------+ testscript |
+----^----+ +------^-----+
| |
|creates |executes
| |
+------------+ uses +----+----+ +------+-----+
| reporter <--------+ testrig +--------> testsuite |
+------------+ +---------+ +------------+
configures
Test scripts are a prescriptive set of steps that are executed in sequence to send and receive packets to interact with a forwarder. Scripts are created by providing packets to send verifying that they are received correctly. For example, a script step might be to send an Interest to link A attached to the forwarder. To verify receipt, the subsequent step might be a receive step that expects the packet which was sent to be that which was received.
Currently, test scripts must be written in C code. A future extension would be to implement a custom DSL to write these tests and have them compile to their C code equivalents.