sippy_cup 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +9 -9
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +2 -0
- data/Guardfile +4 -9
- data/README.markdown +28 -28
- data/Rakefile +2 -3
- data/bin/sippy_cup +16 -26
- data/lib/sippy_cup/media.rb +3 -1
- data/lib/sippy_cup/runner.rb +148 -50
- data/lib/sippy_cup/scenario.rb +436 -206
- data/lib/sippy_cup/tasks.rb +3 -3
- data/lib/sippy_cup/version.rb +1 -1
- data/lib/sippy_cup/xml_scenario.rb +57 -0
- data/lib/sippy_cup.rb +1 -0
- data/sippy_cup.gemspec +2 -1
- data/spec/fixtures/dtmf_2833_1.pcap +0 -0
- data/spec/fixtures/scenario.xml +73 -0
- data/spec/sippy_cup/fixtures/test.yml +16 -0
- data/spec/sippy_cup/runner_spec.rb +425 -71
- data/spec/sippy_cup/scenario_spec.rb +820 -71
- data/spec/sippy_cup/xml_scenario_spec.rb +103 -0
- data/spec/spec_helper.rb +5 -2
- metadata +30 -5
- data/tmp/rspec_guard_result +0 -1
data/lib/sippy_cup/tasks.rb
CHANGED
@@ -7,9 +7,9 @@ namespace :sippy_cup do
|
|
7
7
|
require File.expand_path(args[:scenario])
|
8
8
|
end
|
9
9
|
|
10
|
-
desc "Run the scenario described by the given
|
10
|
+
desc "Run the scenario described by the given manifest file"
|
11
11
|
task :run, :options_file do |t, args|
|
12
|
-
|
13
|
-
SippyCup::Runner.new(
|
12
|
+
scenario = SippyCup::Scenario.from_manifest File.read(args[:options_file])
|
13
|
+
SippyCup::Runner.new(scenario).run
|
14
14
|
end
|
15
15
|
end
|
data/lib/sippy_cup/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module SippyCup
|
4
|
+
#
|
5
|
+
# A representation of a SIPp XML scenario
|
6
|
+
#
|
7
|
+
class XMLScenario
|
8
|
+
# @return [Hash] The options the scenario was created with, either from a manifest or passed as overrides
|
9
|
+
attr_reader :scenario_options
|
10
|
+
|
11
|
+
#
|
12
|
+
# Create a scenario instance
|
13
|
+
#
|
14
|
+
# @param [String] name The scenario's name
|
15
|
+
# @param [String] xml The XML document representing the scenario
|
16
|
+
# @param [String] media The media to be invoked by the scenario in PCAP format
|
17
|
+
# @param [Hash] args options to customise the scenario. @see Scenario#initialize.
|
18
|
+
#
|
19
|
+
def initialize(name, xml, media, args = {})
|
20
|
+
@xml, @media = xml, media
|
21
|
+
@scenario_options = args.merge name: name
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Write compiled Scenario XML and PCAP media to tempfiles.
|
26
|
+
#
|
27
|
+
# These will automatically be closed and deleted once they have gone out of scope, and can be used to execute the scenario without leaving stuff behind.
|
28
|
+
#
|
29
|
+
# @return [Hash<Symbol => Tempfile>] handles to created Tempfiles at :scenario and :media
|
30
|
+
#
|
31
|
+
# @see http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html
|
32
|
+
#
|
33
|
+
def to_tmpfiles
|
34
|
+
scenario_file = Tempfile.new 'scenario'
|
35
|
+
scenario_file.write @xml
|
36
|
+
scenario_file.rewind
|
37
|
+
|
38
|
+
if @media
|
39
|
+
media_file = Tempfile.new 'media'
|
40
|
+
media_file.write @media
|
41
|
+
media_file.rewind
|
42
|
+
else
|
43
|
+
media_file = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
{scenario: scenario_file, media: media_file}
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Dump the scenario to a SIPp XML string
|
51
|
+
#
|
52
|
+
# @return [String] the SIPp XML scenario
|
53
|
+
def to_xml
|
54
|
+
@xml
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/sippy_cup.rb
CHANGED
data/sippy_cup.gemspec
CHANGED
@@ -21,10 +21,11 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency 'packetfu'
|
22
22
|
s.add_runtime_dependency 'nokogiri', ["~> 1.6.0"]
|
23
23
|
s.add_runtime_dependency 'activesupport', ["> 3.0"]
|
24
|
+
s.add_runtime_dependency 'psych', ["~> 2.0.0"] unless RUBY_PLATFORM == 'java'
|
24
25
|
|
25
26
|
s.add_development_dependency 'guard-rspec'
|
26
27
|
s.add_development_dependency 'rspec', ["~> 2.11"]
|
27
28
|
s.add_development_dependency 'simplecov'
|
28
29
|
s.add_development_dependency 'simplecov-rcov'
|
29
|
-
s.add_development_dependency '
|
30
|
+
s.add_development_dependency 'fakefs'
|
30
31
|
end
|
File without changes
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<scenario name="spec scenario">
|
3
|
+
<send retrans="500">
|
4
|
+
<![CDATA[
|
5
|
+
INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
|
6
|
+
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
7
|
+
From: "#{specs_from}" <sip:#{specs_from}@[local_ip]>;tag=[call_number]
|
8
|
+
To: <sip:[service]@[remote_ip]:[remote_port]>
|
9
|
+
Call-ID: [call_id]
|
10
|
+
CSeq: [cseq] INVITE
|
11
|
+
Contact: <sip:#{specs_from}@[local_ip]:[local_port];transport=[transport]>
|
12
|
+
Max-Forwards: 100
|
13
|
+
User-Agent: SIPp/sippy_cup
|
14
|
+
Content-Type: application/sdp
|
15
|
+
Content-Length: [len]
|
16
|
+
|
17
|
+
v=0
|
18
|
+
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
|
19
|
+
s=-
|
20
|
+
c=IN IP[media_ip_type] [media_ip]
|
21
|
+
t=0 0
|
22
|
+
m=audio [media_port] RTP/AVPF 0 101
|
23
|
+
a=rtcp:[media_port+1]
|
24
|
+
a=rtpmap:0 PCMU/8000
|
25
|
+
a=rtpmap:101 telephone-event/8000
|
26
|
+
a=fmtp:101 0-15
|
27
|
+
]]>
|
28
|
+
</send>
|
29
|
+
<recv optional="true" response="100"/>
|
30
|
+
<recv optional="true" response="180"/>
|
31
|
+
<recv optional="true" response="183"/>
|
32
|
+
<recv response="200" rrs="true" rtd="true"/>
|
33
|
+
<send>
|
34
|
+
<![CDATA[
|
35
|
+
ACK [next_url] SIP/2.0
|
36
|
+
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
37
|
+
From: "#{specs_from}" <sip:#{specs_from}@[local_ip]>;tag=[call_number]
|
38
|
+
[last_To:]
|
39
|
+
Call-ID: [call_id]
|
40
|
+
CSeq: [cseq] ACK
|
41
|
+
Contact: <sip:#{specs_from}@[local_ip]:[local_port];transport=[transport]>
|
42
|
+
Max-Forwards: 100
|
43
|
+
User-Agent: SIPp/sippy_cup
|
44
|
+
Content-Length: 0
|
45
|
+
[routes]
|
46
|
+
]]>
|
47
|
+
</send>
|
48
|
+
<nop>
|
49
|
+
<action>
|
50
|
+
<exec play_pcap_audio="/tmp/spec_scenario.pcap"/>
|
51
|
+
</action>
|
52
|
+
</nop>
|
53
|
+
<pause milliseconds="3000"/>
|
54
|
+
<pause milliseconds="5000"/>
|
55
|
+
<pause milliseconds="5000"/>
|
56
|
+
<pause milliseconds="500"/>
|
57
|
+
<recv request="BYE"/>
|
58
|
+
<send>
|
59
|
+
<![CDATA[
|
60
|
+
SIP/2.0 200 OK
|
61
|
+
[last_Via:]
|
62
|
+
[last_From:]
|
63
|
+
[last_To:]
|
64
|
+
[last_Call-ID:]
|
65
|
+
[last_CSeq:]
|
66
|
+
Contact: <sip:#{specs_from}@[local_ip]:[local_port];transport=[transport]>
|
67
|
+
Max-Forwards: 100
|
68
|
+
User-Agent: SIPp/sippy_cup
|
69
|
+
Content-Length: 0
|
70
|
+
[routes]
|
71
|
+
]]>
|
72
|
+
</send>
|
73
|
+
</scenario>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
name: My test scenario
|
3
|
+
source: 192.0.2.15
|
4
|
+
destination: 192.0.2.200
|
5
|
+
max_concurrent: 10
|
6
|
+
calls_per_second: 5
|
7
|
+
number_of_calls: 20
|
8
|
+
steps:
|
9
|
+
- invite
|
10
|
+
- wait_for_answer
|
11
|
+
- ack_answer
|
12
|
+
- sleep 3
|
13
|
+
- send_digits '3125551234'
|
14
|
+
- sleep 5
|
15
|
+
- send_digits '#'
|
16
|
+
- wait_for_hangup
|