イベント・シーケンスの作成
イベント・シーケンスでテスト・イベントのセットを定義します。出力するイベントは、イベント・シーケンス・ファイル内に定義されている順序でサーバーに送信されます。
始める前に
このタスクについて
イベント・シーケンス・ファイル (.eseq) 内のイベントはすべて、 emit <event> 構成体または emit <event>, time-stamped <date & time> 構成体を使用して定義されなければなりません。 .eseq ファイルでイベントが指定された順序で、その処理順序が決まります。 イベント・タイム・スタンプは、イベントが発生した時間を表します。例えば、.eseq ファイルに以下の 3 つのイベントがあるとします。
- event1 のタイム・スタンプは 3/24/2015 です。
- event2 のタイム・スタンプは 3/25/2015 です。
- event3 のタイム・スタンプは 3/22/2015 です。
処理されるイベントの順序は、タイム・スタンプに関係なく、event1、event2、 event3 です。event3 のタイム・スタンプは event2 と event1 よりも前ですが、 転送中に遅延して順序が誤って到着したイベントとして解釈できます。 テストは、イベント・シーケンスの最初のタイム・スタンプで開始します。これは、絶対時間でなければなりません。 後続のイベントのタイム・スタンプは、最初のタイム・スタンプより前 (過去) であることも、後 (未来) であることも可能です。 ただし、イベント・シーケンスの順序で、イベントは処理されます。 つまり、イベントはすべて、いつ発生したかには関係なく、処理されます。
別の方法として、相対タイム・スタンプを持つイベント・シーケンスを作成する場合は、出力した最初のイベントに続けて、time-stamped by the test scenario 構成体を使用できます。この構成体を最初のイベントに使用すると、以降のすべてのイベントには、シーケンス内で直前にあるイベントからの相対的なタイム・スタンプが付けられます。その後、さまざまなタイム・スタンプで同じシーケンスを出力することにより、イベント・シーケンスをテスト・シナリオで再使用できます。
手順
例
- イベント 属性
-
イベントはイベント属性を持つことができます。イベント属性もタイム・スタンプを持つことができます。 次の例で、request event 属性にはタイム・スタンプがあります。
emit a new response event where the in response to is ( a new request event where the timestamp is 1/1/2015 ) , time-stamped 1/2/2015 ;次の例では、new customer registration イベントの address 属性が emit 構成体の中で記述されています。 a new <item> 構成体の中で、where 構成体が使用されています。
emit a new customer registration where the address is ( a new address where the street is "221B Baker Street" , the city is "London" , the country is "UK" ) , time-stamped 3/25/2015 ; - 相対タイム・スタンプを持つイベント・シーケンス
- 以下の例では、テスト・シナリオで指定された日時に、顧客 Fred によって購入イベントが出力されます。2 番目と 3 番目の購入は、最初の購入イベントから 3 日後と 5 日後に出力されます。
emit a new purchase where the customer is the customer "Fred", the amount is 100.0, time-stamped by the test scenario ; emit a new purchase where the customer is the customer "Fred", the amount is 50, time-stamped 3 days later ; emit a new purchase where the customer is the customer "Fred", the amount is 250, time-stamped 2 days later ; - 別個の概念定義を含むイベント・シーケンス
- 次の例で、イベント・シーケンスは
customer registration イベントと
purchase イベントの 2 つのイベントで構成され、
それらは the
customer と purchase1 の 2 つの変数に関連します。
これらの変数は、emit ステートメントの外部にある
define ステートメントで定義されています。
括弧はオプションです。
define 'the customer' as the customer identified by "John"; emit ( a new customer registration where the customer is 'the customer' , the first name is "John" , the last name is "Watson" ) , time-stamped 3/25/2015 ; define 'purchase1' as a new purchase where the customer is 'the customer'; emit purchase1 , time-stamped 5 minutes later; - インラインの概念定義を含むイベント・シーケンス
- 次の例で、イベント・シーケンスは
customer registration イベントと
purchase イベントの 2 つのイベントで構成され、
それらは the
customer と purchase1 の 2 つの変数に関連します。
the customer の address 属性の変数は、
customer registration イベントの emit 定義の中で定義されています。
new customer registration イベントには、
識別子以外の、address 概念タイプの属性の値は含まれません。
これは、address インスタンスが関係の確立に使用されているためです。
括弧はオプションです。
define 'the customer' as the customer identified by "John"; emit a new customer registration where the customer is 'the customer' , the first name is "John" , the last name is "Watson" , the address is ( a new address where the address id is "123" the street is "221B Baker Street" , the city is "London" , the country is "UK" ) , time-stamped 3/25/2015 ; define 'purchase1' as a new purchase where the customer is 'the customer'; emit purchase1 , time-stamped 5 minutes later; - 2 つのイベントが同じ変数を使用するイベント・シーケンス
- 次の例で、変数 paddington は各イベントで再使用され、
特定の customer を参照します。
define 'paddington' as the customer identified by "paddington@example.com" emit a new customer registration where the customer is paddington , time-stamped 4/07/2015 ; emit a new purchase where the customer is paddington , the price is 25 , time-stamped 10 minutes later ; emit a new purchase where the customer is paddington , the price is 62 , time-stamped 3 days later ; - 異なるタイプのタイム・スタンプを使用するイベントを含むイベント・シーケンス
- 次の例で、最初の purchase イベントのタイム・スタンプは、
customer
registration イベントの 10 分後です。
シーケンスで 3 番目のイベントは、直前のイベント (この例では customer registration イベント)
の 3 日後に発生します。
これらのイベントは、順序に従わずに処理されるイベントのシーケンスをシミュレートする方法の例を示しています。
define 'paddington' as the customer identified by "paddington@example.com" emit a new purchase where the customer is paddington , the price is 25 , time-stamped 4/07/2015 ; emit a new customer registration where the customer is paddington , time-stamped 10 minutes earlier ; emit a new purchase where the customer is paddington , the price is 62 , time-stamped 3 days later ;