solutious-stella 0.5.5 → 0.6.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.
Files changed (83) hide show
  1. data/CHANGES.txt +39 -2
  2. data/LICENSE.txt +19 -0
  3. data/README.rdoc +85 -0
  4. data/Rakefile +54 -59
  5. data/bin/example_test.rb +82 -0
  6. data/bin/example_webapp.rb +63 -0
  7. data/lib/{stella/logger.rb → logger.rb} +6 -11
  8. data/lib/stella.rb +76 -58
  9. data/lib/stella/clients.rb +161 -0
  10. data/lib/stella/command/base.rb +4 -24
  11. data/lib/stella/command/form.rb +36 -0
  12. data/lib/stella/command/get.rb +44 -0
  13. data/lib/stella/common.rb +53 -0
  14. data/lib/stella/crypto.rb +88 -0
  15. data/lib/stella/data/domain.rb +2 -2
  16. data/lib/stella/data/http.rb +164 -36
  17. data/lib/stella/environment.rb +66 -0
  18. data/lib/stella/functest.rb +105 -0
  19. data/lib/stella/loadtest.rb +186 -0
  20. data/lib/{utils → stella}/stats.rb +16 -20
  21. data/lib/stella/testplan.rb +237 -0
  22. data/lib/stella/testrunner.rb +64 -0
  23. data/lib/storable.rb +280 -0
  24. data/lib/threadify.rb +171 -0
  25. data/lib/timeunits.rb +65 -0
  26. data/lib/util/httputil.rb +266 -0
  27. data/stella.gemspec +69 -0
  28. data/tryouts/drb/drb_test.rb +65 -0
  29. data/tryouts/drb/open4.rb +19 -0
  30. data/tryouts/drb/slave.rb +27 -0
  31. data/tryouts/oo_tryout.rb +30 -0
  32. metadata +39 -107
  33. data/README.textile +0 -162
  34. data/bin/stella +0 -12
  35. data/bin/stella.bat +0 -12
  36. data/lib/daemonize.rb +0 -56
  37. data/lib/pcaplet.rb +0 -180
  38. data/lib/stella/adapter/ab.rb +0 -337
  39. data/lib/stella/adapter/base.rb +0 -106
  40. data/lib/stella/adapter/httperf.rb +0 -305
  41. data/lib/stella/adapter/pcap_watcher.rb +0 -221
  42. data/lib/stella/adapter/proxy_watcher.rb +0 -76
  43. data/lib/stella/adapter/siege.rb +0 -341
  44. data/lib/stella/cli.rb +0 -258
  45. data/lib/stella/cli/agents.rb +0 -73
  46. data/lib/stella/cli/base.rb +0 -55
  47. data/lib/stella/cli/language.rb +0 -18
  48. data/lib/stella/cli/localtest.rb +0 -78
  49. data/lib/stella/cli/sysinfo.rb +0 -16
  50. data/lib/stella/cli/watch.rb +0 -278
  51. data/lib/stella/command/localtest.rb +0 -358
  52. data/lib/stella/response.rb +0 -85
  53. data/lib/stella/storable.rb +0 -201
  54. data/lib/stella/support.rb +0 -276
  55. data/lib/stella/sysinfo.rb +0 -257
  56. data/lib/stella/test/definition.rb +0 -79
  57. data/lib/stella/test/run/summary.rb +0 -70
  58. data/lib/stella/test/stats.rb +0 -114
  59. data/lib/stella/text.rb +0 -64
  60. data/lib/stella/text/resource.rb +0 -38
  61. data/lib/utils/crypto-key.rb +0 -84
  62. data/lib/utils/domainutil.rb +0 -47
  63. data/lib/utils/escape.rb +0 -302
  64. data/lib/utils/fileutil.rb +0 -78
  65. data/lib/utils/httputil.rb +0 -266
  66. data/lib/utils/mathutil.rb +0 -15
  67. data/lib/utils/textgraph.rb +0 -267
  68. data/lib/utils/timerutil.rb +0 -58
  69. data/lib/win32/Console.rb +0 -970
  70. data/lib/win32/Console/ANSI.rb +0 -305
  71. data/support/kvm.h +0 -91
  72. data/support/ruby-pcap-takuma-notes.txt +0 -19
  73. data/support/ruby-pcap-takuma-patch.txt +0 -30
  74. data/support/text/en.yaml +0 -80
  75. data/support/text/nl.yaml +0 -7
  76. data/support/useragents.txt +0 -75
  77. data/tests/01-util_test.rb +0 -0
  78. data/tests/02-stella-util_test.rb +0 -42
  79. data/tests/10-stella_test.rb +0 -104
  80. data/tests/11-stella-storable_test.rb +0 -68
  81. data/tests/60-stella-command_test.rb +0 -248
  82. data/tests/80-stella-cli_test.rb +0 -45
  83. data/tests/spec-helper.rb +0 -31
data/CHANGES.txt CHANGED
@@ -1,9 +1,46 @@
1
1
  STELLA, CHANGES
2
2
 
3
+ #### TODO
4
+
5
+ * TODO: prepend instance variables with "stella_"
6
+ * TODO: implement session handling
7
+ * BUG: http://jira.codehaus.org/browse/JRUBY-2992
8
+ * TODO: variable interpolation that happens at test time so instance variables can be grabbed from the calling space.
9
+ #
10
+ # get "/product/${token}" do
11
+ # ## TODO: Override environment settings.
12
+ # #protocol :https
13
+ # response 200 do |headers, body|
14
+ # data = YAML.load(body)
15
+ # puts "ID: #{data[:id]}"
16
+ # end
17
+ # end
18
+
19
+
20
+
21
+ #### 0.6.0 (2009-03-15) ###############################
22
+
23
+ http://github.com/solutious/stella/tree/0.6
24
+
25
+ * COMPLETE REWRITE!
26
+ * The commands and API from 0.5.x are no longer supported. This ain't your grandmother's Stella.
27
+ * NEW: Tests are now defined using a DSL. See tryouts/dsl_tryout.rb for an example.
28
+ * NEW: Tests are run with Ruby directly: ruby testplan.rb (for now)
29
+
30
+
31
+ #### 0.5.6 (2009-02-04) ###############################
32
+
33
+ * API Change: watch is replaced by pcap and proxy.
34
+ * "stella watch -C" is now "stella pcap"
35
+ * "stella watch -P" is now "stella proxy"
36
+ * Fixed body printing bug for stella -v watch -C
37
+ * Added adapter tests
38
+ * Improved RDocs
39
+
3
40
 
4
41
  #### 0.5.5 (2009-01-14) ###############################
5
42
 
6
- http://github.com/solutious/stella/tree/0.5.5
43
+ http://github.com/solutious/stella/tree/stella-0.5.5
7
44
 
8
45
  * Now has specs (33 specifications, 303 requirements)
9
46
  * New dependency: test-spec (development copy only)
@@ -18,7 +55,7 @@ http://github.com/solutious/stella/tree/0.5.5
18
55
 
19
56
  #### 0.5.4-alpha (2009-01-07) #########################
20
57
 
21
- http://github.com/solutious/stella/tree/0.5.4-alpha
58
+ http://github.com/solutious/stella/tree/stella-0.5.4-alpha
22
59
 
23
60
  * New command: watch. Monitor HTTP traffic with Ruby-Pcap (unix only) or proxy. Pcap also supports DNS sniffing.
24
61
  * Improved error handling for stats output
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 Delano Mandelbaum
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,85 @@
1
+ = Stella - 0.6.0 ALPHA
2
+
3
+ Stella is a Ruby library for writing functional tests in a sexy DSL (domain specific language).
4
+
5
+ ==== NOTE: The 0.6 release was a complete rewrite from previous versions. All commands, APIs, and documentation have changed!*
6
+
7
+ == Example 1
8
+
9
+ testplan :maintain_value do
10
+ desc "Maintain a value between requests"
11
+ auth :basic, "stella", "stella"
12
+ protocol :http
13
+
14
+ post "/upload" do
15
+ name "Add Product"
16
+ body "bill", "/path/2/file.txt"
17
+ header "X-Stella" => "Version #{Stella::VERSION}"
18
+ param :convert => true
19
+ param :rand => rand
20
+
21
+ response 200, 201 do |headers, body, objid|
22
+ data = YAML.load(body)
23
+ @product_id = data[:id] # Save a response value
24
+ end
25
+ end
26
+
27
+ get "/product" do
28
+ name "View Product"
29
+ param 'id' => @product_id # Use the saved value
30
+
31
+ response 200 do |header, body, objid|
32
+ data = YAML.load(body)
33
+ repeat :times => 2, :wait => 1.second # Repeat this request twice
34
+ end
35
+ end
36
+ end
37
+
38
+ functest :quick_test do
39
+ plan :product_api
40
+ clients 2
41
+ duration 5.minutes
42
+ verbose
43
+ end
44
+
45
+ environment :development do
46
+ machines "localhost:3114"
47
+ # machine "localhost:3115"
48
+ # ...
49
+ end
50
+
51
+ run :development, :quick_test
52
+
53
+
54
+ See bin/example_test.rb for a running example.
55
+
56
+
57
+ == Installation
58
+
59
+ Get it in one of the following ways:
60
+
61
+ * RubyForge: http://stella.rubyforge.org/
62
+ * gem install stella
63
+ * git clone git://github.com/solutious/stella.git
64
+ * gem install solutious-stella --source http://gems.github.com
65
+
66
+
67
+ == More Information
68
+
69
+ Stellaaahhhh[http://www.youtube.com/watch?v=wmq-JDonTpc]
70
+
71
+
72
+ == Credits
73
+
74
+ * Delano Mandelbaum (delano@solutious.com)
75
+
76
+
77
+ == Thanks
78
+
79
+ * Harm Aarts for the great test case and feedback!
80
+ * Kalin Harvey for keeping me on track.
81
+ * Dave L, the best intern money can't buy.
82
+
83
+ == License
84
+
85
+ See LICENSE.txt
data/Rakefile CHANGED
@@ -1,88 +1,83 @@
1
-
2
1
  require 'rubygems'
3
2
  require 'rake/clean'
4
3
  require 'rake/gempackagetask'
5
- require 'rake/rdoctask'
4
+ require 'hanna/rdoctask'
6
5
  require 'fileutils'
7
6
  include FileUtils
8
7
 
9
- task :default => :test
10
-
11
- # SPECS ===============================================================
8
+ task :default => :package
12
9
 
13
- desc 'Run specs with unit test style output'
14
- task :test do |t|
15
- # sh "specrb -s tests/*_test.rb"
16
- sh "specrb -s tests/*_test.rb"
17
- end
10
+ # CONFIG =============================================================
18
11
 
19
- # PACKAGE =============================================================
20
-
21
-
22
- STELLA_HOME = File.expand_path(File.join(File.dirname(__FILE__)))
23
- $: << File.join(STELLA_HOME, 'lib')
24
-
25
- require 'stella'
26
- version = Stella::VERSION.to_s
27
- name = "stella"
28
-
29
- spec = Gem::Specification.new do |s|
30
- s.name = name
31
- s.version = version
32
- s.summary = "Your friend in performance testing."
33
- s.description = "Run Apache Bench, Siege, or httperf tests in batches and aggregate results."
34
- s.author = "Delano Mandelbaum"
35
- s.email = "delano@solutious.com"
36
- s.homepage = "http://stella.solutious.com/"
37
- s.executables = [ "stella", "stella.bat" ]
38
- s.rubyforge_project = "stella"
39
- s.extra_rdoc_files = ['README.textile']
40
-
41
- # NOTE: how to make optional dependencies?
42
- s.add_dependency 'mongrel'
43
- s.add_dependency 'rspec'
44
- s.add_dependency 'net-dns'
45
-
46
- s.platform = Gem::Platform::RUBY
47
- s.has_rdoc = true
48
-
49
- s.files = %w(Rakefile) + Dir.glob("{bin,doc,lib,tests,support,vendor}/**/**/*")
50
-
51
- s.require_path = "lib"
52
- s.bindir = "bin"
53
- end
12
+ # Change the following according to your needs
13
+ README = "README.rdoc"
14
+ CHANGES = "CHANGES.txt"
15
+ LICENSE = "LICENSE.txt"
16
+
17
+ # Files and directories to be deleted when you run "rake clean"
18
+ CLEAN.include [ 'pkg', '*.gem', '.config', 'doc']
19
+
20
+ # Virginia assumes your project and gemspec have the same name
21
+ name = (Dir.glob('*.gemspec') || ['stella']).first.split('.').first
22
+ load "#{name}.gemspec"
23
+ version = @spec.version
24
+
25
+ # That's it! The following defaults should allow you to get started
26
+ # on other things.
27
+
28
+
29
+ # TESTS/SPECS =========================================================
54
30
 
55
- Rake::GemPackageTask.new(spec) do |p|
56
- p.need_tar = true if RUBY_PLATFORM !~ /mswin/
57
- end
58
31
 
59
32
 
33
+ # INSTALL =============================================================
60
34
 
35
+ Rake::GemPackageTask.new(@spec) do |p|
36
+ p.need_tar = true if RUBY_PLATFORM !~ /mswin/
37
+ end
38
+
39
+ task :release => [ :rdoc, :package ]
61
40
  task :install => [ :rdoc, :package ] do
62
41
  sh %{sudo gem install pkg/#{name}-#{version}.gem}
63
42
  end
64
-
65
43
  task :uninstall => [ :clean ] do
66
44
  sh %{sudo gem uninstall #{name}}
67
45
  end
68
46
 
69
47
 
48
+ # RUBYFORGE RELEASE / PUBLISH TASKS ==================================
49
+
50
+ if @spec.rubyforge_project
51
+ desc 'Publish website to rubyforge'
52
+ task 'publish:rdoc' => 'doc/index.html' do
53
+ sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
54
+ end
55
+
56
+ desc 'Public release to rubyforge'
57
+ task 'publish:gem' => [:package] do |t|
58
+ sh <<-end
59
+ rubyforge add_release -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
60
+ rubyforge add_file -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
61
+ end
62
+ end
63
+ end
64
+
65
+
66
+
67
+ # RUBY DOCS TASK ==================================
70
68
 
71
69
  Rake::RDocTask.new do |t|
72
70
  t.rdoc_dir = 'doc'
73
- t.title = "stella, a friend in performance testing"
74
- t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
71
+ t.title = @spec.summary
72
+ t.options << '--line-numbers'
75
73
  t.options << '--charset' << 'utf-8'
76
- t.rdoc_files.include('LICENSE.txt')
77
- t.rdoc_files.include('README.textile')
78
- t.rdoc_files.include('CHANGES.txt')
79
- t.rdoc_files.include('lib/utils/*.rb')
80
- t.rdoc_files.include('lib/stella.rb')
81
- t.rdoc_files.include('lib/stella/*.rb')
82
- t.rdoc_files.include('lib/stella/**/*.rb')
74
+ t.rdoc_files.include(LICENSE)
75
+ t.rdoc_files.include(README)
76
+ t.rdoc_files.include(CHANGES)
77
+ t.rdoc_files.include('bin/*')
78
+ t.rdoc_files.include('lib/**/*.rb')
83
79
  end
84
80
 
85
- CLEAN.include [ 'pkg', '*.gem', '.config', 'doc' ]
86
81
 
87
82
 
88
83
 
@@ -0,0 +1,82 @@
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
+
@@ -0,0 +1,63 @@
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