0

Im using tsung to test a webapplication. when requested, the server respond with xml.

What Im trying to do : Use tsung match tag in the request to log if an error occure.

If an error occure, the xml response is as this :

<?xml version="1.0" encoding="UTF-8" ?>
 <toto:root xmlns:toto="toto_url" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <toto:header>
  <toto:trace-id>Testing</toto:trace-id>
  <toto:timestamp>1420441279107</toto:timestamp>
  <toto:command>MyServiceName</toto:command>
  <toto:version>2.4</toto:version>
  <toto:operation-id/>
  <toto:calling-user>Tester</toto:calling-user>
  <toto:calling-application>Tester</toto:calling-application>
  <toto:calling-channel/>
  <toto:locale-code>en</toto:locale-code>
  <toto:country-code>EN</toto:country-code>
  <toto:error>
   <toto:applicative>
     <toto:code>002</toto:code>
     <toto:message>No record found</toto:message>
   </toto:applicative>
  </toto:error>
 </toto:header>
 <app:data xmlns:app="url_toto_service">
  <app:totoNullPayload>
    <app:result>OK</app:result>
  </app:totoNullPayload>
</app:data>

I need to log in match.log specific name for the error code value 002 and other error code value.

so far, I have this working. It logs in match log when I get the value 002 inside the response. the issue is that it match the 002 value even if it is not inside the tag. Therefor, it sometimes match regular xml response that holds this value. 002 008

My question is How do I match the error value and the fact that it is inside the tag ?

the tsung request part is :

   <request subst="true">
            <match name="Norecord" do="log" when="match" skip_headers="http" subst="true">002</match>
    <match name="Request Error" do="log" when="match" skip_headers="http" subst="true">008</match>
   <http url="/myApp/XmlHttpInbound" method="POST" version="1.1"
     content_type="application/xml"
     contents_from_file="/tmp/query.xml">
   </http>
Xarouma
  • 171
  • 1
  • 10

1 Answers1

0

Updated:

Tsung test plans specified as xml file, so you should to escape xml symbols wich you expect in response. To match 002 and 008 error codes inside tags you can use:

<request subst="true">
    <match do="log" when="match" skip_headers="http" subst="true">&lt;toto:code&gt;002&lt;/toto:code&gt;</match>
    <match do="log" when="match" skip_headers="http" subst="true">&lt;toto:code&gt;008&lt;/toto:code&gt;</match>
    <http url="/myApp/XmlHttpInbound" method="POST" version="1.1"
        content_type="application/xml"
        contents_from_file="/tmp/query.xml">
    </http>
</request>
Sabik
  • 1,599
  • 1
  • 11
  • 10
  • Please try to elaborate your answers rather than just posting a piece of code. Explain why this code works and why you chose this solution. – Avi May 14 '15 at 05:44