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.
- data/CHANGES.txt +7 -15
- data/LICENSE.txt +1 -1
- data/README.rdoc +93 -63
- data/Rakefile +32 -42
- data/bin/stella +138 -0
- data/examples/basic/listing_ids.csv +7 -0
- data/examples/basic/plan.rb +71 -0
- data/lib/stella/cli.rb +66 -0
- data/lib/stella/client.rb +199 -0
- data/lib/stella/config.rb +87 -0
- data/lib/stella/data/http/body.rb +15 -0
- data/lib/stella/data/http/request.rb +116 -0
- data/lib/stella/data/http/response.rb +92 -0
- data/lib/stella/data/http.rb +2 -257
- data/lib/stella/data.rb +85 -0
- data/lib/stella/dsl.rb +5 -0
- data/lib/stella/engine/functional.rb +39 -0
- data/lib/stella/engine/load.rb +106 -0
- data/lib/stella/engine.rb +55 -0
- data/lib/stella/exceptions.rb +15 -0
- data/lib/stella/guidelines.rb +18 -0
- data/lib/stella/mixins.rb +2 -0
- data/lib/stella/stats.rb +3 -7
- data/lib/stella/testplan/stats.rb +26 -0
- data/lib/stella/testplan/usecase.rb +67 -0
- data/lib/stella/testplan.rb +95 -220
- data/lib/{util → stella/utils}/httputil.rb +0 -0
- data/lib/stella/utils.rb +126 -0
- data/lib/stella/version.rb +15 -0
- data/lib/stella.rb +58 -104
- data/lib/threadify.rb +0 -6
- data/stella.gemspec +43 -49
- data/support/example_webapp.rb +246 -0
- data/support/useragents.txt +75 -0
- metadata +68 -32
- data/bin/example_test.rb +0 -82
- data/bin/example_webapp.rb +0 -63
- data/lib/logger.rb +0 -79
- data/lib/stella/clients.rb +0 -161
- data/lib/stella/command/base.rb +0 -20
- data/lib/stella/command/form.rb +0 -36
- data/lib/stella/command/get.rb +0 -44
- data/lib/stella/common.rb +0 -53
- data/lib/stella/crypto.rb +0 -88
- data/lib/stella/data/domain.rb +0 -82
- data/lib/stella/environment.rb +0 -66
- data/lib/stella/functest.rb +0 -105
- data/lib/stella/loadtest.rb +0 -186
- data/lib/stella/testrunner.rb +0 -64
- data/lib/storable.rb +0 -280
- data/lib/timeunits.rb +0 -65
- data/tryouts/drb/drb_test.rb +0 -65
- data/tryouts/drb/open4.rb +0 -19
- data/tryouts/drb/slave.rb +0 -27
- data/tryouts/oo_tryout.rb +0 -30
data/lib/stella/crypto.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
if RUBY_PLATFORM !~ /java/
|
4
|
-
require 'openssl'
|
5
|
-
else
|
6
|
-
module JRuby #:nodoc:
|
7
|
-
module OpenSSL #:nodoc:
|
8
|
-
GEM_ONLY = false unless defined?(GEM_ONLY)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
if JRuby::OpenSSL::GEM_ONLY
|
13
|
-
require 'jruby/openssl/gem'
|
14
|
-
else
|
15
|
-
module OpenSSL #:nodoc:all
|
16
|
-
class OpenSSLError < StandardError; end
|
17
|
-
# These require the gem
|
18
|
-
%w[
|
19
|
-
ASN1
|
20
|
-
BN
|
21
|
-
Cipher
|
22
|
-
Config
|
23
|
-
Netscape
|
24
|
-
PKCS7
|
25
|
-
PKey
|
26
|
-
Random
|
27
|
-
SSL
|
28
|
-
X509
|
29
|
-
].each {|c| autoload c, "jruby/openssl/gem"}
|
30
|
-
end
|
31
|
-
require "jruby/openssl/builtin"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# A small collection of helper methods for dealing with RSA keys.
|
36
|
-
module Stella::Crypto
|
37
|
-
VERSION = 1.0
|
38
|
-
|
39
|
-
def self.create_keys(bits = 2048)
|
40
|
-
pk = OpenSSL::PKey::RSA.new(bits)
|
41
|
-
end
|
42
|
-
|
43
|
-
@@digest = OpenSSL::Digest::Digest.new("sha1")
|
44
|
-
def self.sign(secret, string)
|
45
|
-
sig = OpenSSL::HMAC.hexdigest(@@digest, secret, string).strip
|
46
|
-
#sig.gsub(/\+/, "%2b")
|
47
|
-
end
|
48
|
-
def self.aws_sign(secret, string)
|
49
|
-
Base64.encode64(self.sign(secret, string)).strip
|
50
|
-
end
|
51
|
-
|
52
|
-
# A class which represents an RSA or DSA key.
|
53
|
-
class Key
|
54
|
-
attr_reader :data, :key
|
55
|
-
|
56
|
-
# Create an instance of Crypto::Key with the provided rsa or dsa
|
57
|
-
# public or private key data.
|
58
|
-
def initialize(data)
|
59
|
-
@data = data
|
60
|
-
@public = (data =~ /^-----BEGIN (RSA|DSA) PRIVATE KEY-----$/).nil?
|
61
|
-
@key = OpenSSL::PKey::RSA.new(@data)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Create an instance of Crypto::Key using a key file.
|
65
|
-
# key = Crypto::Key.from_file('path/2/id_rsa')
|
66
|
-
def self.from_file(filename)
|
67
|
-
self.new File.read( filename )
|
68
|
-
end
|
69
|
-
|
70
|
-
# Encrypt and base64 encode the given text.
|
71
|
-
def encrypt(text)
|
72
|
-
Base64.encode64(@key.send("#{type}_encrypt", text))
|
73
|
-
end
|
74
|
-
|
75
|
-
# Decrypt the given base64 encoded text.
|
76
|
-
def decrypt(text)
|
77
|
-
@key.send("#{type}_decrypt", Base64.decode64(text))
|
78
|
-
end
|
79
|
-
|
80
|
-
def private?(); !@public; end
|
81
|
-
def public?(); @public; end
|
82
|
-
|
83
|
-
def type
|
84
|
-
@public ? :public : :private
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
data/lib/stella/data/domain.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Stella::Data
|
4
|
-
class DomainRequest < Storable
|
5
|
-
attr_accessor :dns_data
|
6
|
-
attr_reader :raw_data
|
7
|
-
|
8
|
-
field :time => DateTime
|
9
|
-
field :client_ip => String
|
10
|
-
field :server_ip => String
|
11
|
-
field :domain_name => String
|
12
|
-
field :header => String
|
13
|
-
|
14
|
-
def initialize(raw_data)
|
15
|
-
@raw_data = raw_data
|
16
|
-
@dns_data, @domain_name, @header = DomainUtil::parse_domain_request(@raw_data)
|
17
|
-
end
|
18
|
-
|
19
|
-
def has_request?
|
20
|
-
false
|
21
|
-
end
|
22
|
-
def has_response?
|
23
|
-
false
|
24
|
-
end
|
25
|
-
def has_body?
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_s
|
30
|
-
"%s: %s -> %s (%s)" % [@time, @client_ip, @server_ip, @domain_name]
|
31
|
-
end
|
32
|
-
|
33
|
-
def inspect
|
34
|
-
str = "#{$/};; REQUEST #{@time.to_s}"
|
35
|
-
str << "#{$/};; %s %s> %s" % [@client_ip, '-'*30, @server_ip]
|
36
|
-
str << "#{$/};;#{$/}"
|
37
|
-
str << @dns_data.inspect
|
38
|
-
str
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
class DomainResponse < Storable
|
44
|
-
attr_accessor :dns_data
|
45
|
-
attr_reader :raw_data
|
46
|
-
|
47
|
-
field :time => DateTime
|
48
|
-
field :client_ip => String
|
49
|
-
field :server_ip => String
|
50
|
-
field :domain_name => String
|
51
|
-
field :header => String
|
52
|
-
field :addresses => Array
|
53
|
-
field :cnames => Array
|
54
|
-
|
55
|
-
|
56
|
-
def initialize(raw_data)
|
57
|
-
@raw_data = raw_data
|
58
|
-
@dns_data, @domain_name, @header, @addresses, @cnames = DomainUtil::parse_domain_response(@raw_data)
|
59
|
-
end
|
60
|
-
|
61
|
-
def has_request?
|
62
|
-
false
|
63
|
-
end
|
64
|
-
def has_response?
|
65
|
-
false
|
66
|
-
end
|
67
|
-
def has_body?
|
68
|
-
false
|
69
|
-
end
|
70
|
-
|
71
|
-
def to_s
|
72
|
-
"%s: %s <- %s (%s) %s" % [@time, @client_ip, @server_ip, @domain_name, (@addresses || []).join(',')]
|
73
|
-
end
|
74
|
-
|
75
|
-
def inspect
|
76
|
-
str = "#{$/};; RESPONSE #{@time.strftime(NICE_TIME_FORMAT)}"
|
77
|
-
str << "#{$/};; %s <%s %s" % [@client_ip, '-'*30, @server_ip]
|
78
|
-
str << "#{$/};;#{$/}"
|
79
|
-
str << @dns_data.inspect
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
data/lib/stella/environment.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
module Stella
|
2
|
-
class Environment
|
3
|
-
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
module Stella
|
9
|
-
class Environment
|
10
|
-
|
11
|
-
attr_accessor :name
|
12
|
-
|
13
|
-
# An array of `Stella::Common::Machine objects to be use during the test.
|
14
|
-
# @stella_environments.machines << "stellaaahhhh.com:80"
|
15
|
-
attr_accessor :machines
|
16
|
-
# The default proxy, a Stella::Common::Proxy object containing the proxy to be used for the test.
|
17
|
-
attr_accessor :proxy
|
18
|
-
|
19
|
-
def initialize(name=:development)
|
20
|
-
@name = name
|
21
|
-
@machines = []
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def add_machines(*args)
|
26
|
-
return if args.empty?
|
27
|
-
args.each do |machine|
|
28
|
-
@machines << Stella::Common::Machine.new(machine)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Creates a Stella::TestPlan::Proxy object and stores it to +@proxy+
|
33
|
-
def proxy=(*args)
|
34
|
-
uri, user, pass = args.flatten
|
35
|
-
@proxy = Stella::Common::Proxy.new(uri, user, pass)
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
module Stella
|
43
|
-
module DSL
|
44
|
-
module Environment
|
45
|
-
attr_accessor :stella_current_environment
|
46
|
-
|
47
|
-
def environments
|
48
|
-
@stella_environments
|
49
|
-
end
|
50
|
-
|
51
|
-
def environment(name, &define)
|
52
|
-
@stella_environments ||= {}
|
53
|
-
@stella_current_environment = @stella_environments[name] = Stella::Environment.new(name)
|
54
|
-
define.call if define
|
55
|
-
end
|
56
|
-
|
57
|
-
def machines(*args)
|
58
|
-
return unless @stella_current_environment.is_a? Stella::Environment
|
59
|
-
args.each do |machine|
|
60
|
-
@stella_current_environment.add_machines machine
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/lib/stella/functest.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
module Stella
|
5
|
-
class FunctionalTest
|
6
|
-
include TestRunner
|
7
|
-
|
8
|
-
def type; "functional"; end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def update_start(machine, name)
|
13
|
-
puts '-'*60
|
14
|
-
puts "%10s: %s" % ["MACHINE", machine]
|
15
|
-
end
|
16
|
-
|
17
|
-
def update_authorized(domain, user, pass)
|
18
|
-
note = user
|
19
|
-
note += ":****" if pass
|
20
|
-
puts "%10s: %s" % ["user", note]
|
21
|
-
puts
|
22
|
-
end
|
23
|
-
|
24
|
-
def update_request(method, uri, query, response_status, response_headers, response_body)
|
25
|
-
puts "#{method} #{uri}"
|
26
|
-
puts "%18s: %s" % ["status", response_status]
|
27
|
-
puts "%18s: %s" % ["query", query] if @verbose > 0 && !query.empty?
|
28
|
-
puts "%18s: %s" % ["response_headers", response_headers]
|
29
|
-
puts "%18s: #{$/}%s" % ["response_body", response_body[0..100]] if @verbose > 0
|
30
|
-
puts
|
31
|
-
end
|
32
|
-
|
33
|
-
def update_request_exception(method, uri, query, ex)
|
34
|
-
puts "#{method} #{uri}"
|
35
|
-
puts "EXCEPTION: #{ex.message}"
|
36
|
-
puts ex.backtrace
|
37
|
-
end
|
38
|
-
|
39
|
-
def update_request_unexpected_response(method, uri, query, response_status, response_headers, response_body)
|
40
|
-
puts "#{method} #{uri}"
|
41
|
-
puts "%18s: %s" % ["status", response_status]
|
42
|
-
puts "%18s: %s" % ["note", "unexpected response status"]
|
43
|
-
puts "", response_body[0..500]
|
44
|
-
puts '...' if response_body.length >= 500
|
45
|
-
end
|
46
|
-
|
47
|
-
def update_retrying(uri, retry_count, total)
|
48
|
-
puts "retrying: #{uri} (#{retry_count} of #{total})"
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
# +environment+ is a Stella::Common::Environment object.
|
53
|
-
# +namespace+ is a reference to the namespace which contains the instance
|
54
|
-
# variables. This will be the section of code that makes use of the DSL.
|
55
|
-
def run(environment, namespace)
|
56
|
-
raise "No testplan defined" unless @testplan
|
57
|
-
raise "No machines defined for #{environment.name}" if environment.machines.empty?
|
58
|
-
|
59
|
-
|
60
|
-
begin
|
61
|
-
if environment.proxy
|
62
|
-
http_client = HTTPClient.new(environment.proxy.uri)
|
63
|
-
http_client.set_proxy_auth(environment.proxy.user, environment.proxy.pass) if environment.proxy.user
|
64
|
-
else
|
65
|
-
http_client = HTTPClient.new
|
66
|
-
end
|
67
|
-
rescue => ex
|
68
|
-
puts ex.class
|
69
|
-
end
|
70
|
-
|
71
|
-
request_stats = {}
|
72
|
-
environment.machines.each do |machine|
|
73
|
-
client = Stella::Client.new
|
74
|
-
client.add_observer(self)
|
75
|
-
client.execute_testplan(request_stats, http_client, machine, namespace, @testplan, @verbose)
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
request_stats.each do |rstat|
|
80
|
-
puts rstat[1][:stats].to_s
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
module Stella
|
92
|
-
module DSL
|
93
|
-
module FunctionalTest
|
94
|
-
include Stella::DSL::TestRunner
|
95
|
-
|
96
|
-
def functest(name=:default, &define)
|
97
|
-
@tests ||= {}
|
98
|
-
@current_test = @tests[name] = Stella::FunctionalTest.new(name)
|
99
|
-
define.call if define
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
data/lib/stella/loadtest.rb
DELETED
@@ -1,186 +0,0 @@
|
|
1
|
-
# See, re Threadify on JRuby: http://www.ruby-forum.com/topic/158180
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
module Stella
|
6
|
-
class LoadTest
|
7
|
-
include TestRunner
|
8
|
-
|
9
|
-
attr_accessor :clients
|
10
|
-
attr_accessor :repetitions
|
11
|
-
attr_accessor :duration
|
12
|
-
|
13
|
-
attr_reader :testplans_started
|
14
|
-
attr_reader :testplans_completed
|
15
|
-
|
16
|
-
attr_reader :requests_successful
|
17
|
-
attr_reader :requests_failed
|
18
|
-
|
19
|
-
def init
|
20
|
-
@repetitions = 1
|
21
|
-
@clients = 1
|
22
|
-
@duration = 0
|
23
|
-
reset
|
24
|
-
end
|
25
|
-
|
26
|
-
def reset
|
27
|
-
@testplans_started = 0
|
28
|
-
@testplans_completed = 0
|
29
|
-
@requests_successful = 0
|
30
|
-
@requests_failed = 0
|
31
|
-
end
|
32
|
-
|
33
|
-
def type; "load"; end
|
34
|
-
|
35
|
-
def requests_total
|
36
|
-
@requests_successful + @requests_failed
|
37
|
-
end
|
38
|
-
|
39
|
-
def update_start(machine, name)
|
40
|
-
@testplans_started += 1
|
41
|
-
end
|
42
|
-
|
43
|
-
def update_done(*args)
|
44
|
-
@testplans_completed += 1
|
45
|
-
end
|
46
|
-
|
47
|
-
def update_authorized(domain, user, pass)
|
48
|
-
end
|
49
|
-
|
50
|
-
def update_request(method, uri, query, response_status, response_headers, response_body)
|
51
|
-
@requests_successful += 1
|
52
|
-
end
|
53
|
-
|
54
|
-
def update_request_exception(method, uri, query, ex)
|
55
|
-
@requests_failed += 1
|
56
|
-
puts [method, uri, query, ex.message].join("|")
|
57
|
-
end
|
58
|
-
|
59
|
-
def update_request_unexpected_response(method, uri, query, response_status, response_headers, response_body)
|
60
|
-
@requests_failed += 1
|
61
|
-
#puts [method, uri, query, response_status, response_headers, response_body].join("|")
|
62
|
-
end
|
63
|
-
|
64
|
-
def update_retrying(uri, retry_count, total)
|
65
|
-
#print retry_count
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
# +environment+ is a Stella::Common::Environment object.
|
70
|
-
# +namespace+ is a reference to the namespace which contains the instance
|
71
|
-
# variables.
|
72
|
-
def run(environment, namespace)
|
73
|
-
raise "No testplan defined" unless @testplan
|
74
|
-
raise "No machines defined for #{environment.name}" if environment.machines.empty?
|
75
|
-
|
76
|
-
[:duration, :clients, :repetitions].each do |p|
|
77
|
-
val = instance_variable_get("@#{p}")
|
78
|
-
puts " %11s: %s" % [p, val] if val
|
79
|
-
end
|
80
|
-
|
81
|
-
stats = Stats.new("LoadTest")
|
82
|
-
request_stats = {}
|
83
|
-
|
84
|
-
time_started = Time.now
|
85
|
-
seconds_elapsed = 0
|
86
|
-
(1..@clients).to_a.threadify do |i|
|
87
|
-
|
88
|
-
(0..@repetitions).to_a.each do |rep|
|
89
|
-
|
90
|
-
if environment.proxy
|
91
|
-
http_client = HTTPClient.new(environment.proxy.uri)
|
92
|
-
http_client.set_proxy_auth(environment.proxy.user, environment.proxy.pass) if environment.proxy.user
|
93
|
-
else
|
94
|
-
http_client = HTTPClient.new
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
environment.machines.each do |machine|
|
99
|
-
client = Stella::Client.new(i)
|
100
|
-
client.add_observer(self)
|
101
|
-
client.execute_testplan(request_stats, http_client, machine, namespace, @testplan, @verbose)
|
102
|
-
end
|
103
|
-
|
104
|
-
seconds_elapsed = Time.now - time_started
|
105
|
-
|
106
|
-
#request_stats.each do |rstat|
|
107
|
-
# puts rstat[1][:stats].to_s
|
108
|
-
#end
|
109
|
-
|
110
|
-
# If a duration was given, we make sure to run for that
|
111
|
-
# amount of time.
|
112
|
-
if @duration > 0
|
113
|
-
redo if seconds_elapsed <= @duration
|
114
|
-
break if seconds_elapsed >= @duration
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
stats.tick
|
120
|
-
puts "DONE! (#{seconds_elapsed.minutes} minutes)"
|
121
|
-
instance_variables.each do |name|
|
122
|
-
#next unless name =~ /request/
|
123
|
-
puts "%20s: %s" % [name, instance_variable_get(name)]
|
124
|
-
end
|
125
|
-
|
126
|
-
puts "Final Status"
|
127
|
-
puts stats.to_s
|
128
|
-
puts
|
129
|
-
|
130
|
-
request_stats.each do |rstat|
|
131
|
-
puts rstat[1][:stats].to_s
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
def clients=(*args)
|
137
|
-
count = args.flatten.first
|
138
|
-
@clients = count
|
139
|
-
end
|
140
|
-
|
141
|
-
def repetitions=(*args)
|
142
|
-
@repetitions = args.flatten.first
|
143
|
-
end
|
144
|
-
|
145
|
-
def duration=(*args)
|
146
|
-
@duration = args.flatten.first
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
module Stella
|
158
|
-
module DSL
|
159
|
-
module LoadTest
|
160
|
-
include Stella::DSL::TestRunner
|
161
|
-
|
162
|
-
def loadtest(name=:default, &define)
|
163
|
-
@tests ||= {}
|
164
|
-
@current_test = @tests[name] = Stella::LoadTest.new(name)
|
165
|
-
define.call if define
|
166
|
-
end
|
167
|
-
|
168
|
-
def rampup(*args)
|
169
|
-
end
|
170
|
-
|
171
|
-
def warmup(*args)
|
172
|
-
end
|
173
|
-
|
174
|
-
[:repetitions, :duration, :clients].each do |method_name|
|
175
|
-
eval <<-RUBY, binding, '(Stella::DSL::LoadTest)', 1
|
176
|
-
def #{method_name}(*val)
|
177
|
-
return unless @current_test.is_a? Stella::LoadTest
|
178
|
-
@current_test.#{method_name}=(val)
|
179
|
-
end
|
180
|
-
private :#{method_name}
|
181
|
-
RUBY
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
data/lib/stella/testrunner.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# ---
|
2
|
-
# See: http://codeforpeople.com/lib/ruby/flow/flow-2.0.0/sample/a.rb
|
3
|
-
# +++
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
module Stella
|
9
|
-
module TestRunner
|
10
|
-
attr_accessor :name
|
11
|
-
# Name or instance of the testplan to execute
|
12
|
-
attr_accessor :testplan
|
13
|
-
# Determines the amount of output. Default: 0
|
14
|
-
attr_accessor :verbose
|
15
|
-
|
16
|
-
def initialize(name=:default)
|
17
|
-
@name = name
|
18
|
-
@verbose = 0
|
19
|
-
init if respond_to? :init
|
20
|
-
end
|
21
|
-
|
22
|
-
def update(*args)
|
23
|
-
what, *args = args
|
24
|
-
self.send("update_#{what}", *args) if respond_to? "update_#{what}"
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
module DSL
|
29
|
-
module TestRunner
|
30
|
-
attr_accessor :current_test
|
31
|
-
|
32
|
-
def plan(testplan)
|
33
|
-
raise "Unknown testplan, '#{testplan}'" unless @plans.has_key?(testplan)
|
34
|
-
return unless @current_test
|
35
|
-
@current_test.testplan = @plans[testplan]
|
36
|
-
end
|
37
|
-
|
38
|
-
def run(env_name=nil, test_name=nil)
|
39
|
-
to_run = test_name.nil? ? @tests : [@tests[test_name]]
|
40
|
-
env = env_name.nil? ? @stella_environments.first : @stella_environments[env_name]
|
41
|
-
to_run.each do |t|
|
42
|
-
puts '='*60
|
43
|
-
puts "RUNNING TEST: #{test_name}"
|
44
|
-
puts " %11s: %s" % ['type', t.type]
|
45
|
-
puts " %11s: %s" % ['testplan', t.testplan.name]
|
46
|
-
puts " %11s: %s" % ['desc', t.testplan.description]
|
47
|
-
puts " %11s: %s" % ['env', env_name]
|
48
|
-
|
49
|
-
|
50
|
-
t.run(env, self)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def verbose(*args)
|
55
|
-
@current_test.verbose += args.first || 1
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|