solutious-stella 0.6.0 → 0.7.0.001
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +3 -15
- data/LICENSE.txt +1 -1
- data/README.rdoc +90 -60
- 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.rb +57 -104
- data/lib/stella/cli.rb +66 -0
- data/lib/stella/client.rb +197 -0
- data/lib/stella/config.rb +87 -0
- data/lib/stella/data.rb +85 -0
- data/lib/stella/data/http.rb +2 -257
- 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/dsl.rb +5 -0
- data/lib/stella/engine.rb +55 -0
- data/lib/stella/engine/functional.rb +39 -0
- data/lib/stella/engine/load.rb +106 -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.rb +95 -220
- data/lib/stella/testplan/stats.rb +26 -0
- data/lib/stella/testplan/usecase.rb +67 -0
- data/lib/stella/utils.rb +126 -0
- data/lib/{util → stella/utils}/httputil.rb +0 -0
- data/lib/stella/version.rb +15 -0
- 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 +66 -31
- 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/clients.rb
DELETED
@@ -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
|
data/lib/stella/command/base.rb
DELETED
@@ -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
|
data/lib/stella/command/form.rb
DELETED
@@ -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
|
data/lib/stella/command/get.rb
DELETED
@@ -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
|
-
|
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
|