Sipper 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/sipper/README.rb +26 -0
- data/sipper/b2bua_controller.rb +163 -0
- data/sipper/b2bua_session_mixin.rb +24 -0
- data/sipper/base_controller.rb +425 -0
- data/sipper/bin/common.rb +42 -0
- data/sipper/bin/generate.rb +70 -0
- data/sipper/bin/project.rb +44 -0
- data/sipper/bin/run.rb +85 -0
- data/sipper/bin/run_smoke.rb +8 -0
- data/sipper/config/log4r.xml +71 -0
- data/sipper/controller_class_loader.rb +29 -0
- data/sipper/controller_selector.rb +119 -0
- data/sipper/controllers/invite_controller.rb +30 -0
- data/sipper/controllers/order.yaml +3 -0
- data/sipper/custom_message.rb +4 -0
- data/sipper/detached_session.rb +11 -0
- data/sipper/docs/manual.txt +1621 -0
- data/sipper/generators/README +12 -0
- data/sipper/generators/gen_controller.rb +228 -0
- data/sipper/generators/gen_project.rb +45 -0
- data/sipper/generators/gen_test.rb +72 -0
- data/sipper/generators/project_template_dir/Rakefile +56 -0
- data/sipper/generators/project_template_dir/config/sipper.cfg +31 -0
- data/sipper/generators/project_template_dir/controllers/README.txt +2 -0
- data/sipper/generators/project_template_dir/dot_sipper.proj +2 -0
- data/sipper/generators/project_template_dir/logs/README.txt +2 -0
- data/sipper/generators/project_template_dir/tests/README.txt +2 -0
- data/sipper/lib/smc/statemap.rb +194 -0
- data/sipper/logs/dialog_info_store +0 -0
- data/sipper/logs/r.cmd +6 -0
- data/sipper/logs/r.sh +6 -0
- data/sipper/media/sipper_media_client.rb +268 -0
- data/sipper/media/sipper_media_event.rb +43 -0
- data/sipper/media/sipper_media_manager.rb +145 -0
- data/sipper/media/sipper_media_proxy.rb +60 -0
- data/sipper/media/sipper_offer_answer.rb +285 -0
- data/sipper/message.rb +512 -0
- data/sipper/modified_pattern_formatter.rb +119 -0
- data/sipper/proxy_controller.rb +143 -0
- data/sipper/registration.rb +52 -0
- data/sipper/request.rb +109 -0
- data/sipper/response.rb +123 -0
- data/sipper/ruby_ext/module.rb +27 -0
- data/sipper/ruby_ext/mutable_class.rb +17 -0
- data/sipper/ruby_ext/object.rb +38 -0
- data/sipper/ruby_ext/pqueue.rb +190 -0
- data/sipper/ruby_ext/snapshot.rb +201 -0
- data/sipper/ruby_ext/string.rb +18 -0
- data/sipper/ruby_ext/time.rb +9 -0
- data/sipper/run/run_sipper1.rb +28 -0
- data/sipper/run/run_sipper2.rb +56 -0
- data/sipper/sdp/sdp.rb +257 -0
- data/sipper/sdp/sdp_generator.rb +131 -0
- data/sipper/sdp/sdp_parser.rb +136 -0
- data/sipper/session.rb +1952 -0
- data/sipper/session_manager.rb +170 -0
- data/sipper/session_recorder.rb +190 -0
- data/sipper/session_state/DialogState.sm +54 -0
- data/sipper/session_state/DialogState_sm.rb +337 -0
- data/sipper/session_state/dialog_routes.rb +141 -0
- data/sipper/sip_headers/header.rb +632 -0
- data/sipper/sip_headers/sipuri.rb +352 -0
- data/sipper/sip_logger.rb +65 -0
- data/sipper/sip_message_router.rb +231 -0
- data/sipper/sip_test_driver_controller.rb +10 -0
- data/sipper/sipper.rb +329 -0
- data/sipper/sipper_assertions.rb +21 -0
- data/sipper/sipper_configurator.rb +376 -0
- data/sipper/sipper_http/sipper_http_request_dispatcher.rb +71 -0
- data/sipper/sipper_http/sipper_http_response.rb +25 -0
- data/sipper/stray_message_manager.rb +40 -0
- data/sipper/test_completion_signaling_helper.rb +77 -0
- data/sipper/transaction/Ict.sm +59 -0
- data/sipper/transaction/Ict_sm.rb +430 -0
- data/sipper/transaction/Ist.sm +74 -0
- data/sipper/transaction/Ist_sm.rb +460 -0
- data/sipper/transaction/Nict.sm +51 -0
- data/sipper/transaction/Nict_sm.rb +325 -0
- data/sipper/transaction/Nist.sm +59 -0
- data/sipper/transaction/Nist_sm.rb +356 -0
- data/sipper/transaction/invite_client_transaction.rb +274 -0
- data/sipper/transaction/invite_server_transaction.rb +319 -0
- data/sipper/transaction/non_invite_client_transaction.rb +230 -0
- data/sipper/transaction/non_invite_server_transaction.rb +263 -0
- data/sipper/transaction/state_machine_wrapper.rb +58 -0
- data/sipper/transaction/transaction.rb +212 -0
- data/sipper/transport/base_transport.rb +84 -0
- data/sipper/transport/rel_unrel.rb +19 -0
- data/sipper/transport/transport_and_route_resolver.rb +67 -0
- data/sipper/transport/udp_transport.rb +156 -0
- data/sipper/transport_manager.rb +33 -0
- data/sipper/udp_session.rb +17 -0
- data/sipper/util/command_element.rb +62 -0
- data/sipper/util/compact_converter.rb +50 -0
- data/sipper/util/counter.rb +26 -0
- data/sipper/util/digest/digest_authorizer.rb +204 -0
- data/sipper/util/expectation_parser.rb +164 -0
- data/sipper/util/locator.rb +31 -0
- data/sipper/util/message_fill.rb +58 -0
- data/sipper/util/persistence/ps_sipper_map.rb +63 -0
- data/sipper/util/persistence/sipper_map.rb +41 -0
- data/sipper/util/sipper_util.rb +305 -0
- data/sipper/util/timer/sip_timer_helper.rb +26 -0
- data/sipper/util/timer/timer_manager.rb +80 -0
- data/sipper/util/timer/timer_task.rb +56 -0
- data/sipper/util/validations.rb +44 -0
- data/sipper/version.rb +10 -0
- data/sipper_test/_test_media_uas.rb +79 -0
- data/sipper_test/base_test_case.rb +31 -0
- data/sipper_test/c_134.txt +7 -0
- data/sipper_test/driven_sip_test_case.rb +96 -0
- data/sipper_test/gold.txt +10 -0
- data/sipper_test/gold_res.txt +8 -0
- data/sipper_test/gold_sub.txt +9 -0
- data/sipper_test/hello_sipper.au +0 -0
- data/sipper_test/in_sipper.au +0 -0
- data/sipper_test/nonrr_proxy.rb +17 -0
- data/sipper_test/order_tests.yaml +4 -0
- data/sipper_test/rake_res.txt +399 -0
- data/sipper_test/rr_proxy.rb +17 -0
- data/sipper_test/run_test.cmd +94 -0
- data/sipper_test/sip_test_case.rb +104 -0
- data/sipper_test/test2xx_retransmission.rb +80 -0
- data/sipper_test/test2xx_retransmission_with_limit.rb +81 -0
- data/sipper_test/test2xx_retransmission_with_nist.rb +91 -0
- data/sipper_test/test2xx_retransmission_with_txns.rb +94 -0
- data/sipper_test/test_address_header.rb +66 -0
- data/sipper_test/test_b2bua1.rb +130 -0
- data/sipper_test/test_b2bua2.rb +120 -0
- data/sipper_test/test_b2bua3.rb +160 -0
- data/sipper_test/test_b2bua4.rb +130 -0
- data/sipper_test/test_base_controller.rb +110 -0
- data/sipper_test/test_base_transport.rb +37 -0
- data/sipper_test/test_cancel.rb +21 -0
- data/sipper_test/test_cancel_after2xx.rb +81 -0
- data/sipper_test/test_cancel_retransmission.rb +105 -0
- data/sipper_test/test_cancel_with481.rb +83 -0
- data/sipper_test/test_cancel_with487.rb +70 -0
- data/sipper_test/test_cancel_with_ist_without_nist.rb +99 -0
- data/sipper_test/test_cancel_with_nist.rb +84 -0
- data/sipper_test/test_cancel_without487.rb +77 -0
- data/sipper_test/test_command_element.rb +38 -0
- data/sipper_test/test_compact_converter.rb +33 -0
- data/sipper_test/test_controller_class_loader.rb +37 -0
- data/sipper_test/test_controller_selector.rb +53 -0
- data/sipper_test/test_controller_using_compact_headers.rb +74 -0
- data/sipper_test/test_controller_using_header_order.rb +85 -0
- data/sipper_test/test_controller_using_ict.rb +64 -0
- data/sipper_test/test_controller_using_ict_with_non_success.rb +72 -0
- data/sipper_test/test_controller_using_ict_with_tcbh.rb +24 -0
- data/sipper_test/test_controller_using_ict_with_tcbh_no_action.rb +24 -0
- data/sipper_test/test_controller_using_ist.rb +70 -0
- data/sipper_test/test_controller_using_ist_with_tcbh.rb +24 -0
- data/sipper_test/test_controller_using_nict.rb +115 -0
- data/sipper_test/test_controller_using_nict_with_tcbh.rb +24 -0
- data/sipper_test/test_controller_using_nist.rb +63 -0
- data/sipper_test/test_controller_using_pre_existing_rs0.rb +73 -0
- data/sipper_test/test_controller_using_pre_existing_rs1.rb +75 -0
- data/sipper_test/test_controller_using_pre_existing_rs2.rb +71 -0
- data/sipper_test/test_controller_using_route_set.rb +86 -0
- data/sipper_test/test_controller_with_sdp.rb +80 -0
- data/sipper_test/test_controllers/cancel/order.yaml +2 -0
- data/sipper_test/test_controllers/cancel/uac_cancel_controller.rb +35 -0
- data/sipper_test/test_controllers/cancel/uas_cancel_controller.rb +25 -0
- data/sipper_test/test_controllers/class_loading/ordered/first_ordered_controller.rb +5 -0
- data/sipper_test/test_controllers/class_loading/ordered/order.yaml +3 -0
- data/sipper_test/test_controllers/class_loading/ordered/recond_ordered_controller.rb +6 -0
- data/sipper_test/test_controllers/class_loading/ordered/second_ordered_controller.rb +6 -0
- data/sipper_test/test_controllers/class_loading/unordered/first_unordered_controller.rb +7 -0
- data/sipper_test/test_controllers/class_loading/unordered/second_unordered_controller.rb +6 -0
- data/sipper_test/test_controllers/ctrl_trhandler/lib/transport_filters/my_transport_handler.rb +22 -0
- data/sipper_test/test_controllers/ctrl_trhandler/uac_tr_handler_controller.rb +27 -0
- data/sipper_test/test_controllers/ctrl_trhandler/uas_tr_handler_controller.rb +21 -0
- data/sipper_test/test_controllers/ete/order.yaml +1 -0
- data/sipper_test/test_controllers/ete/uac_controller.rb +39 -0
- data/sipper_test/test_controllers/ete/uas_controller.rb +34 -0
- data/sipper_test/test_controllers/extensions/extension_uac_controller.rb +24 -0
- data/sipper_test/test_controllers/extensions/extension_uas_controller.rb +35 -0
- data/sipper_test/test_controllers/extensions/lib/sipper_extensions/my_from_extension.rb +16 -0
- data/sipper_test/test_controllers/ict_tcbh/lib/transaction_handlers/app_ict_handler.rb +23 -0
- data/sipper_test/test_controllers/ict_tcbh/uac_ict_tcbh_controller.rb +27 -0
- data/sipper_test/test_controllers/ict_tcbh/uac_ict_tcbh_no_action_controller.rb +28 -0
- data/sipper_test/test_controllers/ict_tcbh/uas_ict_tcbh_controller.rb +29 -0
- data/sipper_test/test_controllers/ict_tcbh/uas_ict_tcbh_no_action_controller.rb +31 -0
- data/sipper_test/test_controllers/ist_tcbh/lib/app_ist_handler.rb +13 -0
- data/sipper_test/test_controllers/ist_tcbh/uac_ist_tcbh_controller.rb +22 -0
- data/sipper_test/test_controllers/ist_tcbh/uas_ist_tcbh_controller.rb +31 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/in_order.yaml +2 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/my_transport_handler1.rb +21 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/my_transport_handler2.rb +21 -0
- data/sipper_test/test_controllers/multi_trhandlers/lib/transport_filters/out_order.yaml +2 -0
- data/sipper_test/test_controllers/multi_trhandlers/uac_multi_tr_handler_controller.rb +27 -0
- data/sipper_test/test_controllers/multi_trhandlers/uas_multi_tr_handler_controller.rb +29 -0
- data/sipper_test/test_controllers/multiple/lib/blank_test.rb +2 -0
- data/sipper_test/test_controllers/multiple/uac_info_controller.rb +21 -0
- data/sipper_test/test_controllers/multiple/uac_msg_controller.rb +20 -0
- data/sipper_test/test_controllers/multiple/uas_info_controller.rb +15 -0
- data/sipper_test/test_controllers/multiple/uas_msg_controller.rb +14 -0
- data/sipper_test/test_controllers/nict_tcbh/lib/transaction_handlers/app_nict_handler.rb +13 -0
- data/sipper_test/test_controllers/nict_tcbh/uac_nict_tcbh_controller.rb +26 -0
- data/sipper_test/test_controllers/nict_tcbh/uas_nict_tcbh_controller.rb +20 -0
- data/sipper_test/test_controllers/state_machine_based/lib/CreditControl.sm +43 -0
- data/sipper_test/test_controllers/state_machine_based/lib/CreditControl_sm.rb +194 -0
- data/sipper_test/test_controllers/state_machine_based/order.yaml +1 -0
- data/sipper_test/test_controllers/state_machine_based/uac_message_controller.rb +34 -0
- data/sipper_test/test_controllers/state_machine_based/uas_message_controller.rb +44 -0
- data/sipper_test/test_controllers/stray_message/lib/sipper_extensions/my_stray_handler.rb +9 -0
- data/sipper_test/test_controllers/stray_message/stray_uac_controller.rb +24 -0
- data/sipper_test/test_controllers/stray_message/stray_uas_controller.rb +31 -0
- data/sipper_test/test_controllers/string/order.yaml +1 -0
- data/sipper_test/test_controllers/string/uac_controller.rb +29 -0
- data/sipper_test/test_controllers/string/uas_controller.rb +22 -0
- data/sipper_test/test_controllers/test_controller.rb +24 -0
- data/sipper_test/test_detached_session1.rb +78 -0
- data/sipper_test/test_dialog_routes.rb +139 -0
- data/sipper_test/test_digest_challenge1.rb +89 -0
- data/sipper_test/test_digest_challenge2.rb +90 -0
- data/sipper_test/test_dynamic_parse.rb +249 -0
- data/sipper_test/test_empty_sdp.rb +89 -0
- data/sipper_test/test_ete.rb +37 -0
- data/sipper_test/test_expectation_parser.rb +76 -0
- data/sipper_test/test_extensions.rb +28 -0
- data/sipper_test/test_freeze.rb +81 -0
- data/sipper_test/test_generated.rb +90 -0
- data/sipper_test/test_header_parameters.rb +75 -0
- data/sipper_test/test_header_parse.rb +141 -0
- data/sipper_test/test_http_client1.rb +84 -0
- data/sipper_test/test_http_client2.rb +90 -0
- data/sipper_test/test_ict_with_timeout.rb +62 -0
- data/sipper_test/test_in_dialog_request.rb +61 -0
- data/sipper_test/test_inline_controller.rb +67 -0
- data/sipper_test/test_invite_client_transaction.rb +272 -0
- data/sipper_test/test_invite_replace.rb +147 -0
- data/sipper_test/test_invite_retransmission.rb +90 -0
- data/sipper_test/test_invite_server_transaction.rb +208 -0
- data/sipper_test/test_lower_cseq.rb +79 -0
- data/sipper_test/test_media.rb +52 -0
- data/sipper_test/test_message.rb +392 -0
- data/sipper_test/test_method_specific_response_handling.rb +81 -0
- data/sipper_test/test_multi_homed1.rb +127 -0
- data/sipper_test/test_multi_homed2.rb +109 -0
- data/sipper_test/test_multi_homed_duplicate.rb +87 -0
- data/sipper_test/test_multi_homed_with_detached.rb +88 -0
- data/sipper_test/test_multiple.rb +49 -0
- data/sipper_test/test_multiple_contacts.rb +89 -0
- data/sipper_test/test_non2xx_retransmission_with_ist.rb +87 -0
- data/sipper_test/test_non_invite_client_transaction.rb +210 -0
- data/sipper_test/test_non_invite_retransmission.rb +91 -0
- data/sipper_test/test_non_invite_server_transaction.rb +202 -0
- data/sipper_test/test_offer_answer_prack.rb +103 -0
- data/sipper_test/test_pickup.rb +258 -0
- data/sipper_test/test_prack.rb +105 -0
- data/sipper_test/test_prack_store_and_dispatch.rb +101 -0
- data/sipper_test/test_prack_timer.rb +105 -0
- data/sipper_test/test_ps_sipper_map.rb +56 -0
- data/sipper_test/test_re_invite_uas_ongoing_ict.rb +81 -0
- data/sipper_test/test_re_invite_uas_ongoing_ist.rb +84 -0
- data/sipper_test/test_re_invite_with_ongoing_ict.rb +101 -0
- data/sipper_test/test_re_invite_with_ongoing_ist.rb +89 -0
- data/sipper_test/test_recorder_swap.rb +157 -0
- data/sipper_test/test_refer.rb +121 -0
- data/sipper_test/test_registeration_clearing.rb +97 -0
- data/sipper_test/test_registrar.rb +109 -0
- data/sipper_test/test_registration_controller.rb +73 -0
- data/sipper_test/test_registration_timeout.rb +90 -0
- data/sipper_test/test_remote_controller.rb +39 -0
- data/sipper_test/test_remote_target_update_on2xx.rb +140 -0
- data/sipper_test/test_request.rb +106 -0
- data/sipper_test/test_response.rb +40 -0
- data/sipper_test/test_response_without_to_tag.rb +92 -0
- data/sipper_test/test_rport.rb +88 -0
- data/sipper_test/test_sdp.rb +91 -0
- data/sipper_test/test_sdp_parser.rb +145 -0
- data/sipper_test/test_session.rb +276 -0
- data/sipper_test/test_session_callback_handler.rb +68 -0
- data/sipper_test/test_session_lifetime.rb +66 -0
- data/sipper_test/test_session_manager.rb +141 -0
- data/sipper_test/test_session_recorder.rb +145 -0
- data/sipper_test/test_session_state_user_defined.rb +84 -0
- data/sipper_test/test_session_states.rb +91 -0
- data/sipper_test/test_simple_dialog_state.rb +86 -0
- data/sipper_test/test_simple_re_invite.rb +86 -0
- data/sipper_test/test_sip_uri.rb +234 -0
- data/sipper_test/test_sipper_util.rb +45 -0
- data/sipper_test/test_smc_controller.rb +17 -0
- data/sipper_test/test_smoke.rb +80 -0
- data/sipper_test/test_stray.rb +28 -0
- data/sipper_test/test_stray_inline.rb +89 -0
- data/sipper_test/test_stray_res_acked.rb +103 -0
- data/sipper_test/test_stray_respond.rb +104 -0
- data/sipper_test/test_stray_retry.rb +92 -0
- data/sipper_test/test_stray_retry_failure.rb +93 -0
- data/sipper_test/test_stray_retry_initial.rb +100 -0
- data/sipper_test/test_strict_router_with_angled.rb +84 -0
- data/sipper_test/test_string_record.rb +31 -0
- data/sipper_test/test_subscribe_notify.rb +141 -0
- data/sipper_test/test_subscribe_notify_client_timeout.rb +158 -0
- data/sipper_test/test_subscribe_notify_dialog.rb +146 -0
- data/sipper_test/test_subscribe_notify_expires.rb +155 -0
- data/sipper_test/test_subscribe_notify_multiple_subscription.rb +157 -0
- data/sipper_test/test_subscribe_notify_server_timeout.rb +144 -0
- data/sipper_test/test_subsequent_unsent.rb +88 -0
- data/sipper_test/test_target_refresh_proxy_detached.rb +128 -0
- data/sipper_test/test_target_refresh_proxy_udp.rb +130 -0
- data/sipper_test/test_target_refresh_rr_proxy_udp.rb +133 -0
- data/sipper_test/test_target_refresh_with_new_port.rb +158 -0
- data/sipper_test/test_target_refresh_with_proxy1.rb +113 -0
- data/sipper_test/test_target_refresh_with_rr_update_proxy.rb +145 -0
- data/sipper_test/test_target_refresh_with_update_proxy.rb +144 -0
- data/sipper_test/test_target_refresh_with_update_proxy2.rb +139 -0
- data/sipper_test/test_timer_manager.rb +71 -0
- data/sipper_test/test_timer_task.rb +60 -0
- data/sipper_test/test_transport_handler.rb +19 -0
- data/sipper_test/test_transport_multi_handler.rb +18 -0
- data/sipper_test/test_udp_transport.rb +119 -0
- data/sipper_test/test_unparsed.rb +70 -0
- data/sipper_test/test_validations.rb +69 -0
- data/sipper_test/test_with_rr_proxy.rb +111 -0
- data/sipper_test/testmediacontroller.rb +71 -0
- data/sipper_test/tracing.rb +23 -0
- data/sipper_test/transaction_test_helper.rb +176 -0
- data/sipper_test/transport_filters.rb +26 -0
- data/sipper_test/ts_sipper.rb +91 -0
- data/sipper_test/ts_smoke.rb +3 -0
- data/sipper_test/tt.cmd +20 -0
- metadata +455 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'util/timer/timer_manager'
|
2
|
+
require 'util/timer/timer_task'
|
3
|
+
|
4
|
+
module SIP
|
5
|
+
class SipTimerHelper
|
6
|
+
|
7
|
+
def initialize(manager)
|
8
|
+
@tm = manager
|
9
|
+
end
|
10
|
+
|
11
|
+
# Have methods for all protocol timers here, along with other type of timers
|
12
|
+
# like user level timers
|
13
|
+
|
14
|
+
def schedule_for(target, tid, block=nil, type=:session, duration=500)
|
15
|
+
task = TimerTask.new(target, block, tid, type, duration)
|
16
|
+
@tm.schedule task
|
17
|
+
return task
|
18
|
+
end
|
19
|
+
|
20
|
+
def granularity
|
21
|
+
@tm.granularity
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'facets', '= 1.8.54'
|
3
|
+
#require 'facets/more/pqueue'
|
4
|
+
require 'ruby_ext/pqueue'
|
5
|
+
require 'monitor'
|
6
|
+
|
7
|
+
require 'sip_logger'
|
8
|
+
require 'util/sipper_util'
|
9
|
+
|
10
|
+
module SIP
|
11
|
+
class TimerManager
|
12
|
+
include SipLogger
|
13
|
+
include SipperUtil
|
14
|
+
|
15
|
+
attr_reader :granularity
|
16
|
+
|
17
|
+
MAX_TIME = Time.local(2038, "jan", 1).to_f*1000 # a long time
|
18
|
+
|
19
|
+
def initialize(msg_q=nil, granularity=50)
|
20
|
+
@msg_q = msg_q
|
21
|
+
#@pqueue = PQueue.new() {|x,y| x<y}
|
22
|
+
@pqueue = PQueue.new(lambda {|x,y| x<y})
|
23
|
+
@lock = Monitor.new
|
24
|
+
@cond = @lock.new_cond
|
25
|
+
@granularity = granularity
|
26
|
+
@running = false
|
27
|
+
@next_schedule = MAX_TIME
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def schedule(task)
|
32
|
+
log_and_raise "Timer Manager not running", RuntimeError unless @running
|
33
|
+
if task.canceled?
|
34
|
+
logw("TimerTask #{task} is canceled, will not be scheduled")
|
35
|
+
return
|
36
|
+
end
|
37
|
+
@lock.synchronize do
|
38
|
+
@pqueue.push task
|
39
|
+
@cond.signal if @next_schedule > task.abs_msec + @granularity
|
40
|
+
end
|
41
|
+
task
|
42
|
+
end
|
43
|
+
|
44
|
+
# possibly keep a separate list and then just gloss over when due.
|
45
|
+
def remove_task(task)
|
46
|
+
end
|
47
|
+
|
48
|
+
def start
|
49
|
+
logi "Starting the TimerManager"
|
50
|
+
@running = true
|
51
|
+
Thread.new do
|
52
|
+
@lock.synchronize do
|
53
|
+
while @running
|
54
|
+
# look for top if not current then wait on cond
|
55
|
+
if (t = @pqueue.top)
|
56
|
+
diff = t.abs_msec - Time.ctm
|
57
|
+
if diff >= @granularity
|
58
|
+
@next_schedule = t.abs_msec
|
59
|
+
@cond.wait(diff/1000.0)
|
60
|
+
else
|
61
|
+
@msg_q << @pqueue.pop
|
62
|
+
end
|
63
|
+
else
|
64
|
+
@next_schedule = MAX_TIME
|
65
|
+
@cond.wait
|
66
|
+
end
|
67
|
+
end #while
|
68
|
+
end #lock
|
69
|
+
end #thread
|
70
|
+
end #def
|
71
|
+
|
72
|
+
|
73
|
+
def stop
|
74
|
+
logi "Stopping the TimerManager"
|
75
|
+
@running = false
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'ruby_ext/time'
|
2
|
+
require 'sip_logger'
|
3
|
+
|
4
|
+
# The target can be anything which defines a on_timer method. For our purposes it can be
|
5
|
+
# a session for most part and possibly transaction.
|
6
|
+
# todo update this doc.
|
7
|
+
# type can be :session, :app, :transaction. also note that for both :app and :session
|
8
|
+
# the target is session.
|
9
|
+
|
10
|
+
module SIP
|
11
|
+
class TimerTask
|
12
|
+
include Comparable
|
13
|
+
attr_reader :abs_msec, :tid, :task, :target, :type, :duration
|
14
|
+
|
15
|
+
def initialize(target, task_proc=nil, tid="sip_task", type=:session, duration=100)
|
16
|
+
raise ArgumentError, "Time cannot be in past" if duration < 0
|
17
|
+
@duration = duration
|
18
|
+
@target = target
|
19
|
+
@type = type
|
20
|
+
if task_proc
|
21
|
+
@task = task_proc
|
22
|
+
elsif block_given?
|
23
|
+
@task = Proc.new # converts the block given to initialize to Proc
|
24
|
+
end
|
25
|
+
@tid = tid
|
26
|
+
@abs_msec = Time.ctm + duration
|
27
|
+
@canceled = false
|
28
|
+
end
|
29
|
+
|
30
|
+
# Compare on time only
|
31
|
+
def <=>(that)
|
32
|
+
abs_msec <=> that.abs_msec
|
33
|
+
end
|
34
|
+
|
35
|
+
def invoke
|
36
|
+
if @canceled
|
37
|
+
SipLogger['siplog::sip_timermanager'].info("Not invoking timer #{self} as it is canceled")
|
38
|
+
return
|
39
|
+
end
|
40
|
+
@target.on_timer_expiration self
|
41
|
+
end
|
42
|
+
|
43
|
+
def canceled?
|
44
|
+
@canceled
|
45
|
+
end
|
46
|
+
|
47
|
+
def cancel
|
48
|
+
@canceled = true
|
49
|
+
SipLogger['siplog::sip_timermanager'].info("Canceled the timer #{self}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def short_to_s
|
53
|
+
self.to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module SIP
|
2
|
+
module Validations
|
3
|
+
|
4
|
+
def validate_presence_of_headers(*hdr_names)
|
5
|
+
hdr_names.each do |hdr|
|
6
|
+
if self.imessage[hdr]
|
7
|
+
self.do_record("true")
|
8
|
+
else
|
9
|
+
self.do_record("header #{hdr} not found in the message")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def validate_header_values(hdr_val_hash)
|
15
|
+
hdr_val_hash.each do |k,v|
|
16
|
+
if self.imessage[k]
|
17
|
+
mvh = v.split(",").sort
|
18
|
+
if mvh == self.imessage[k].sort
|
19
|
+
self.do_record("true")
|
20
|
+
else
|
21
|
+
self.do_record("actual header value found is #{self.imessage[k]}")
|
22
|
+
end
|
23
|
+
else
|
24
|
+
self.do_record("header #{k} not found in the message")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def validate_presence_of_header_params(hdr_name, *params)
|
30
|
+
if hdr=self.imessage[hdr_name]
|
31
|
+
params.each do |p|
|
32
|
+
if hdr[0].send p.to_sym
|
33
|
+
self.do_record("true")
|
34
|
+
else
|
35
|
+
self.do_record("param #{p} not found on #{hdr_name}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
self.do_record("header #{hdr_name} not found in the message")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
data/sipper/version.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'driven_sip_test_case'
|
2
|
+
|
3
|
+
class Testmediacontroller < DrivenSipTestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@sm = SipperConfigurator[:SipperMedia]
|
7
|
+
SipperConfigurator[:SipperMedia] = true
|
8
|
+
super
|
9
|
+
SipperConfigurator[:SessionRecord]='msg-info'
|
10
|
+
SipperConfigurator[:WaitSecondsForTestCompletion] = 40
|
11
|
+
str = <<-EOF
|
12
|
+
# FLOW : > INVITE, < 200, > ACK
|
13
|
+
#
|
14
|
+
require 'base_controller'
|
15
|
+
|
16
|
+
class TestmediacontrollerController < SIP::SipTestDriverController
|
17
|
+
|
18
|
+
# change the directive below to true to enable transaction usage.
|
19
|
+
# If you do that then make sure that your controller is also
|
20
|
+
# transaction aware. i.e does not try send ACK to non-2xx responses,
|
21
|
+
# does not send 100 Trying response etc.
|
22
|
+
|
23
|
+
transaction_usage :use_transactions=>true
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
logd('Controller created')
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def on_register(session)
|
31
|
+
session.respond_with(200)
|
32
|
+
registration_store.put(:bob, session.irequest.contact.uri.to_s)
|
33
|
+
session.invalidate(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def on_invite(s)
|
38
|
+
s.set_media_attributes(:codec=>['G711U', 'DTMF'],
|
39
|
+
:type=>'SENDRECV',
|
40
|
+
:play=>{:file=>'hello_sipper.au', :repeat=>false},
|
41
|
+
:record_file=>'in_sipper.au',
|
42
|
+
:remote_m_line=>['any'])
|
43
|
+
s.respond_with(200)
|
44
|
+
end
|
45
|
+
|
46
|
+
def on_subscribe(session)
|
47
|
+
session.respond_with(200)
|
48
|
+
end
|
49
|
+
|
50
|
+
def on_media_audio_started(session)
|
51
|
+
puts "NK **** Media started**"
|
52
|
+
end
|
53
|
+
|
54
|
+
def on_media_audio_stopped(session)
|
55
|
+
puts "NK **** Media stopped**"
|
56
|
+
end
|
57
|
+
|
58
|
+
def on_media_dtmf_received(session)
|
59
|
+
puts "NK*********DTMF key received****"+session.imedia_event.dtmf
|
60
|
+
end
|
61
|
+
|
62
|
+
def on_ack(session)
|
63
|
+
#sleep 15
|
64
|
+
#session.invalidate
|
65
|
+
#session.flow_completed_for('Testmediacontroller')
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
EOF
|
70
|
+
define_controller_from(str)
|
71
|
+
set_controller('TestmediacontrollerController')
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_case_1
|
75
|
+
self.expected_flow = ['> INVITE','< 200','> ACK']
|
76
|
+
start_controller
|
77
|
+
verify_call_flow(:out)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),"..","sipper")
|
2
|
+
|
3
|
+
require 'sipper'
|
4
|
+
|
5
|
+
$:.unshift File.join(SipperConfigurator[:SipperBasePath],"sipper","lib")
|
6
|
+
$:.unshift File.join(SipperConfigurator[:SipperBasePath],"sipper","lib", "smc")
|
7
|
+
|
8
|
+
require 'sipper_assertions'
|
9
|
+
|
10
|
+
require 'yaml'
|
11
|
+
require 'session_recorder'
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
|
15
|
+
#Signal.trap("INT") { puts; exit }
|
16
|
+
|
17
|
+
class BaseTestCase < Test::Unit::TestCase
|
18
|
+
|
19
|
+
def setup
|
20
|
+
SipperConfigurator[:SessionRecordPath] = File.join(SipperConfigurator[:LogPath], ".Test#{self.class.name}")
|
21
|
+
FileUtils.mkdir_p SipperConfigurator[:SessionRecordPath]
|
22
|
+
#puts "Now testing #{self.class.name}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown
|
26
|
+
FileUtils.rm_r SipperConfigurator[:SessionRecordPath] unless (Dir.glob(File.join(SipperConfigurator[:SessionRecordPath], "*"))).length>0 if File.exist?(SipperConfigurator[:SessionRecordPath]) if SipperConfigurator[:SessionRecordPath]
|
27
|
+
end
|
28
|
+
|
29
|
+
undef_method :default_test
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'sip_test_case'
|
2
|
+
require 'test_completion_signaling_helper'
|
3
|
+
require 'sipper_configurator'
|
4
|
+
require 'util/expectation_parser'
|
5
|
+
|
6
|
+
class DrivenSipTestCase < SipTestCase
|
7
|
+
|
8
|
+
@@now_running = "DrivenSipTestCase"
|
9
|
+
|
10
|
+
def start_controller(in_mem_rec=false)
|
11
|
+
SipperConfigurator[:SessionTimer] = SIP::Locator[:Sth].granularity # we want a quick invalidation for driven test cases
|
12
|
+
# see test_completion_signaling_helper for descriptive comment on this
|
13
|
+
# sequence.
|
14
|
+
_prep_monitor
|
15
|
+
super
|
16
|
+
wait_for_signaling
|
17
|
+
end
|
18
|
+
|
19
|
+
def start_named_controller_non_blocking(name, in_mem_rec=false)
|
20
|
+
set_controller(name)
|
21
|
+
SipperConfigurator[:SessionTimer] = SIP::Locator[:Sth].granularity # we want a quick invalidation for driven test cases
|
22
|
+
# see test_completion_signaling_helper for descriptive comment on this
|
23
|
+
# sequence.
|
24
|
+
_prep_monitor
|
25
|
+
start_the_set_controller(in_mem_rec)
|
26
|
+
end
|
27
|
+
|
28
|
+
def _prep_monitor
|
29
|
+
@sd = SIP::TestCompletionSignalingHelper.prepare_monitor_for(self.class.name) unless @sd
|
30
|
+
@ok_to_wait = true
|
31
|
+
end
|
32
|
+
|
33
|
+
def wait_for_signaling
|
34
|
+
if @ok_to_wait
|
35
|
+
SIP::TestCompletionSignalingHelper.wait_for_completion_on(@sd)
|
36
|
+
@ok_to_wait = false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Runs assertions against the expected flow.
|
41
|
+
# assert_equal("> INFO", record_out.get_recording[0])
|
42
|
+
def verify_call_flow(direction, idx=0)
|
43
|
+
if current_controller && current_controller.class < SIP::SipTestDriverController
|
44
|
+
if direction.to_s == "in"
|
45
|
+
recording = get_in_recording(idx).get_info_only_recording
|
46
|
+
elsif direction.to_s == "out"
|
47
|
+
recording = get_out_recording(idx).get_info_only_recording
|
48
|
+
end
|
49
|
+
expectation = @flowarr
|
50
|
+
ep = SipperUtil::ExpectationParser.new
|
51
|
+
ep.parse(expectation)
|
52
|
+
recording.each do |msg|
|
53
|
+
begin
|
54
|
+
match_result = ep.match(msg)
|
55
|
+
assert(match_result[0])
|
56
|
+
rescue Test::Unit::AssertionFailedError => e
|
57
|
+
raise Test::Unit::AssertionFailedError.new("Expected= #{match_result[1]} Actual= #{msg}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
flunk "The controller #{current_controller} is not a proper controller for flow verification"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Flow(s) are the array of messages with their direction in the form
|
66
|
+
# of arrows.
|
67
|
+
# "INVITE >" indicates an outgoing INVITE request and "180 <" indicates an
|
68
|
+
# incoming 180 response.
|
69
|
+
# The expected messages further have a mini grammar to indicate the various
|
70
|
+
# options in the expected flow.
|
71
|
+
# * a trailing ? (question) of the arrow indicates an optional message, 100 <? means an optional 100, i.e 0 or 1
|
72
|
+
# * a trailing + (plus) of the arrow indicates at least 1 of the message 1 or more
|
73
|
+
# * a trailing * (star) of the arrow is for 0 or more of the messages.
|
74
|
+
# Note if the flow is [...."180 <", "180 <", ...] then it means that 2 distinct 180s are expected
|
75
|
+
# while a "180 <+" means that exactly "same" 180 response is to be received twice.
|
76
|
+
# The responses can also take wildcards like "18x" matches any of the 180-189 response code,
|
77
|
+
# 1xx is any provisional response including 100.
|
78
|
+
# Two special modifiers "gt" and "lt" can also be used with the responses with a period in between.
|
79
|
+
# "1xx.gt.100 <" indicates an expectation of a 1xx class response but greater than 100.
|
80
|
+
#
|
81
|
+
# Expected flow is an array with messages like
|
82
|
+
# ["> INFO", "< 200", "< INFO", "> 200", "> INFO", "< 200"]
|
83
|
+
# In order to signal the end of test we need to find the smallest non-repeating pattern in the
|
84
|
+
# expected flow (from the end) and then compare the building actual flow against it.
|
85
|
+
# Whenever flow is complete we signal the test class.
|
86
|
+
def expected_flow=(flowarr)
|
87
|
+
@flowarr = flowarr
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_controller(name)
|
91
|
+
super
|
92
|
+
end
|
93
|
+
private :_prep_monitor
|
94
|
+
end
|
95
|
+
|
96
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
INVITE sip:nasir@agnity.com SIP/2.0
|
2
|
+
Contact: <sip:127.0.0.1:5060;transport=UDP>
|
3
|
+
P-Asserted-Identity: <sip:nina@home.com>
|
4
|
+
Max-Forwards: 70
|
5
|
+
Call-ID: 1-_PID_@127.0.0.1
|
6
|
+
Via: SIP/2.0/UDP 127.0.0.1:5061;branch=z9hG4bK-1-0-1
|
7
|
+
From: Sipper <sip:sipper@127.0.0.1:5060>;tag=2
|
8
|
+
To: Sut <sip:sut@127.0.0.1:5061>
|
9
|
+
Cseq: 1 INVITE
|
10
|
+
Content-Length: 0
|