kronk 1.8.5 → 1.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,15 @@
1
+ === 1.8.6 / 2012-04-23
2
+
3
+ * Enhancements:
4
+
5
+ * Split out path logic into the ruby-path gem.
6
+
7
+ * Bugfixes:
8
+
9
+ * Support file uploads with Player.
10
+
11
+ * Allow using files in the Suite Player.
12
+
1
13
  === 1.8.5 / 2012-03-26
2
14
 
3
15
  * Bugfixes:
data/Manifest.txt CHANGED
@@ -7,7 +7,6 @@ bin/kronk
7
7
  lib/kronk.rb
8
8
  lib/kronk/cmd.rb
9
9
  lib/kronk/constants.rb
10
- lib/kronk/core_ext.rb
11
10
  lib/kronk/data_string.rb
12
11
  lib/kronk/diff.rb
13
12
  lib/kronk/diff/ascii_format.rb
@@ -15,10 +14,6 @@ lib/kronk/diff/color_format.rb
15
14
  lib/kronk/diff/output.rb
16
15
  lib/kronk/http.rb
17
16
  lib/kronk/buffered_io.rb
18
- lib/kronk/path.rb
19
- lib/kronk/path/matcher.rb
20
- lib/kronk/path/match.rb
21
- lib/kronk/path/transaction.rb
22
17
  lib/kronk/player.rb
23
18
  lib/kronk/player/benchmark.rb
24
19
  lib/kronk/player/input_reader.rb
@@ -48,19 +43,14 @@ test/mocks/cookies.yml
48
43
  test/mocks/get_request.txt
49
44
  test/test_assertions.rb
50
45
  test/test_cmd.rb
51
- test/test_core_ext.rb
52
46
  test/test_data_string.rb
53
47
  test/test_diff.rb
54
48
  test/test_helper.rb
55
49
  test/test_helper_methods.rb
56
50
  test/test_input_reader.rb
57
51
  test/test_kronk.rb
58
- test/test_path.rb
59
- test/test_path_match.rb
60
- test/test_path_matcher.rb
61
52
  test/test_player.rb
62
53
  test/test_request.rb
63
54
  test/test_request_parser.rb
64
55
  test/test_response.rb
65
- test/test_transaction.rb
66
56
  test/test_xml_parser.rb
data/README.rdoc CHANGED
@@ -1,10 +1,15 @@
1
1
  = Kronk
2
2
 
3
- * https://github.com/yaksnrainbows/kronk
3
+ * http://kronk.me
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- Kronk runs diffs against data from live and cached http responses.
7
+ Kronk is a command line swiss-army-knife for HTTP services.
8
+
9
+ With Kronk, you easily parse and segregate data, run diffs between
10
+ the parsed data from different queries, and easily replay logs and loadtest
11
+ your HTTP applications.
12
+
8
13
  Kronk was made possible by the sponsoring of AT&T Interactive.
9
14
 
10
15
  == FEATURES:
data/Rakefile CHANGED
@@ -24,6 +24,7 @@ Hoe.spec 'kronk' do
24
24
 
25
25
  self.extra_deps << ['json', '~>1.5']
26
26
  self.extra_deps << ['cookiejar', '~>0.3.0']
27
+ self.extra_deps << ['ruby-path', '~>1.0.0']
27
28
 
28
29
  self.extra_dev_deps << ['plist', '~>3.1.0']
29
30
  self.extra_dev_deps << ['nokogiri', '~>1.4']
data/lib/kronk.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems' if RUBY_VERSION =~ /1.8/
2
2
 
3
3
  require 'json'
4
4
  require 'cookiejar'
5
+ require 'path'
5
6
 
6
7
  require 'thread'
7
8
  require 'stringio'
@@ -12,7 +13,7 @@ require 'yaml'
12
13
  class Kronk
13
14
 
14
15
  # This gem's version.
15
- VERSION = '1.8.5'
16
+ VERSION = '1.8.6'
16
17
 
17
18
  require 'kronk/constants'
18
19
  require 'kronk/queue_runner'
@@ -23,10 +24,6 @@ class Kronk
23
24
  require 'kronk/player/tsv'
24
25
  require 'kronk/player/request_parser'
25
26
  require 'kronk/player/input_reader'
26
- require 'kronk/path'
27
- require 'kronk/path/match'
28
- require 'kronk/path/matcher'
29
- require 'kronk/path/transaction'
30
27
  require 'kronk/data_string'
31
28
  require 'kronk/diff/ascii_format'
32
29
  require 'kronk/diff/color_format'
data/lib/kronk/cmd.rb CHANGED
@@ -51,7 +51,7 @@ class Kronk
51
51
  resp.body
52
52
  end
53
53
 
54
- $stdout.puts "\nHTTP Response is in $http_response"
54
+ $stdout.puts "\nKronk Response is in $http_response"
55
55
  $stdout.puts "Response data is in $response\n\n"
56
56
 
57
57
  IRB.start
@@ -474,7 +474,7 @@ Parse and run diffs against data from live and cached http responses.
474
474
 
475
475
  opt.on('-T', '--upload-file FILE', String,
476
476
  'Transfer file in HTTP body') do |file|
477
- options[:data] = File.open(file, 'rb')
477
+ options[:file] = file
478
478
  options[:http_method] ||= 'PUT'
479
479
  end
480
480
 
@@ -569,7 +569,7 @@ Parse and run diffs against data from live and cached http responses.
569
569
 
570
570
 
571
571
  ##
572
- # Determine the cmd-given path's action and Kronk::Path representation.
572
+ # Determine the cmd-given path's action and Path representation.
573
573
 
574
574
  def self.process_path path
575
575
  case path
@@ -96,7 +96,7 @@ class Kronk
96
96
 
97
97
  else
98
98
  super ""
99
- data = Kronk::Path.pathed(data) if Kronk.config[:render_paths]
99
+ data = Path.pathed(data) if Kronk.config[:render_paths]
100
100
  @data = data
101
101
  block ||= Kronk.config[:render_lang].to_s == 'ruby' ? TO_RUBY : TO_JSON
102
102
  end
@@ -55,11 +55,11 @@ class Kronk::Diff
55
55
 
56
56
 
57
57
  ##
58
- # Create a Kronk::Path String from an Array. Used when the meta data
58
+ # Create a Path String from an Array. Used when the meta data
59
59
  # given for either side of the diff is an Array.
60
60
 
61
61
  def ary_to_path ary
62
- "#{Kronk::Path::DCH}#{Kronk::Path.join ary}"
62
+ "#{Path::DCH}#{Path.join ary}"
63
63
  end
64
64
 
65
65
 
data/lib/kronk/player.rb CHANGED
@@ -58,6 +58,7 @@ class Kronk
58
58
  on(:interrupt){
59
59
  interrupt and return if respond_to?(:interrupt)
60
60
  complete if respond_to?(:complete)
61
+ kill
61
62
  exit 2
62
63
  }
63
64
  on(:start){
@@ -68,6 +68,7 @@ class Kronk
68
68
  uri.query = nil
69
69
  uri = "#{req.http_method} #{uri.to_s}"
70
70
 
71
+ # TODO: Keep the number in @paths to 10.
71
72
  @paths[uri] ||= [0, 0]
72
73
  pcount = @paths[uri][1] + 1
73
74
  @paths[uri][0] = (@paths[uri][0] * @paths[uri][1] + time) / pcount
@@ -112,15 +112,18 @@ class Kronk
112
112
 
113
113
  non_error_count = @results.length - error_count
114
114
 
115
- avg_time = non_error_count > 0 ? total_time / non_error_count : "n/a"
116
- avg_qps = non_error_count > 0 ? non_error_count / player_time : "n/a"
115
+ avg_time = non_error_count > 0 ?
116
+ ((total_time / non_error_count)* 1000).round(3) : "n/a "
117
+
118
+ avg_qps = non_error_count > 0 ?
119
+ (non_error_count / player_time).round(3) : "n/a"
117
120
 
118
121
  $stderr.puts err_buffer unless err_buffer.empty?
119
122
  $stdout.puts "\n#{@results.length} cases, " +
120
123
  "#{failure_count} failures, #{error_count} errors"
121
124
 
122
- $stdout.puts "Avg Time: #{(avg_time * 1000).round 3}ms"
123
- $stdout.puts "Avg QPS: #{avg_qps.round 3}"
125
+ $stdout.puts "Avg Time: #{avg_time}ms"
126
+ $stdout.puts "Avg QPS: #{avg_qps}"
124
127
 
125
128
  return bad_count == 0
126
129
  end
@@ -130,13 +133,8 @@ class Kronk
130
133
 
131
134
 
132
135
  def resp_text kronk
133
- http_method = kronk.response.request ?
134
- kronk.response.request.http_method :
135
- "(FILE)"
136
-
137
136
  <<-STR
138
- Request: #{kronk.response.code} - #{http_method} \
139
- #{kronk.response.uri}
137
+ Request: #{req_text kronk.response}
140
138
  Options: #{kronk.options.inspect}
141
139
  STR
142
140
  end
@@ -144,12 +142,8 @@ class Kronk
144
142
 
145
143
  def diff_text kronk
146
144
  output = <<-STR
147
- Request: #{kronk.responses[0].code} - \
148
- #{kronk.responses[0].request.http_method} \
149
- #{kronk.responses[0].uri}
150
- #{kronk.responses[1].code} - \
151
- #{kronk.responses[0].request.http_method} \
152
- #{kronk.responses[1].uri}
145
+ Request: #{req_text kronk.responses[0]}
146
+ #{req_text kronk.responses[1]}
153
147
  Options: #{kronk.options.inspect}
154
148
  Diffs: #{kronk.diff.count}
155
149
  STR
@@ -158,6 +152,16 @@ class Kronk
158
152
  end
159
153
 
160
154
 
155
+ def req_text resp
156
+ if resp.headless?
157
+ "(FILE) #{resp.uri}"
158
+ else
159
+ http_method = resp.request ? resp.request.http_method : "(FILE)"
160
+ "#{resp.code} - #{http_method} #{resp.uri}"
161
+ end
162
+ end
163
+
164
+
161
165
  def error_text err, kronk=nil
162
166
  str = " #{err.class}: #{err.message}"
163
167
 
data/lib/kronk/request.rb CHANGED
@@ -212,6 +212,7 @@ class Kronk
212
212
  # Build an http request to the given uri and return a Response instance.
213
213
  # Supports the following options:
214
214
  # :data:: Hash/String - the data to pass to the http request body
215
+ # :file:: String - the path to a file to upload; overrides :data
215
216
  # :form:: Hash/String - similar to :data but sets content-type header
216
217
  # :query:: Hash/String - the data to append to the http request path
217
218
  # :user_agent:: String - user agent string or alias; defaults to 'kronk'
@@ -247,8 +248,14 @@ class Kronk
247
248
  @proxy = opts[:proxy] || {}
248
249
  @proxy = {:host => @proxy} unless Hash === @proxy
249
250
 
250
- self.body = opts[:data] if opts[:data]
251
- self.form_data = opts[:form] if opts[:form]
251
+
252
+ if opts[:file]
253
+ self.body = File.open(opts[:file], 'rb')
254
+ elsif opts[:form]
255
+ self.form_data = opts[:form]
256
+ elsif opts[:data]
257
+ self.body = opts[:data]
258
+ end
252
259
 
253
260
  self.user_agent ||= opts[:user_agent]
254
261
 
@@ -551,7 +551,7 @@ class Kronk
551
551
  # trans.delete "foo/0", "bar/1"
552
552
  # end
553
553
  #
554
- # See Kronk::Path::Transaction for supported transform actions.
554
+ # See Path::Transaction for supported transform actions.
555
555
 
556
556
  def data opts={}
557
557
  data = nil
@@ -590,7 +590,7 @@ class Kronk
590
590
  # :keep_indicies:: Boolean - indicies of modified arrays display as hashes.
591
591
  # :show_headers:: Boolean/String/Array - defines which headers to include
592
592
  #
593
- # If block is given, yields a Kronk::Path::Transaction instance to make
593
+ # If block is given, yields a Path::Transaction instance to make
594
594
  # transformations on the data. See Kronk::Response#data
595
595
 
596
596
  def stringify opts={}, &block
@@ -12,7 +12,7 @@ class Kronk
12
12
  msg ||= "No data found at #{path.inspect} for #{data.inspect}"
13
13
  found = false
14
14
 
15
- Kronk::Path.find path, data do |d,k,p|
15
+ Path.find path, data do |d,k,p|
16
16
  found = true
17
17
  break
18
18
  end
@@ -29,7 +29,7 @@ class Kronk
29
29
  msg ||= "Data found at #{path.inspect} for #{data.inspect}"
30
30
  found = false
31
31
 
32
- Kronk::Path.find path, data do |d,k,p|
32
+ Path.find path, data do |d,k,p|
33
33
  found = true
34
34
  break
35
35
  end
@@ -47,7 +47,7 @@ class Kronk
47
47
  last_data = nil
48
48
  found = false
49
49
 
50
- Kronk::Path.find path, data do |d,k,p|
50
+ Path.find path, data do |d,k,p|
51
51
  found = true
52
52
  last_data = d[k]
53
53
  break if d[k] == match
@@ -68,7 +68,7 @@ class Kronk
68
68
  def assert_data_at_not_equal data, path, match, msg=nil
69
69
  last_data = nil
70
70
 
71
- Kronk::Path.find path, data do |d,k,p|
71
+ Path.find path, data do |d,k,p|
72
72
  last_data = d[k]
73
73
  break if d[k] == match
74
74
  end
data/test/test_helper.rb CHANGED
@@ -123,7 +123,7 @@ IRB = Module.new
123
123
  def with_irb_mock
124
124
  mock_require "irb"
125
125
 
126
- $stdout.expects(:puts).with "\nHTTP Response is in $http_response"
126
+ $stdout.expects(:puts).with "\nKronk Response is in $http_response"
127
127
  $stdout.expects(:puts).with "Response data is in $response\n\n"
128
128
  ::IRB.expects :start
129
129
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kronk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.5
4
+ version: 1.8.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-27 00:00:00.000000000Z
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -43,6 +43,38 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 0.3.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: ruby-path
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.10'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.10'
46
78
  - !ruby/object:Gem::Dependency
47
79
  name: plist
48
80
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +130,7 @@ dependencies:
98
130
  requirements:
99
131
  - - ~>
100
132
  - !ruby/object:Gem::Version
101
- version: '2.11'
133
+ version: '3.0'
102
134
  type: :development
103
135
  prerelease: false
104
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,8 +138,16 @@ dependencies:
106
138
  requirements:
107
139
  - - ~>
108
140
  - !ruby/object:Gem::Version
109
- version: '2.11'
110
- description: ! 'Kronk runs diffs against data from live and cached http responses.
141
+ version: '3.0'
142
+ description: ! 'Kronk is a command line swiss-army-knife for HTTP services.
143
+
144
+
145
+ With Kronk, you easily parse and segregate data, run diffs between
146
+
147
+ the parsed data from different queries, and easily replay logs and loadtest
148
+
149
+ your HTTP applications.
150
+
111
151
 
112
152
  Kronk was made possible by the sponsoring of AT&T Interactive.'
113
153
  email:
@@ -116,8 +156,8 @@ executables:
116
156
  - kronk
117
157
  extensions: []
118
158
  extra_rdoc_files:
119
- - Manifest.txt
120
159
  - History.rdoc
160
+ - Manifest.txt
121
161
  - README.rdoc
122
162
  - TODO.rdoc
123
163
  files:
@@ -130,7 +170,6 @@ files:
130
170
  - lib/kronk.rb
131
171
  - lib/kronk/cmd.rb
132
172
  - lib/kronk/constants.rb
133
- - lib/kronk/core_ext.rb
134
173
  - lib/kronk/data_string.rb
135
174
  - lib/kronk/diff.rb
136
175
  - lib/kronk/diff/ascii_format.rb
@@ -138,10 +177,6 @@ files:
138
177
  - lib/kronk/diff/output.rb
139
178
  - lib/kronk/http.rb
140
179
  - lib/kronk/buffered_io.rb
141
- - lib/kronk/path.rb
142
- - lib/kronk/path/matcher.rb
143
- - lib/kronk/path/match.rb
144
- - lib/kronk/path/transaction.rb
145
180
  - lib/kronk/player.rb
146
181
  - lib/kronk/player/benchmark.rb
147
182
  - lib/kronk/player/input_reader.rb
@@ -171,25 +206,20 @@ files:
171
206
  - test/mocks/get_request.txt
172
207
  - test/test_assertions.rb
173
208
  - test/test_cmd.rb
174
- - test/test_core_ext.rb
175
209
  - test/test_data_string.rb
176
210
  - test/test_diff.rb
177
211
  - test/test_helper.rb
178
212
  - test/test_helper_methods.rb
179
213
  - test/test_input_reader.rb
180
214
  - test/test_kronk.rb
181
- - test/test_path.rb
182
- - test/test_path_match.rb
183
- - test/test_path_matcher.rb
184
215
  - test/test_player.rb
185
216
  - test/test_request.rb
186
217
  - test/test_request_parser.rb
187
218
  - test/test_response.rb
188
- - test/test_transaction.rb
189
219
  - test/test_xml_parser.rb
190
220
  - TODO.rdoc
191
221
  - .gemtest
192
- homepage: https://github.com/yaksnrainbows/kronk
222
+ homepage: http://kronk.me
193
223
  licenses: []
194
224
  post_install_message:
195
225
  rdoc_options:
@@ -203,9 +233,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
233
  - - ! '>='
204
234
  - !ruby/object:Gem::Version
205
235
  version: '0'
206
- segments:
207
- - 0
208
- hash: 2890085585821855848
209
236
  required_rubygems_version: !ruby/object:Gem::Requirement
210
237
  none: false
211
238
  requirements:
@@ -214,26 +241,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
241
  version: '0'
215
242
  requirements: []
216
243
  rubyforge_project: kronk
217
- rubygems_version: 1.8.19
244
+ rubygems_version: 1.8.18
218
245
  signing_key:
219
246
  specification_version: 3
220
- summary: Kronk runs diffs against data from live and cached http responses
247
+ summary: Kronk is a command line swiss-army-knife for HTTP services
221
248
  test_files:
222
249
  - test/test_assertions.rb
223
250
  - test/test_cmd.rb
224
- - test/test_core_ext.rb
225
251
  - test/test_data_string.rb
226
252
  - test/test_diff.rb
227
253
  - test/test_helper.rb
228
254
  - test/test_helper_methods.rb
229
255
  - test/test_input_reader.rb
230
256
  - test/test_kronk.rb
231
- - test/test_path.rb
232
- - test/test_path_match.rb
233
- - test/test_path_matcher.rb
234
257
  - test/test_player.rb
235
258
  - test/test_request.rb
236
259
  - test/test_request_parser.rb
237
260
  - test/test_response.rb
238
- - test/test_transaction.rb
239
261
  - test/test_xml_parser.rb