Barry,
Sorry for the delay a lot of things going on in parallel :-)
There are at least a couple of ways of doing it. The simplest but cumbersome way is to use what you described below with one change.
Have "< OPTIONS {,} > 200 {,} , < OPTIONS {,} > 200 {,} ..."
You just need to have a large number of these OPTIONS/200 strings in the validation string, it will not matter if you have more than what you receive on the wireas the {,} indicates at least 0 and at
most infinity.
I know that this is a quick and dirty way of doing it.
However here is a much powerful and elegant way.
Look at the script below
#---START OF SNIPPET ---
require 'driven_sip_test_case'
class TestCustomRecord < DrivenSipTestCase
def setup
super
str = <<-EOF
require 'sip_test_driver_controller'
module SipInline
class UasCrController < SIP::SipTestDriverController
transaction_usage :use_transactions=>true
emit_console true
def on_invite(session)
session.make_new_offer
session.respond_with(200)
logd("Received INVITE sent a 200 from "+name)
end
def on_ack(session)
session.request_with("options")
end
def on_success_res_for_bye(session)
session.invalidate(true)
session.flow_completed_for("TestCustomRecord")
end
def on_success_res_for_options(session)
if rand(10)%2 == 0
session.request_with("options")
else
session.request_with("bye")
end
end
def order
0
end
end
class UacCrController < SIP::SipTestDriverController
transaction_usage :use_transactions=>true
def start
u = create_udp_session(SipperConfigurator[:LocalSipperIP],
SipperConfigurator[:LocalTestPort])
r = u.create_initial_request("invite", "
sip:na...@sipper.com",
:p_session_record=>"msg-info")
u.offer_answer.make_new_offer
u.send(r)
logd("Sent a new INVITE from "+name)
end
def on_success_res(session)
session.request_with('ACK')
end
def on_options(session)
session.respond_with(200)
end
def on_bye(session)
session.respond_with(200)
session.invalidate(true)
end
end
end
EOF
define_controller_from(str)
set_controller("SipInline::UacCrController")
end
def test_smoke_controllers
start_controller
recording = get_in_recording.get_info_only_recording
assert_equal("< INVITE", recording[0])
assert_equal("> OPTIONS", recording[-4])
assert_equal("< 200", recording[-3])
assert_equal("> BYE", recording[-2])
assert_equal("< 200", recording[-1])
end
end
#----END OF SNIPPET
There are a few things to note here.
1. We are sending a random number of OPTIONS before we send a BYE as you can see by turning on the emit_console option to print messages to console (your test may be different as you need a time bound thins, but this is a simulation).
2. We are not using standard validator here but accessing the recording using
recording = get_in_recording.get_info_only_recording
You may read the manual for more details but essentially this retrieves the recorded messages with their directions in the array.
3. Finally we are using Ruby negative array access to compare the recording from reverse starting from BYE and only one OPTION. It doesn't matter how many OPTIONS we get.
Hope this helps.