stella 0.6.0 → 0.7.0.002

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.
Files changed (55) hide show
  1. data/CHANGES.txt +7 -15
  2. data/LICENSE.txt +1 -1
  3. data/README.rdoc +93 -63
  4. data/Rakefile +32 -42
  5. data/bin/stella +138 -0
  6. data/examples/basic/listing_ids.csv +7 -0
  7. data/examples/basic/plan.rb +71 -0
  8. data/lib/stella/cli.rb +66 -0
  9. data/lib/stella/client.rb +199 -0
  10. data/lib/stella/config.rb +87 -0
  11. data/lib/stella/data/http/body.rb +15 -0
  12. data/lib/stella/data/http/request.rb +116 -0
  13. data/lib/stella/data/http/response.rb +92 -0
  14. data/lib/stella/data/http.rb +2 -257
  15. data/lib/stella/data.rb +85 -0
  16. data/lib/stella/dsl.rb +5 -0
  17. data/lib/stella/engine/functional.rb +39 -0
  18. data/lib/stella/engine/load.rb +106 -0
  19. data/lib/stella/engine.rb +55 -0
  20. data/lib/stella/exceptions.rb +15 -0
  21. data/lib/stella/guidelines.rb +18 -0
  22. data/lib/stella/mixins.rb +2 -0
  23. data/lib/stella/stats.rb +3 -7
  24. data/lib/stella/testplan/stats.rb +26 -0
  25. data/lib/stella/testplan/usecase.rb +67 -0
  26. data/lib/stella/testplan.rb +95 -220
  27. data/lib/{util → stella/utils}/httputil.rb +0 -0
  28. data/lib/stella/utils.rb +126 -0
  29. data/lib/stella/version.rb +15 -0
  30. data/lib/stella.rb +58 -104
  31. data/lib/threadify.rb +0 -6
  32. data/stella.gemspec +43 -49
  33. data/support/example_webapp.rb +246 -0
  34. data/support/useragents.txt +75 -0
  35. metadata +68 -32
  36. data/bin/example_test.rb +0 -82
  37. data/bin/example_webapp.rb +0 -63
  38. data/lib/logger.rb +0 -79
  39. data/lib/stella/clients.rb +0 -161
  40. data/lib/stella/command/base.rb +0 -20
  41. data/lib/stella/command/form.rb +0 -36
  42. data/lib/stella/command/get.rb +0 -44
  43. data/lib/stella/common.rb +0 -53
  44. data/lib/stella/crypto.rb +0 -88
  45. data/lib/stella/data/domain.rb +0 -82
  46. data/lib/stella/environment.rb +0 -66
  47. data/lib/stella/functest.rb +0 -105
  48. data/lib/stella/loadtest.rb +0 -186
  49. data/lib/stella/testrunner.rb +0 -64
  50. data/lib/storable.rb +0 -280
  51. data/lib/timeunits.rb +0 -65
  52. data/tryouts/drb/drb_test.rb +0 -65
  53. data/tryouts/drb/open4.rb +0 -19
  54. data/tryouts/drb/slave.rb +0 -27
  55. data/tryouts/oo_tryout.rb +0 -30
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stella
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0.002
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,9 +9,39 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-16 00:00:00 -04:00
12
+ date: 2009-09-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: drydock
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.6.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: gibbler
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.2
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: storable
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.5.7
44
+ version:
15
45
  - !ruby/object:Gem::Dependency
16
46
  name: httpclient
17
47
  type: :runtime
@@ -20,56 +50,62 @@ dependencies:
20
50
  requirements:
21
51
  - - ">="
22
52
  - !ruby/object:Gem::Version
23
- version: "0"
53
+ version: 2.1.5
24
54
  version:
25
- description: Your friend in performance testing
55
+ description: "Stella: Your friend in performance testing."
26
56
  email: delano@solutious.com
27
- executables: []
28
-
57
+ executables:
58
+ - stella
29
59
  extensions: []
30
60
 
31
61
  extra_rdoc_files:
32
62
  - README.rdoc
33
63
  - LICENSE.txt
64
+ - CHANGES.txt
34
65
  files:
35
66
  - CHANGES.txt
36
67
  - LICENSE.txt
37
68
  - README.rdoc
38
69
  - Rakefile
39
- - bin/example_test.rb
40
- - bin/example_webapp.rb
41
- - lib/logger.rb
70
+ - bin/stella
71
+ - examples/basic/listing_ids.csv
72
+ - examples/basic/plan.rb
42
73
  - lib/stella.rb
43
- - lib/stella/clients.rb
44
- - lib/stella/command/base.rb
45
- - lib/stella/command/form.rb
46
- - lib/stella/command/get.rb
47
- - lib/stella/common.rb
48
- - lib/stella/crypto.rb
49
- - lib/stella/data/domain.rb
74
+ - lib/stella/cli.rb
75
+ - lib/stella/client.rb
76
+ - lib/stella/config.rb
77
+ - lib/stella/data.rb
50
78
  - lib/stella/data/http.rb
51
- - lib/stella/environment.rb
52
- - lib/stella/functest.rb
53
- - lib/stella/loadtest.rb
79
+ - lib/stella/data/http/body.rb
80
+ - lib/stella/data/http/request.rb
81
+ - lib/stella/data/http/response.rb
82
+ - lib/stella/dsl.rb
83
+ - lib/stella/engine.rb
84
+ - lib/stella/engine/functional.rb
85
+ - lib/stella/engine/load.rb
86
+ - lib/stella/exceptions.rb
87
+ - lib/stella/guidelines.rb
88
+ - lib/stella/mixins.rb
54
89
  - lib/stella/stats.rb
55
90
  - lib/stella/testplan.rb
56
- - lib/stella/testrunner.rb
57
- - lib/storable.rb
91
+ - lib/stella/testplan/stats.rb
92
+ - lib/stella/testplan/usecase.rb
93
+ - lib/stella/utils.rb
94
+ - lib/stella/utils/httputil.rb
95
+ - lib/stella/version.rb
58
96
  - lib/threadify.rb
59
- - lib/timeunits.rb
60
- - lib/util/httputil.rb
61
97
  - stella.gemspec
62
- - tryouts/drb/drb_test.rb
63
- - tryouts/drb/open4.rb
64
- - tryouts/drb/slave.rb
65
- - tryouts/oo_tryout.rb
98
+ - support/example_webapp.rb
99
+ - support/useragents.txt
66
100
  has_rdoc: true
67
- homepage: http://github.com/solutious/stella
101
+ homepage: http://solutious.com/projects/stella/
102
+ licenses: []
103
+
68
104
  post_install_message:
69
105
  rdoc_options:
70
106
  - --line-numbers
71
107
  - --title
72
- - Your friend in performance testing
108
+ - "Stella: Your friend in performance testing."
73
109
  - --main
74
110
  - README.rdoc
75
111
  require_paths:
@@ -89,9 +125,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
125
  requirements: []
90
126
 
91
127
  rubyforge_project: stella
92
- rubygems_version: 1.3.1
128
+ rubygems_version: 1.3.2
93
129
  signing_key:
94
- specification_version: 2
95
- summary: Your friend in performance testing
130
+ specification_version: 3
131
+ summary: "Stella: Your friend in performance testing."
96
132
  test_files: []
97
133
 
data/bin/example_test.rb DELETED
@@ -1,82 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # Stella Test DSL - Example 1: Multiple requests, with response data
4
- #
5
- # To run the example test, do the following:
6
- #
7
- # * run bin/example_webapp.rb in an other terminal window. This provides
8
- # an HTTP server for this script to run against.
9
- #
10
- # * run bin/example_test.rb and watch the output!
11
- #
12
- #
13
-
14
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) # Put the local lib first in line
15
-
16
- require 'stella'
17
- require 'yaml'
18
-
19
- include Stella::DSL
20
-
21
- testplan :dsl_example1 do
22
- desc "A basic demonstration of the testplan DSL"
23
- protocol :http
24
- # auth :basic, "stella", "stella"
25
-
26
- post "/upload" do
27
- name "Add Product"
28
- body "bill", "/path/2/file.txt"
29
- header "X-Stella" => "Version #{Stella::VERSION}"
30
- param :convert => true
31
- param :rand => rand
32
-
33
- response 200, 201 do |headers, body|
34
- data = YAML.load(body)
35
- @product_id = data[:id] # Store the response value
36
- end
37
- end
38
-
39
- get "/product" do
40
- name "View Product"
41
- param 'id' => @product_id # Use the value from the previous request
42
-
43
- response 200 do |header, body|
44
- data = YAML.load(body)
45
- #repeat :times => 2, :wait => 1 # Repeat this request
46
- end
47
- end
48
-
49
- get "/product/22" do
50
- name "Product 22"
51
- response 200 do |header, body|
52
- data = YAML.load(body)
53
- end
54
- end
55
-
56
- end
57
-
58
- # Environments
59
- #
60
- # Stella can execute the same test plan on different environments.
61
- # You can specify several environment blocks by giving them unique
62
- # names. Each environment can contain any number of machines.
63
- environment :development do
64
- machines "localhost:3114"
65
- # machine "localhost:3115"
66
- # ...
67
- end
68
-
69
- # Functional Test
70
- #
71
- # A functional test executes the test plan with a single client. It
72
- # produces more output than a load test which can be used to verify
73
- # both that the test plan was written correctly and that the server
74
- # is responding as expected for each request.
75
- functest :integration do
76
- plan :dsl_example1
77
- verbose 2
78
- end
79
-
80
-
81
- run :development, :integration # Run functional test
82
-
@@ -1,63 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # Use Ruby 1.8
4
-
5
- require "rubygems"
6
- require "rack"
7
- require "sinatra"
8
-
9
- require 'yaml'
10
-
11
- set :run => true
12
- set :environment => :development
13
- set :raise_errors => true
14
- set :port => 3114
15
-
16
- #log = File.new("/dev/null", "a")
17
- #STDOUT.reopen(log)
18
- #STDERR.reopen(log)
19
-
20
-
21
- #use Rack::Auth::Basic do |username, password|
22
- # username == 'stella' && password == 'stella'
23
- #end
24
-
25
- #
26
- # Generates a string of random alphanumeric characters
27
- # These are used as IDs throughout the system
28
- def strand( len )
29
- chars = ("a".."z").to_a + ("0".."9").to_a
30
- newpass = ""
31
- 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
32
- return newpass
33
- end
34
-
35
- get '/' do
36
- redirect '/product'
37
- end
38
-
39
- get '/product' do
40
- content_type "text/plain"
41
- product = {
42
- :id => (params[:id] || 0).to_s,
43
- :name => "John West Smoked Oysters"
44
- }.to_yaml
45
- end
46
-
47
- get '/product/:id' do
48
- content_type "text/plain"
49
- product = {
50
- :id => params[:id].to_i,
51
- :name => "John West Smoked Oysters"
52
- }.to_yaml
53
- end
54
-
55
- post '/upload' do
56
- content_type "text/plain"
57
- product = {
58
- :id => strand(3),
59
- :name => "John West Smoked Oysters",
60
- :convert => params[:convert] || false,
61
- :rand => params[:rand]
62
- }.to_yaml
63
- end
data/lib/logger.rb DELETED
@@ -1,79 +0,0 @@
1
-
2
-
3
- module Stella
4
- class Logger
5
- attr_accessor :debug_level
6
-
7
- # +args+ is a hash of initialization arguments
8
- # * <tt>:info_logger</tt> The IO class for info level logging. Default: STDOUT
9
- # * <tt>:error_logger</tt> The IO class for error level logging. Default: STDERR
10
- # * <tt>:debug_logger</tt> The IO class for error level logging. Default: STDERR
11
- # * <tt>:debug_level</tt> An integer from 0 to 4 which determines the amount of debugging output. Default: 0.
12
- def initialize(args={})
13
- @debug_level = args[:debug_level] || false
14
- @info_logger = args[:info_logger]
15
- @error_logger = args[:error_logger]
16
- @debug_logger = args[:debug_logger]
17
- end
18
-
19
- # +msgs+ is an array which can contain a list of messages or a symbol and a list of values
20
- # If the first element is a symbol, this will return the output of Stella::Text.msg(msgs[0],msgs[1..-1])
21
- def info(*msgs)
22
- return if !msgs || msgs.empty?
23
- msgs.each do |m|
24
- info_logger.puts m
25
- end
26
- info_logger.flush
27
- end
28
-
29
- def info_logger
30
- @info_logger || $stdout
31
- end
32
- def debug_logger
33
- @debug_logger || $stderr
34
- end
35
- def error_logger
36
- @error_logger || $stderr
37
- end
38
-
39
- def flush
40
- info_logger.flush
41
- error_logger.flush
42
- debug_logger.flush
43
- end
44
-
45
- # Print all messages on a single line.
46
- def info_print(*msgs)
47
- msgs.each do |m|
48
- info_logger.print m
49
- end
50
- info_logger.flush
51
- end
52
-
53
- # Print all messages on a single line.
54
- def info_printf(pattern, *vals)
55
- info_logger.printf(pattern, *vals)
56
- info_logger.flush
57
- end
58
-
59
- def debug(*msgs)
60
- return unless @debug_level
61
- msgs.each do |m|
62
- debug_logger.puts "DEBUG: #{m}"
63
- end
64
- debug_logger.flush
65
- end
66
- def warn(ex, prefix="WARN: ")
67
- error(ex, prefix)
68
- end
69
-
70
- def error(ex, prefix="ERR: ")
71
- msg = (ex.kind_of? String) ? ex : ex.message
72
- error_logger.puts "#{prefix}#{msg}"
73
- return unless @debug_level > 0 && ex.kind_of?(Exception)
74
- error_logger.puts("#{prefix}------------------------------------------")
75
- error_logger.puts("#{prefix}#{ex.backtrace.join("\n")}")
76
- error_logger.puts("#{prefix}------------------------------------------")
77
- end
78
- end
79
- end
@@ -1,161 +0,0 @@
1
-
2
- require "observer"
3
- require "tempfile"
4
-
5
-
6
- module Stella
7
- class Client
8
- include Observable
9
-
10
- @@IDS = {}
11
-
12
- attr_reader :request_stats
13
- attr_accessor :client_id
14
- def initialize(client_id=1)
15
- @client_id = client_id
16
- @request_stats = {
17
- }
18
- end
19
-
20
- def execute_testplan(request_stats, http_client, machine, namespace, plan, verbose=1)
21
- changed
22
- notify_observers(:start, machine, plan.name)
23
-
24
- if plan.auth
25
- auth_domain = "#{plan.protocol}://#{machine.to_s}/"
26
- http_client.set_auth(auth_domain, plan.auth.user, plan.auth.pass)
27
- changed
28
- notify_observers(:authorized, auth_domain, plan.auth.user, plan.auth.pass)
29
- end
30
-
31
- tf = Tempfile.new('stella-cookie')
32
- http_client.set_cookie_store(tf.to_s)
33
-
34
- request_methods = namespace.methods.select { |meth| meth =~ /\d+\s[A-Z]/ }
35
-
36
- retry_count = 1
37
- previous_methname = nil
38
- request_methods.each do |methname|
39
- retry_count = 1 unless previous_methname == methname
40
- previous_methname = methname
41
-
42
- # We need to define the request only the first time it's run.
43
- req = namespace.send(methname) unless retry_count > 1
44
- req.set_unique_id(self.object_id)
45
-
46
- request_stats[req.stella_id.to_sym] ||= {
47
- :name => req.name,
48
- :stats => Stats.new( req.name )
49
- }
50
-
51
- uri = req.uri.is_a?(URI) ? req.uri : URI.parse(req.uri.to_s)
52
- uri.scheme ||= plan.protocol
53
- uri.host ||= machine.host
54
- uri.port ||= machine.port
55
-
56
- query = {}.merge!(req.params)
57
-
58
-
59
-
60
- begin
61
-
62
- if req.http_method =~ /POST|PUT/
63
-
64
- if req.body.has_content?
65
- body = req.body.content
66
- param = req.body.form_param || 'file' # How do we handle bodies with no form name?
67
- query[param] = body # NOTE: HTTPClient prefers a file handle rather than reading in the file
68
- end
69
-
70
- end
71
-
72
- # Make the request.
73
- time_started = Time.now
74
- res = http_client.send(req.http_method.downcase, uri.to_s, query)
75
- request_stats[req.stella_id.to_sym][:stats].sample(Time.now - time_started)
76
-
77
- id1 = (query || {})['id']
78
- id2 = YAML.load(res.body.content || '')[:id]
79
- if id1
80
- #puts "#{id1} (#{req.unique_id}): #{@@IDS[id1].join(', ')}" if @@IDS.has_key?(id1) && @@IDS[id1].size > 1
81
- @@IDS[id1] ||= []
82
- @@IDS[id1] << @client_id
83
- @@IDS[id1].uniq!
84
- end
85
-
86
- rescue => ex
87
- changed
88
- notify_observers(:request_exception, req.http_method, uri, query, ex)
89
- next
90
- end
91
-
92
-
93
- response_headers = res.header.all.stella_to_hash
94
-
95
-
96
-
97
- unless req.response_handler.has_key?(res.status)
98
- changed
99
- notify_observers(:request_unexpected_response, req.http_method, uri, query, res.status, response_headers, res.body.content)
100
- else
101
-
102
- changed
103
- notify_observers(:request, req.http_method, uri, query, res.status, response_headers, res.body.content)
104
-
105
- response_handler_ret = req.response_handler[res.status].call(response_headers, res.body.content, @client_id, req.unique_id)
106
-
107
- if response_handler_ret.is_a?(Stella::TestPlan::ResponseHandler) && response_handler_ret.action == :repeat
108
- retry_count ||= 1
109
-
110
- if retry_count > response_handler_ret.times
111
- retry_count = 1
112
- next
113
- else
114
- changed
115
- notify_observers(:retrying, uri, retry_count, response_handler_ret.times)
116
- run_sleeper(response_handler_ret.wait)
117
- retry_count += 1
118
- redo
119
- end
120
- end
121
- end
122
-
123
- end
124
-
125
- http_client.save_cookie_store
126
- changed
127
- notify_observers(:done)
128
-
129
- end
130
-
131
- def run_sleeper(duration, quiet=true)
132
- remainder = duration % 1
133
- duration.to_i.times {
134
- print '.' unless duration <= 1 || quiet
135
- sleep 1
136
- }
137
- sleep remainder if remainder > 0
138
- end
139
- end
140
- end
141
-
142
- #module Stella
143
- # class Clients
144
- #
145
- # # The default authentication, a Stella::Common::Auth object
146
- # attr_accessor :auth
147
- #
148
- # end
149
- #end
150
-
151
- #module Stella
152
- # module DSL
153
- # module Clients
154
- #
155
- # def clients(name = :anonymous, &define)
156
- # @stella_clients ||= {}
157
- # @stella_clients[name] = []
158
- # end
159
- # end
160
- # end
161
- #end
@@ -1,20 +0,0 @@
1
-
2
-
3
- module Stella::Command
4
- module Base
5
-
6
-
7
- def run
8
- raise "Override 'run'"
9
- end
10
-
11
- def run_sleeper(duration)
12
- remainder = duration % 1
13
- duration.to_i.times {
14
- Stella::LOGGER.info_print('.') unless @quiet
15
- sleep 1
16
- }
17
- sleep remainder if remainder > 0
18
- end
19
- end
20
- end
@@ -1,36 +0,0 @@
1
-
2
- require 'httpclient'
3
-
4
- require 'util/httputil'
5
-
6
- require 'stella/command/base'
7
- require 'stella/data/http'
8
-
9
-
10
- module Stella::Command #:nodoc: all
11
- class Form < Drydock::Command #:nodoc: all
12
- include Stella::Command::Base
13
-
14
-
15
-
16
- end
17
- end
18
-
19
-
20
-
21
-
22
- __END__
23
-
24
- headers = { 'Content-Type' => 'text/xml' }
25
-
26
- @client = HTTPClient.new('http://localhost:3114')
27
- @url = URI.parse "http://solutious.com/"
28
- #@url = URI.parse 'https://delaagsterekening.nl/api/suggestions/status.json?token=253'
29
- #@client.set_auth("https://delaagsterekening.nl/", "stella", "stella")
30
- @client.set_cookie_store("/tmp/cookie.dat")
31
- body, resp = @client.get @url, headers
32
- body.header.all.each do |h|
33
- puts "#{h[0]}: #{h[1]}"
34
- end
35
- #puts @client
36
- @client.save_cookie_store
@@ -1,44 +0,0 @@
1
-
2
- require 'httpclient'
3
-
4
- require 'util/httputil'
5
-
6
- require 'stella/command/base'
7
- require 'stella/data/http'
8
-
9
- # NOTE: Not working
10
-
11
- #
12
- #
13
- module Stella::Command #:nodoc: all
14
- class Get < Drydock::Command #:nodoc: all
15
- include Stella::Command::Base
16
-
17
- attr_accessor :raw
18
- attr_accessor :uri
19
- attr_accessor :proxy
20
-
21
- def run
22
- @req ||= req
23
- raise "No request defined" unless @req
24
-
25
- c = (@proxy) ? HTTPClient.new(@proxy) : HTTPClient.new
26
- c.get @req.uri, @req.headers
27
- end
28
-
29
- def read_raw
30
- Stella.info("Enter the raw GET request:")
31
- @raw = gets
32
- while raw !~ /^#{$/}$/
33
- val = gets
34
- @raw << val if val
35
- end
36
- @raw
37
- end
38
-
39
- def req
40
-
41
- end
42
-
43
- end
44
- end
data/lib/stella/common.rb DELETED
@@ -1,53 +0,0 @@
1
-
2
-
3
- module Stella
4
- module Common
5
- class Auth
6
- attr_accessor :type
7
- attr_accessor :user
8
- attr_accessor :pass
9
- attr_accessor :port
10
- def initialize(type, user, pass=nil, port=nil)
11
- @uri = type
12
- @user = user
13
- @pass = pass if pass
14
- @port = port if port
15
- end
16
- end
17
- class Proxy
18
- attr_accessor :uri
19
- attr_accessor :user
20
- attr_accessor :pass
21
- def initialize(uri, user=nil, pass=nil)
22
- @uri = uri
23
- @user = user if user
24
- @pass = pass if pass
25
- end
26
- end
27
- class Machine
28
- attr_accessor :host
29
- attr_accessor :port
30
- attr_accessor :role
31
- attr_accessor :ssh
32
-
33
- def initialize(*args)
34
- raise "You must at least a hostname or IP address" if args.empty?
35
- if args.first.is_a? String
36
- @host, @port = args.first.split(":")
37
- else
38
- @host, @port, @role = args.flatten
39
- end
40
- @role ||= "app"
41
- @port = @port.to_i if @port
42
- end
43
- def to_s
44
- str = "#{@host}"
45
- str << ":#{@port}" if @port
46
- str
47
- end
48
- end
49
- end
50
- end
51
-
52
-
53
-