stella 2.1.1.002 → 2.1.2.001

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,5 +1,14 @@
1
1
  STELLA, CHANGES
2
2
 
3
+ #### 2.1.2 (2011-07-06) ###############################
4
+
5
+ * FIXED: Stella::Report#postprocess loads log from a hash.
6
+ * ADDED: Wait only up to 35 seconds for a remote checkup
7
+ * CHANGE: Move stella/api.rb content to stella.rb
8
+ * CHANGE: CLI output
9
+ * CHANGE: Removed Stella::Template and require 'erb'
10
+
11
+
3
12
  #### 2.1.1 (2011-07-06) ###############################
4
13
 
5
14
  * ADDED: Append more info URI to CLI output for remote checkups
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  :MAJOR: 2
2
2
  :MINOR: 1
3
- :PATCH: 1
4
- :BUILD: '002'
3
+ :PATCH: 2
4
+ :BUILD: '001'
data/bin/stella CHANGED
@@ -39,6 +39,7 @@ class Stella::CLI::Definition
39
39
  global :D, :debug, "Enable debug mode" do
40
40
  Drydock.debug true
41
41
  Stella.debug = true
42
+ Stella::API.debug_output $stdout
42
43
  end
43
44
  global :P, :pause, Integer, "Seconds to wait before starting test"
44
45
  #global :H, :withheader, "Include X-Stella-ID request header"
data/lib/stella.rb CHANGED
@@ -14,7 +14,7 @@ $:.unshift STELLA_LIB_HOME
14
14
  end
15
15
 
16
16
  require 'yajl'
17
- require 'erb'
17
+ require 'httparty'
18
18
  require 'storable'
19
19
  require 'benelux'
20
20
  require 'gibbler/aliases'
@@ -40,20 +40,6 @@ class Stella
40
40
  end
41
41
  end
42
42
 
43
- class MatchData
44
- include Gibbler::String
45
- end
46
-
47
- module Addressable
48
- class URI
49
- include Gibbler::String
50
- end
51
- end
52
-
53
- class OpenStruct
54
- include Gibbler::Object
55
- end
56
-
57
43
  #
58
44
  # Any object that wants to be serialized to JSON
59
45
  # ought to inherit from this class.
@@ -217,20 +203,73 @@ class Stella
217
203
  end
218
204
  end
219
205
 
220
- class Stella::Template
221
- include Gibbler::String
222
- attr_reader :src
223
- def initialize(src)
224
- src = src.to_s
225
- @src, @template = src, ERB.new(src)
226
- end
227
- def result(binding)
228
- @template.result(binding)
229
- end
230
- def self.from_file(path)
231
- new File.read(path)
206
+ class Stella
207
+ class API
208
+ include HTTParty
209
+ ssl_ca_file Stella::Client::SSL_CERT_PATH
210
+ format :json
211
+ attr_reader :httparty_opts, :response, :account, :key
212
+ def initialize account=nil, key=nil, httparty_opts={}
213
+ self.class.base_uri ENV['STELLA_HOST'] || 'https://www.blamestella.com/api/v2'
214
+ @httparty_opts = httparty_opts
215
+ @account = account || ENV['STELLA_ACCOUNT']
216
+ @key = key || ENV['STELLA_KEY']
217
+ unless @account.to_s.empty? || @key.to_s.empty?
218
+ httparty_opts[:basic_auth] ||= { :username => @account, :password => @key }
219
+ end
220
+ end
221
+ def get path, params=nil
222
+ opts = httparty_opts
223
+ opts[:query] = params || {}
224
+ execute_request :get, path, opts
225
+ end
226
+ def post path, params=nil
227
+ opts = httparty_opts
228
+ opts[:body] = params || {}
229
+ execute_request :post, path, opts
230
+ end
231
+ def site_uri path
232
+ uri = Addressable::URI.parse self.class.base_uri
233
+ uri.path = uri_path(path)
234
+ uri.to_s
235
+ end
236
+ private
237
+ def uri_path *args
238
+ args.unshift '' # force leading slash
239
+ path = args.flatten.join('/')
240
+ path.gsub '//', '/'
241
+ end
242
+ def execute_request meth, path, opts
243
+ path = uri_path [path]
244
+ @response = self.class.send meth, path, opts
245
+ indifferent_params @response.parsed_response
246
+ end
247
+ # Enable string or symbol key access to the nested params hash.
248
+ def indifferent_params(params)
249
+ if params.is_a?(Hash)
250
+ params = indifferent_hash.merge(params)
251
+ params.each do |key, value|
252
+ next unless value.is_a?(Hash) || value.is_a?(Array)
253
+ params[key] = indifferent_params(value)
254
+ end
255
+ elsif params.is_a?(Array)
256
+ params.collect! do |value|
257
+ if value.is_a?(Hash) || value.is_a?(Array)
258
+ indifferent_params(value)
259
+ else
260
+ value
261
+ end
262
+ end
263
+ end
264
+ end
265
+ # Creates a Hash with indifferent access.
266
+ def indifferent_hash
267
+ Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
268
+ end
269
+
270
+ class Unauthorized < RuntimeError
271
+ end
232
272
  end
233
- def to_s() src end
234
273
  end
235
274
 
236
275
 
data/lib/stella/cli.rb CHANGED
@@ -13,7 +13,6 @@ class Stella::CLI < Drydock::Command
13
13
 
14
14
 
15
15
  def checkup
16
- require 'stella/api'
17
16
  base_uri = Stella.canonical_uri(@argv.first)
18
17
  run_opts = {
19
18
  :repetitions => @option.repetitions || 1,
@@ -42,11 +41,15 @@ class Stella::CLI < Drydock::Command
42
41
  STDERR.puts ret[:msg]
43
42
  @exit_code = 1 and return
44
43
  end
44
+ count = 0
45
45
  begin
46
46
  run_hash = @api.get "/checkup/#{ret[:runid]}"
47
47
  @run = Stella::Testrun.from_hash run_hash if run_hash
48
+ STDERR.print '.' if @global.verbose > 0
48
49
  sleep 1 if @run && !@run.done?
49
- end while @run && !@run.done?
50
+ count += 1
51
+ end while @run && !@run.done? && count < 35
52
+ raise "Sorry, that took too long" if count >= 35
50
53
  else
51
54
  if @global.testplan
52
55
  unless File.owned?(@global.testplan)
@@ -83,8 +86,16 @@ class Stella::CLI < Drydock::Command
83
86
  when 'json', 'yaml'
84
87
  puts @run.dump(@global.format)
85
88
  else
89
+ if @global.verbose > 0 || @report.errors?
90
+ test_uri = @report.log.first ? @report.log.first.uri : '[unknown]'
91
+ Stella.li 'Checkup for %s' % [test_uri]
92
+ Stella.li
93
+ Stella.li ' %s' % [@report.headers.request_headers.split(/\n/).join("\n ")]
94
+ Stella.li
95
+ Stella.li ' %s' % [@report.headers.response_headers.split(/\n/).join("\n ")]
96
+ Stella.li ''
97
+ end
86
98
  metrics = @report.metrics
87
- # @run.planid.shorten(12), @run.runid.shorten(12),
88
99
  args = [@report.statuses.values.first,
89
100
  metrics.response_time.mean*1000,
90
101
  metrics.socket_connect.mean*1000,
@@ -92,23 +103,19 @@ class Stella::CLI < Drydock::Command
92
103
  metrics.last_byte.mean*1000,
93
104
  @more_info]
94
105
  Stella.li "[%3s] %7.2fms (%5.2fms + %6.2fms + %6.2fms) %s" % args
95
- if @global.verbose > 0 || @report.errors?
96
- Stella.li ''
97
- Stella.li ' Headers:'
98
- Stella.li ' %s' % [@report.headers.request_headers.split(/\n/).join("\n ")]
99
- Stella.li
100
- Stella.li ' %s' % [@report.headers.response_headers.split(/\n/).join("\n ")]
101
- end
102
- #puts @report.metrics_pack.dump(:json)
103
106
  end
104
107
  end
105
108
  rescue Stella::API::Unauthorized => ex
106
- STDERR.puts "Create an account, at no charge! https://www.blamestella.com/signup/free"
107
- STDERR.puts "Then specify your credentials:"
108
- STDERR.puts " export STELLA_ACCOUNT=youraccount"
109
- STDERR.puts " export STELLA_KEY=yourapikey"
109
+ accnt = @api.account || 'youraccount'
110
+ key = @api.key || 'yourapikey'
111
+ STDERR.puts "Specify your credentials"
112
+ STDERR.puts " export STELLA_ACCOUNT=#{accnt}"
113
+ STDERR.puts " export STELLA_KEY=#{key}"
110
114
  STDERR.puts " OR "
111
- STDERR.puts " stella -A youraccount -K yourapikey checkup #{@argv.first}"
115
+ STDERR.puts " stella -A #{accnt} -K #{key} checkup #{@argv.first}"
116
+ STDERR.puts
117
+ STDERR.puts "Create an account, at no charge!"
118
+ STDERR.puts "https://www.blamestella.com/signup/free"
112
119
  end
113
120
 
114
121
  def example
@@ -2,6 +2,20 @@
2
2
 
3
3
  $KCODE = "u" if RUBY_VERSION =~ /^1.8/
4
4
 
5
+ class MatchData
6
+ include Gibbler::String
7
+ end
8
+
9
+ module Addressable
10
+ class URI
11
+ include Gibbler::String
12
+ end
13
+ end
14
+
15
+ class OpenStruct
16
+ include Gibbler::Object
17
+ end
18
+
5
19
 
6
20
  # A hash with indifferent access and magic predicates.
7
21
  #
data/lib/stella/report.rb CHANGED
@@ -374,6 +374,9 @@ class Stella
374
374
  val = klass.from_hash(self.send(name))
375
375
  self.send("#{name}=", val)
376
376
  end
377
+ # When we load a report from a hash, some plugin
378
+ # attributes need to be recontituted from a hash as well.
379
+ (self.content.log || []).collect! { |v| Stella::Log::HTTP.from_hash(v) }
377
380
  end
378
381
  def process
379
382
  self.class.plugin_order.each do |name|
data/stella.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{stella}
8
- s.version = "2.1.1.002"
8
+ s.version = "2.1.2.001"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Delano Mandelbaum"]
@@ -41,7 +41,6 @@ Gem::Specification.new do |s|
41
41
  "certs/startssl-sub.class1.server.ca.pem",
42
42
  "certs/stella-master.crt",
43
43
  "lib/stella.rb",
44
- "lib/stella/api.rb",
45
44
  "lib/stella/cli.rb",
46
45
  "lib/stella/client.rb",
47
46
  "lib/stella/core_ext.rb",
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stella
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.1.002
5
+ version: 2.1.2.001
6
6
  platform: ruby
7
7
  authors:
8
8
  - Delano Mandelbaum
@@ -144,7 +144,6 @@ files:
144
144
  - certs/startssl-sub.class1.server.ca.pem
145
145
  - certs/stella-master.crt
146
146
  - lib/stella.rb
147
- - lib/stella/api.rb
148
147
  - lib/stella/cli.rb
149
148
  - lib/stella/client.rb
150
149
  - lib/stella/core_ext.rb
data/lib/stella/api.rb DELETED
@@ -1,75 +0,0 @@
1
- require 'httparty'
2
- require 'stella'
3
-
4
- class Stella
5
- class API
6
- include HTTParty
7
- ssl_ca_file Stella::Client::SSL_CERT_PATH
8
- format :json
9
- attr_reader :httparty_opts, :response
10
- def initialize account=nil, key=nil, httparty_opts={}
11
- self.class.base_uri ENV['STELLA_HOST'] || 'https://www.blamestella.com/api/v2'
12
- @httparty_opts = httparty_opts
13
- account ||= ENV['STELLA_ACCOUNT']
14
- key ||= ENV['STELLA_KEY']
15
- unless account.to_s.empty? || key.to_s.empty?
16
- @httparty_opts[:basic_auth] ||= { :username => account, :password => key }
17
- end
18
- end
19
- def get path, params=nil
20
- opts = httparty_opts
21
- opts[:query] = params || {}
22
- execute_request :get, path, opts
23
- end
24
- def post path, params=nil
25
- opts = httparty_opts
26
- opts[:body] = params || {}
27
- execute_request :post, path, opts
28
- end
29
- def site_uri path
30
- uri = Addressable::URI.parse self.class.base_uri
31
- uri.path = uri_path(path)
32
- uri.to_s
33
- end
34
- private
35
- def uri_path *args
36
- args.unshift '' # force leading slash
37
- path = args.flatten.join('/')
38
- path.gsub '//', '/'
39
- end
40
- def execute_request meth, path, opts
41
- path = uri_path [path]
42
- @response = self.class.send meth, path, opts
43
- indifferent_params @response.parsed_response
44
- end
45
- # Enable string or symbol key access to the nested params hash.
46
- def indifferent_params(params)
47
- if params.is_a?(Hash)
48
- params = indifferent_hash.merge(params)
49
- params.each do |key, value|
50
- next unless value.is_a?(Hash) || value.is_a?(Array)
51
- params[key] = indifferent_params(value)
52
- end
53
- elsif params.is_a?(Array)
54
- params.collect! do |value|
55
- if value.is_a?(Hash) || value.is_a?(Array)
56
- indifferent_params(value)
57
- else
58
- value
59
- end
60
- end
61
- end
62
- end
63
- # Creates a Hash with indifferent access.
64
- def indifferent_hash
65
- Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
66
- end
67
-
68
- class Unauthorized < RuntimeError
69
- end
70
- end
71
- end
72
-
73
- #Stella::API.debug_output $stdout
74
- #Stella::API.base_uri 'http://localhost:3000/api/v2'
75
- #@api = Stella::API.new