sippy_cup 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0bf8b63922a80ba9eb886d9ad0713f953376f6f6
4
+ data.tar.gz: df89e36db406772721fb83164372f1e7c7787261
5
+ SHA512:
6
+ metadata.gz: 436f979aeee94dfbe201ec011ba339cf12977dc9929741bb07c9beee9fe4ccfda3d0f113263b0ca5ad1f003d475e9e2dc2e37c247cabe527cb549f4d26c164cc
7
+ data.tar.gz: 7c613e7768152d9e6a84d3145abfeca4396363fb2aaeaabec2927d45329ecf04f3a5ebc61f06b5a01dd71631aba37618ec05a5c6f2e1909586924986a18d36a6
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .*.sw*
2
+ .DS_Store
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # [develop](https://github.com/bklang/sippy_cup)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'pcap', github: 'ahobson/ruby-pcap'
data/Guardfile ADDED
@@ -0,0 +1,17 @@
1
+ ENV['SKIP_RCOV'] = 'true'
2
+
3
+ group 'rspec' do
4
+ guard 'rspec', :cli => '--format documentation' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec/" }
8
+ end
9
+ end
10
+
11
+ group 'cucumber' do
12
+ guard 'cucumber', :cli => '--profile guard' do
13
+ watch(%r{^features/.+\.feature$})
14
+ watch(%r{^features/support/.+$}) { 'features' }
15
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
16
+ end
17
+ end
data/README.markdown ADDED
@@ -0,0 +1,5 @@
1
+ Sippy Cup
2
+ ---------
3
+
4
+ Sippy Cup is a tool to generate [SIPp](http://sipp.sourceforge.net/) load test profiles. The goal is to take an input document that describes a load test in a very simple way (call this number, wait this many seconds, send this digit, wait a few more seconds, etc). The ideas are taken from [LoadBot](https://github.com/mojolingo/ahn-loadbot), but the goal is for a more performant load generating tool with no dependency on Asterisk.
5
+
data/bin/sippy_cup ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sippy_cup'
data/lib/sippy_cup.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'sippy_cup/scenario'
2
+
3
+ module SippyCup
4
+
5
+ end
@@ -0,0 +1,133 @@
1
+ require 'nokogiri'
2
+
3
+ module SippyCup
4
+ class Scenario
5
+ def initialize(name, &block)
6
+ builder = Nokogiri::XML::Builder.new do |xml|
7
+ xml.scenario name: name
8
+ end
9
+
10
+ @doc = builder.doc
11
+ @scenario = @doc.xpath('//scenario').first
12
+
13
+ instance_eval &block
14
+ end
15
+
16
+ def sleep(seconds)
17
+ # TODO play silent audio files to the server to fill the gap
18
+ pause = Nokogiri::XML::Node.new 'pause', @doc
19
+ pause['milliseconds'] = seconds
20
+ @scenario.add_child pause
21
+ end
22
+
23
+ def invite
24
+ msg = <<-INVITE
25
+ INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
26
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
27
+ From: sipp <sip:[field0]@[local_ip]>;tag=[call_number]
28
+ To: <sip:[service]@[remote_ip]:[remote_port]>
29
+ Call-ID: [call_id]
30
+ CSeq: [cseq] INVITE
31
+ Contact: sip:[field0]@[local_ip]:[local_port]
32
+ Max-Forwards: 100
33
+ Content-Type: application/sdp
34
+ Content-Length: [len]
35
+
36
+ v=0
37
+ o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
38
+ s=-
39
+ c=IN IP[media_ip_type] [media_ip]
40
+ t=0 0
41
+ m=audio [media_port] RTP/AVP 0
42
+ a=rtpmap:0 PCMU/8000
43
+ INVITE
44
+ send = new_send msg
45
+ # FIXME: Does this need to be configurable?
46
+ send['retrans'] = 500
47
+
48
+ @scenario << send
49
+ end
50
+
51
+ def receive_trying(optional = true)
52
+ @scenario.add_child new_recv response: 100, optional: optional
53
+ end
54
+ alias :receive_100 :receive_trying
55
+
56
+ def receive_ringing(optional = true)
57
+ @scenario.add_child new_recv response: 180, optional: optional
58
+ end
59
+ alias :receive_180 :receive_ringing
60
+
61
+ def receive_progress(optional = true)
62
+ @scenario.add_child new_recv response: 183, optional: optional
63
+ end
64
+ alias :receive_183 :receive_progress
65
+
66
+ def receive_answer
67
+ recv = new_recv response: 200, optional: false
68
+ # Record Record Set: Make the Route headers available via [route] later
69
+ recv['rrs'] = true
70
+ @scenario.add_child recv
71
+ end
72
+ alias :receive_200 :receive_answer
73
+
74
+ def ack_answer
75
+ msg = <<-ACK
76
+ ACK [next_url] SIP/2.0
77
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
78
+ From: <sip:[field0]@[local_ip]>;tag=[call_number]
79
+ [last_To:]
80
+ [routes]
81
+ Call-ID: [call_id]
82
+ CSeq: [cseq] ACK
83
+ Contact: sip:[field0]@[local_ip]:[local_port]
84
+ Max-Forwards: 100
85
+ Content-Length: 0
86
+ ACK
87
+ @scenario << new_send(msg)
88
+ end
89
+
90
+ def receive_bye
91
+ @scenario.add_child new_recv response: 'BYE'
92
+ end
93
+
94
+ def ack_bye
95
+ msg = <<-ACK
96
+ SIP/2.0 200 OK
97
+ [last_Via:]
98
+ [last_From:]
99
+ [last_To:]
100
+ [routes]
101
+ [last_Call-ID:]
102
+ [last_CSeq:]
103
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
104
+ Max-Forwards: 100
105
+ Content-Length: 0
106
+ ACK
107
+ @scenario << new_send(msg)
108
+ end
109
+
110
+ def to_xml
111
+ @doc.to_xml
112
+ end
113
+
114
+ private
115
+
116
+ def new_send(msg)
117
+ send = Nokogiri::XML::Node.new 'send', @doc
118
+ send << Nokogiri::XML::Text.new(msg, @doc)
119
+ send
120
+ end
121
+
122
+ def new_recv(opts = {})
123
+ raise ArgumentError, "Receive must include either a response or a request" unless opts.keys.include?(:response) || opts.keys.include?(:request)
124
+ recv = Nokogiri::XML::Node.new 'recv', @doc
125
+ recv['request'] = opts[:request] if opts.keys.include? :request
126
+ recv['response'] = opts[:response] if opts.keys.include? :response
127
+ recv['optional'] = !!opts[:optional]
128
+ recv
129
+ end
130
+ end
131
+
132
+ end
133
+
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module SippyCup
4
+ VERSION = '0.0.1'
5
+ end
data/sippy_cup.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sippy_cup/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sippy_cup"
7
+ s.version = SippyCup::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ben Klang"]
10
+ s.email = "bklang&mojolingo.com"
11
+ s.homepage = "https://github.com/bklang/sippy_cup"
12
+ s.summary = "SIPp profile and RTP stream generator"
13
+ s.description = "This tool makes it easier to generate SIPp load tests with DTMF interactions."
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency 'pcap'
21
+ s.add_runtime_dependency 'nokogiri', ["~> 1.5.0"]
22
+
23
+ s.add_development_dependency 'guard-rspec'
24
+ s.add_development_dependency 'rspec', ["~> 2.11"]
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'simplecov-rcov'
27
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sippy_cup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben Klang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pcap
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov-rcov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: This tool makes it easier to generate SIPp load tests with DTMF interactions.
98
+ email: bklang&mojolingo.com
99
+ executables:
100
+ - sippy_cup
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - CHANGELOG.md
106
+ - Gemfile
107
+ - Guardfile
108
+ - README.markdown
109
+ - bin/sippy_cup
110
+ - lib/sippy_cup.rb
111
+ - lib/sippy_cup/scenario.rb
112
+ - lib/sippy_cup/version.rb
113
+ - sippy_cup.gemspec
114
+ homepage: https://github.com/bklang/sippy_cup
115
+ licenses: []
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.0.3
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: SIPp profile and RTP stream generator
137
+ test_files: []
138
+ has_rdoc: