OpenTTCN/Training/TTCN-3 Basics/Exercises/3.7

From OpenTTCN

Jump to: navigation, search

Exercise 3.7: Using dynamic test configurations

Goal: In this exercise we are learning how to use dynamic test configurations.

Step 1: Using dynamic test configurations

So far we have used quite static configurations where the "runs on" clause of the test case specified the Main Test Component (MTC) where the test case is run. After that we have dynamically (= in the body of the test case) created mappings between MTC and Test System Interface. This is already allows more dynamic connections that were available in TTCN-2 testing language.

We can use far more dynamic test configurations. After the MTC starts executing a test case, the test case can create a number of new test components called Parallel Test Components (PTC). PTCs in turn can create new PTCs. After new PTCs are created, connections between ports of MTC and PTC or between ports of PTC and PTC are created using TTCN-3 connect statements (similar to map statement). These connects can be disconnected using TTCN-3 disconnect statements (similar to unmap statement).

PTCs are moduled using TTCN-3 functions with "runs on" clause specifying the type of the PTC. The same Test System Interface (TSI) that is used with MTC is used by PTC and it therefore does not need to be specified.

Step 2: Testing two DNS servers

Your boss have just said congratulations about the DNS server test suite. In the same sentence she asked that "You can test two DNS server at the same time, yes?"

Fortunately that is possible. In the next steps we modify the original test case to allow testing of two DNS servers. You know your boss and at the same time we are going to modify the test case to allow testing of N DNS servers as easily.

Step 3: Creating test case for testing N interfaces

Instructions 1:

Use the "TC_query" test case as the starting point. Create the body of that test case to a new function called "F_query" having a "runs on" clause. Create also a second function called "F_multi_query" also having a "runs on" clause that only contains call of "F_query" function in its body.

Instructions 2:

Create a new test case called "TC_multi_query" that creates a PTC and starts the "F_multi_query" funtion in that PTC.

Instructions 3:

Discuss with the instructor what kind of synchronization is needed between the MTC and the PTC. Think about using the following types of synchronization primitives: "query", "answer", "stop".

Instructions 4:

Implement the agreed synchronization to "TC_multi_query" test case and to the "F_multi_query" function.

Instructions 5:

Don't forget to wait the stopping Parallel Test Components using TTCN-3 "done" operation in the end of the test case to make sure all PTCs have completed their operation before ending the test case.

Instructions 6:

At this point you have a test case similar to "TC_query" but its structure is easy to modify for testing any number of DNS servers. Discuss the required modifications with the instructor.

Summary

Congratulations! You have just completed the last exercise from the set of seven TTCN-3 exercises of today. You also completed all exercises of this whole course! During this exercise you learned how to use dynamic test configurations. This course is about to be over, but now you are ready to proceed to learn more details about TTCN-3 by your own!

<< Previous   Exercise Index >>

Views
Personal tools