Skip to content
Rodney Lopes Gomes edited this page Sep 24, 2010 · 3 revisions

Components are what set DTF apart from all of the other testing frameworks you may have used till today. A component is another lockable component with DTF and can only be locked and used from a DTFX (runner).

Locking components

Before you can use a component you need to lock one and identify what are the attributes that make this the component you want to use. When starting a DTFA you have the opportunity to define attributes that identify this DTFA based on network location or if the DTFA is running on a particular type of machine. To identify these attributes you just need to start your agent and identify the default properties file using the property -Ddtf.defaults=agent.properties. Any properties defined in the agent.properties file that don't start with the prefix dtf. will be automatically loaded as agent attributes and you can match those when locking your component.

Lets say we start 1 DTFC and 2 DTFA's that use the following properties files:

agent.type=primary
agent.type=secondary

We can start the DTF like so:

./ant.sh run_dtfc

and start up those two agents like so:

./ant.sh run_dtfa -Ddtf.defaults=primary-agent.properties
./ant.sh run_dtfa -Ddtf.defaults=secondary-agent.properties

With the previous setup we can now execute the following test and lock those two components exactly was we want to make sure we use the two components within our setup correctly:

<?xml version="1.0" encoding="UTF-8"?>
<script xmlns="http://dtf.org/v1" name="lockcomponent_example">
    <info>
        <author>
            <name>Rodney Gomes</name>
            <email>rlgomes@yahoo-inc.com</email>
        </author>
        <description>
        </description>
    </info>
  
    <local>
        <lockcomponent id="CS">
            <attrib name="agent.type" value="primary"/>
        </lockcomponent>
        
        <lockcomponent id="CP">
            <attrib name="agent.type" value="secondary"/>
        </lockcomponent>
    </local>    
    
    <component id="CS">
        <log>This is the Secondary Agent</log>
    </component>

    <component id="CP">
        <log>This is the Primary Agent</log>
    </component>
</script>

This example shows how you can easily identify which component is being locked and how it will be identified within your test case. This feature is intended to be used for you to easily identify which of your DTFA's are running on a client machine or a server machine and to give you the flexibility of identifying which attributes are important within your system level tests.

Using components

Using a component is done by opening the component tag around the block of DTF XML that you'd like to run on the component you locked and that XML will now execute on the component in question. One thing to remember is that you can't do everything on a another agent that you would do on the runner side. This is the case because things like locking components or using other components is only intended to be done from the runner.

When using a component from a specific thread on the runner side any subsequent calls to the same component from that same thread will have visibility into properties, ranges and other DTF elements across multiple executions on the same component from the same runner side thread. This allows you to do things such as using a range and waiting for something on the runner side then going back to the component and continue from the previous position you left on the range on that component. Here is a simple example of this:

<?xml version="1.0" encoding="UTF-8"?>
<script xmlns="http://dtf.org/v1" name="component_usage">
    <info>
        <author>
            <name>Rodney Gomes</name>
            <email>rlgomes@yahoo-inc.com</email>
        </author>
        <description>
        </description>
    </info>
  
    <local>
        <lockcomponent id="C1"/>
        <createrange name="range" value="1,2,3,4,5"/>
    </local>    
   
    <for property="i" range="1..5">
	    <component id="C1">
            <assert><eq op1="${i}" op2="${range}"/></assert>
	    </component>
    </for>
</script>

Clone this wiki locally