mbarfiel avatar image
mbarfiel asked Spirent_Admin edited

Reusing key token across multiple blocks or containers

I have a telnet response that has dynamic interface values in the middle of the response. The interface can be one or many. I would like to use the "evc Name" as the key to help query information from the response.


How can I do this with the attached response map and am I taking the best approach to accomplish this?


Interface examples:


Interfaces          : gigabit-ethernet 1/A/1
                            : gigabit-ethernet 1/A/2
                            : gigabit-ethernet 1/A/3
                            : gigabit-ethernet 1/A/4


Interfaces          : gigabit-ethernet 1/A/1
                            : gigabit-ethernet 1/A/2


Any guidance would be appreciated - thanks.

iTestresponse mapblock map
Show_Evc_OSP.ffrm (15.1 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

GregM avatar image
GregM answered GregM posted

Attached is a block response map that handles the optional lines and includes custom queries to lookup all values from a single key.  Below are the steps I used to create the keyed queries:


Creating keyed queries for block maps

1. Create the desired block map
2. Select all but the key for customization (Customize button)
3. Copy all these queries twice so that you have the queries with their query_base_name, query_base_name_1 and query_base_name_2
4. Replace all the _1 query names with _all and all the _2 with _by_keyname
 a. Search>File…
 b. Containing Text: _1
 c. File name patterns: *
 d. Working set: [Choose…]
  i. Add one (unchecking any other entries)
  ii. Select Resource
  iii. Navigate to the RM being edited
 e. Check mark the new working set
 f. Press [Replace]
 g. With: _all
5. Repeat step for with _2 and _by_keyname
6. For each of the _by_keyname queries do
 a. Add an argument called keyname
  i. Values query: .//keyname
  ii. Interpret as: SampleValues
  iii. (for subsequent queries, the argument can be copy-and-pasted)
 b. Append selection criteria to the Query format field.  The query will be of the (.//token_name)[../path_to_key/keyname = ‘{0}’]
 c. To find the ../path_to_key/keyname
  i. Select one of the tokens in the Structure View
  ii. Add ../ to the Structure expression; note the popup will show available options.  If the options do not include the node where the key is located, enter another ../ until that node appears
  iii. Navigate to the key from there
  iv. Copy on the text just entered (not the full expression)
 d. Build the query according to the format in step b above.


Show_Evc_OSP.ffrm (24.6 KiB)
1 comment
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mbarfiel avatar image mbarfiel commented ·

This is exactly what I was looking for. The posted example has multiple blocks that allows the 'key' token to be reused across blocks - good job.

0 Likes 0 ·
dileep avatar image
dileep answered dileep posted



Please find the attached response map.




Show_Evc_OSPF.ffrm (15.1 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mbarfiel avatar image mbarfiel commented ·

This is a real good response map. I will use this one as a model for other block maps.


I still have a problem with associating the "EVCvlan" key in the "vlan" block with the "interface" and "smode" blocks.


How do you check the interface information for "EVC 201", "EVC 202", etc... using the query option? I wan to use the"EVCvlan" key to check the other block properties - does this make sense? I have multiple blocks defined but the token key in block 1 applies to block 2, 3, 4,... but I can't response map the information this way.


I think this might be done with a custom query but I'm not sure how to craft that.



0 Likes 0 ·
PaulD avatar image PaulD mbarfiel commented ·

Indeed, custom queries are the answer to this challenge.  You need to know a bit of XPATH to make this all work.  


Let's start first with pure XPATH.  In your sample, if you want to find the switchingmode associated with the vlan whose EVCvlan is 201, then XPATH will get this answer using:




To interpret this XPATH query:  "Find all 'vlandetails' nodes.  From each of these look for a node under it called 'vlan'.  Then under that one, look for a node called 'EVCvlan' that has the value '201'.   For any 'vlandetails' nodes that match this, then look under it for a node called 'smode' and under that node, find 'switchingmode' and return its contents."  Can you following that logic by looking at the XPATH query?


Okay, now what we really want to do is to be able to make '201' into a parameter.  That's where custom queries comes in.  So we'll make a custom query called SwitchingMode_By_EVCvlan and give it one argument which is the EVCvlan value.  Our custom query will translate into XPATH as above, except that we put a substitution in for the argument:




Then we need to define that argument.  We'll call it EVCvlan.  Now we are able to make queries using this custom query.  But wouldn't it be great if we could ask iTest to also find all of the matches for us?  That's where additional information is needed by iTest to tell us what all possible values for the EVCvlan might be.  So on that argument definition, we tell iTest another XPATH query for how to find all of the various values of EVCvlan in the response:




(Remember that XPATH queries try to find ALL matches.  Not just the first one.  So this query finds all of the EVCvlan nodes and returns their values as a list.)


Now, when you click on one of the blue boxes on the switchingmode values, iTest will give you the appropriate query to return that value based on the value of the EVCvlan in the same group.


I'm attaching an updated response map to show this working.  Note that for clarity, I've also turned off all of the queries that iTest auto-generates based on the information in the blocks themselves.  You do that by clicking on the checkbox at the top of the Queries page in the response map editor.  In this way, you can create your own custom ones when iTest doesn't produce exactly the ones you might want.  (There are some tricks if you want to keep some of them but ignore others.)

0 Likes 0 ·
Show_Evc_OSPF.ffrm (15.4 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.