Product
Search Results

How can I add a specific delay before or after a test case?

In some cases, it may be helpful have CDRouter wait a certain amount of time between test cases. Some implementations may require a certain amount of “cleanup” time before connections can be freed up.

CDRouter has two techniques available for adding delays between tests.

Use the -delay option

The -delay option can be used to insert a delay in seconds before each test case that is run.

Here’s an example:

# cdrouter-cli -delay 60 -module nat.tcl

The drawback to this technique is that the delay is inserted before all test cases.

Add a buddy::pre_test_command or buddy::post_test_command

If you need finer control of the delay before or after a specific test case, you can use the buddy::pre_test_command or buddy::post_test_command to add a customized delay. These commands allow you to define a Tcl procedure that will be run before or after a specific test case. By using the Event_wait procedure, you can create a custom delay. The Event_wait procedure takes an argument that is the number of milliseconds to wait.

The buddy::pre_test_command or the buddy::post_test_command should be placed in the configuration file.

Here’s an example where a 60 second delay is added to the end of the test case cdrouter_nat_100:

buddy::post_test_command cdrouter_nat_100 {

    # display a log message
    buddy::loginfo "Waiting 60 seconds"

    # Event_wait argument is the number of milliseconds
    Event_wait 60000        
}