0

tsung を使用して Web アプリケーションをテストしています。要求されると、サーバーは xml で応答します。

私がやろうとしていること:エラーが発生した場合は、リクエストで tsung マッチタグを使用してログに記録します。

エラーが発生した場合、xml 応答は次のようになります。

<?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>

エラー コード値 002 およびその他のエラー コード値の match.log 固有の名前でログインする必要があります。

これまでのところ、私はこれを機能させています。応答内で値 002 を取得すると、一致ログに記録されます。問題は、タグ内になくても 002 値と一致することです。そのため、この値を保持する通常の xml 応答と一致する場合があります。002 008

私の質問は、エラー値とそれがタグ内にあるという事実をどのように一致させるのですか?

ツングリクエスト部分は次のとおりです。

   <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>
4

1 に答える 1

0

更新しました:

Tsung テスト プランは xml ファイルとして指定されているため、応答で期待される xml シンボルをエスケープする必要があります。タグ内の 002 および 008 エラー コードを一致させるには、次を使用できます。

<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>
于 2015-05-13T21:56:57.417 に答える