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.
- data/CHANGES.txt +39 -2
- data/LICENSE.txt +19 -0
- data/README.rdoc +85 -0
- data/Rakefile +54 -59
- data/bin/example_test.rb +82 -0
- data/bin/example_webapp.rb +63 -0
- data/lib/{stella/logger.rb → logger.rb} +6 -11
- data/lib/stella.rb +76 -58
- data/lib/stella/clients.rb +161 -0
- data/lib/stella/command/base.rb +4 -24
- data/lib/stella/command/form.rb +36 -0
- data/lib/stella/command/get.rb +44 -0
- data/lib/stella/common.rb +53 -0
- data/lib/stella/crypto.rb +88 -0
- data/lib/stella/data/domain.rb +2 -2
- data/lib/stella/data/http.rb +164 -36
- data/lib/stella/environment.rb +66 -0
- data/lib/stella/functest.rb +105 -0
- data/lib/stella/loadtest.rb +186 -0
- data/lib/{utils → stella}/stats.rb +16 -20
- data/lib/stella/testplan.rb +237 -0
- data/lib/stella/testrunner.rb +64 -0
- data/lib/storable.rb +280 -0
- data/lib/threadify.rb +171 -0
- data/lib/timeunits.rb +65 -0
- data/lib/util/httputil.rb +266 -0
- data/stella.gemspec +69 -0
- data/tryouts/drb/drb_test.rb +65 -0
- data/tryouts/drb/open4.rb +19 -0
- data/tryouts/drb/slave.rb +27 -0
- data/tryouts/oo_tryout.rb +30 -0
- metadata +39 -107
- data/README.textile +0 -162
- data/bin/stella +0 -12
- data/bin/stella.bat +0 -12
- data/lib/daemonize.rb +0 -56
- data/lib/pcaplet.rb +0 -180
- data/lib/stella/adapter/ab.rb +0 -337
- data/lib/stella/adapter/base.rb +0 -106
- data/lib/stella/adapter/httperf.rb +0 -305
- data/lib/stella/adapter/pcap_watcher.rb +0 -221
- data/lib/stella/adapter/proxy_watcher.rb +0 -76
- data/lib/stella/adapter/siege.rb +0 -341
- data/lib/stella/cli.rb +0 -258
- data/lib/stella/cli/agents.rb +0 -73
- data/lib/stella/cli/base.rb +0 -55
- data/lib/stella/cli/language.rb +0 -18
- data/lib/stella/cli/localtest.rb +0 -78
- data/lib/stella/cli/sysinfo.rb +0 -16
- data/lib/stella/cli/watch.rb +0 -278
- data/lib/stella/command/localtest.rb +0 -358
- data/lib/stella/response.rb +0 -85
- data/lib/stella/storable.rb +0 -201
- data/lib/stella/support.rb +0 -276
- data/lib/stella/sysinfo.rb +0 -257
- data/lib/stella/test/definition.rb +0 -79
- data/lib/stella/test/run/summary.rb +0 -70
- data/lib/stella/test/stats.rb +0 -114
- data/lib/stella/text.rb +0 -64
- data/lib/stella/text/resource.rb +0 -38
- data/lib/utils/crypto-key.rb +0 -84
- data/lib/utils/domainutil.rb +0 -47
- data/lib/utils/escape.rb +0 -302
- data/lib/utils/fileutil.rb +0 -78
- data/lib/utils/httputil.rb +0 -266
- data/lib/utils/mathutil.rb +0 -15
- data/lib/utils/textgraph.rb +0 -267
- data/lib/utils/timerutil.rb +0 -58
- data/lib/win32/Console.rb +0 -970
- data/lib/win32/Console/ANSI.rb +0 -305
- data/support/kvm.h +0 -91
- data/support/ruby-pcap-takuma-notes.txt +0 -19
- data/support/ruby-pcap-takuma-patch.txt +0 -30
- data/support/text/en.yaml +0 -80
- data/support/text/nl.yaml +0 -7
- data/support/useragents.txt +0 -75
- data/tests/01-util_test.rb +0 -0
- data/tests/02-stella-util_test.rb +0 -42
- data/tests/10-stella_test.rb +0 -104
- data/tests/11-stella-storable_test.rb +0 -68
- data/tests/60-stella-command_test.rb +0 -248
- data/tests/80-stella-cli_test.rb +0 -45
- data/tests/spec-helper.rb +0 -31
@@ -0,0 +1,44 @@
|
|
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
|
@@ -0,0 +1,53 @@
|
|
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
|
+
|
@@ -0,0 +1,88 @@
|
|
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
module Stella::Data
|
4
|
-
class DomainRequest <
|
4
|
+
class DomainRequest < Storable
|
5
5
|
attr_accessor :dns_data
|
6
6
|
attr_reader :raw_data
|
7
7
|
|
@@ -40,7 +40,7 @@ module Stella::Data
|
|
40
40
|
|
41
41
|
end
|
42
42
|
|
43
|
-
class DomainResponse <
|
43
|
+
class DomainResponse < Storable
|
44
44
|
attr_accessor :dns_data
|
45
45
|
attr_reader :raw_data
|
46
46
|
|
data/lib/stella/data/http.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
|
-
require '
|
2
|
+
require 'storable'
|
3
|
+
require 'util/httputil'
|
3
4
|
require 'base64'
|
4
5
|
|
5
6
|
module Stella::Data
|
@@ -7,7 +8,7 @@ module Stella::Data
|
|
7
8
|
# TODO: Implement HTTPHeaders. We should be printing untouched headers.
|
8
9
|
# HTTPUtil should split the HTTP event lines and that's it. Replace
|
9
10
|
# parse_header_body with split_header_body
|
10
|
-
class HTTPHeaders <
|
11
|
+
class HTTPHeaders < Storable
|
11
12
|
attr_reader :raw_data
|
12
13
|
|
13
14
|
def to_s
|
@@ -16,41 +17,125 @@ module Stella::Data
|
|
16
17
|
|
17
18
|
end
|
18
19
|
|
19
|
-
class
|
20
|
+
class HTTPBody < Storable
|
21
|
+
field :content_type
|
22
|
+
field :form_param
|
23
|
+
field :content
|
24
|
+
|
25
|
+
def has_content?
|
26
|
+
!@content.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class HTTPRequest < Storable
|
32
|
+
# A string representing a raw HTTP request
|
20
33
|
attr_reader :raw_data
|
21
34
|
|
35
|
+
# A hash containing blocks to be executed depending on the HTTP response status.
|
36
|
+
# The hash keys are numeric HTTP Status Codes.
|
37
|
+
#
|
38
|
+
# 200 => { ... }
|
39
|
+
# 304 => { ... }
|
40
|
+
# 500 => { ... }
|
41
|
+
#
|
42
|
+
attr_accessor :response_handler
|
43
|
+
|
44
|
+
field :name
|
45
|
+
field :stella_id
|
46
|
+
field :unique_id
|
22
47
|
field :time => DateTime
|
23
|
-
field :client_ip
|
24
|
-
field :server_ip
|
25
|
-
field :header
|
26
|
-
field :uri
|
27
|
-
field :
|
28
|
-
field :
|
29
|
-
field :
|
48
|
+
field :client_ip
|
49
|
+
field :server_ip
|
50
|
+
field :header
|
51
|
+
field :uri
|
52
|
+
field :params
|
53
|
+
field :body
|
54
|
+
field :http_method
|
55
|
+
field :http_version
|
56
|
+
|
30
57
|
|
31
58
|
def has_body?
|
32
|
-
|
59
|
+
!@body.nil? && !@body.empty?
|
33
60
|
end
|
34
61
|
def has_request?
|
35
62
|
false
|
36
63
|
end
|
37
|
-
|
38
|
-
|
64
|
+
|
65
|
+
def initialize (uri_str, method="GET", version="1.1")
|
66
|
+
@uri = (uri_str.is_a? String) ? URI.parse(uri_str) : uri
|
67
|
+
@http_method = method
|
68
|
+
@http_version = version
|
69
|
+
@headers = {}
|
70
|
+
@params = {}
|
71
|
+
@response_handler = {}
|
72
|
+
@time = Time.now
|
73
|
+
@stella_id = Stella::Crypto.sign(time.to_i.to_s, "#{@http_method}/#{@uri}/#{@params}")
|
74
|
+
@unique_id = nil
|
75
|
+
@body = HTTPBody.new
|
39
76
|
end
|
40
77
|
|
41
|
-
def
|
78
|
+
def set_unique_id(seasoning=rand)
|
79
|
+
@unique_id = Stella::Crypto.sign(rand.to_s + seasoning.to_s, "#{@http_method}/#{@uri}/#{@params}")
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
def from_raw(raw_data=nil)
|
42
84
|
@raw_data = raw_data
|
43
|
-
|
44
|
-
|
85
|
+
@http_method, @http_version, @uri, @header, @body = self.parse(@raw_data)
|
86
|
+
@time = DateTime.now
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.parse(raw)
|
90
|
+
return unless raw
|
91
|
+
HTTPUtil::parse_http_request(raw, @uri.host, @uri.port)
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
def add_header(*args)
|
96
|
+
name, value = (args[0].is_a? Hash) ? args[0].to_a.flatten : args
|
97
|
+
@headers[name.to_s] ||= []
|
98
|
+
@headers[name.to_s] << value
|
99
|
+
end
|
100
|
+
def add_param(*args)
|
101
|
+
name, value = (args[0].is_a? Hash) ? args[0].to_a.flatten : args
|
102
|
+
|
103
|
+
# BUG: This auto-array shit is causing a problem where the one request
|
104
|
+
# will set the param and then next will set it again and it becomes
|
105
|
+
# an array.
|
106
|
+
#if @params[name.to_s] && !@params[name.to_s].is_a?(Array)
|
107
|
+
# @params[name.to_s] = [@params[name.to_s]]
|
108
|
+
#else
|
109
|
+
# @params[name.to_s] = ""
|
110
|
+
#end
|
111
|
+
|
112
|
+
@params[name.to_s] = value.to_s
|
113
|
+
end
|
114
|
+
|
115
|
+
def add_response_handler(*args, &b)
|
116
|
+
args << 200 if args.empty?
|
117
|
+
args.each do |status|
|
118
|
+
@response_handler[status] = b
|
45
119
|
end
|
46
|
-
@response = Stella::Data::HTTPResponse.new
|
47
120
|
end
|
48
121
|
|
49
|
-
|
50
|
-
|
51
|
-
@
|
122
|
+
# +content+ can be literal content or a file path
|
123
|
+
def add_body(content, form_param=nil, content_type=nil)
|
124
|
+
@body = Stella::Data::HTTPBody.new
|
125
|
+
|
126
|
+
@body.form_param = form_param if form_param
|
127
|
+
@body.content_type = content_type if content_type
|
128
|
+
|
129
|
+
if File.exists?(content)
|
130
|
+
@body.content = File.new(content)
|
131
|
+
@body.content_type ||= "application/x-www-form-urlencoded"
|
132
|
+
else
|
133
|
+
@body.content = content
|
134
|
+
end
|
135
|
+
|
52
136
|
end
|
53
137
|
|
138
|
+
|
54
139
|
def body
|
55
140
|
return nil unless @body
|
56
141
|
@body
|
@@ -58,26 +143,35 @@ module Stella::Data
|
|
58
143
|
end
|
59
144
|
|
60
145
|
|
61
|
-
|
62
|
-
|
146
|
+
def headers
|
147
|
+
return [] unless header
|
63
148
|
headers = []
|
64
149
|
header.each_pair do |n,v|
|
65
|
-
headers <<
|
150
|
+
headers << [n.to_s.gsub('_', '-'), v[0]]
|
66
151
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
152
|
+
headers
|
153
|
+
end
|
154
|
+
|
155
|
+
def inspect
|
156
|
+
str = "%s %s HTTP/%s" % [http_method, uri.to_s, http_version]
|
157
|
+
str << $/ + headers.join($/) unless headers.empty?
|
158
|
+
str << $/ + $/ + body.to_s if body
|
70
159
|
str
|
71
160
|
end
|
72
161
|
|
73
162
|
def to_s
|
74
|
-
str = "%s: %s %s HTTP/%s" % [time.strftime(NICE_TIME_FORMAT),
|
163
|
+
str = "%s: %s %s HTTP/%s" % [time.strftime(NICE_TIME_FORMAT), http_method, uri.to_s, http_version]
|
75
164
|
str
|
76
165
|
end
|
77
166
|
|
167
|
+
def cookies
|
168
|
+
return [] if !header.is_a?(Hash) || header[:Cookie].empty?
|
169
|
+
header[:Cookie]
|
170
|
+
end
|
171
|
+
|
78
172
|
end
|
79
173
|
|
80
|
-
class HTTPResponse <
|
174
|
+
class HTTPResponse < Storable
|
81
175
|
attr_reader :raw_data
|
82
176
|
|
83
177
|
field :time => DateTime
|
@@ -91,13 +185,16 @@ module Stella::Data
|
|
91
185
|
|
92
186
|
def initialize(raw_data=nil)
|
93
187
|
@raw_data = raw_data
|
94
|
-
|
95
|
-
|
96
|
-
|
188
|
+
parse(@raw_data)
|
189
|
+
end
|
190
|
+
|
191
|
+
def parse(raw)
|
192
|
+
return unless raw
|
193
|
+
@status, @http_version, @message, @header, @body = HTTPUtil::parse_http_response(raw)
|
97
194
|
end
|
98
195
|
|
99
196
|
def has_body?
|
100
|
-
|
197
|
+
!@body.nil? && !@body.empty?
|
101
198
|
end
|
102
199
|
def has_request?
|
103
200
|
false
|
@@ -106,17 +203,42 @@ module Stella::Data
|
|
106
203
|
false
|
107
204
|
end
|
108
205
|
|
206
|
+
|
109
207
|
def body
|
110
208
|
return nil unless @body
|
111
|
-
#
|
112
|
-
|
209
|
+
#TODO: Move to HTTPResponse::Body.to_s
|
210
|
+
if is_binary?
|
211
|
+
"[skipping binary content]"
|
212
|
+
elsif is_gzip?
|
213
|
+
#require 'zlib'
|
214
|
+
#Zlib::Inflate.inflate(@body)
|
215
|
+
"[skipping gzip content]"
|
216
|
+
else
|
217
|
+
@body
|
218
|
+
end
|
113
219
|
end
|
114
220
|
|
115
|
-
def
|
221
|
+
def headers
|
116
222
|
headers = []
|
117
223
|
header.each_pair do |n,v|
|
118
|
-
headers <<
|
224
|
+
headers << [n.to_s.gsub('_', '-'), v[0]]
|
119
225
|
end
|
226
|
+
headers
|
227
|
+
end
|
228
|
+
|
229
|
+
def is_binary?
|
230
|
+
(!is_text?) == true
|
231
|
+
end
|
232
|
+
|
233
|
+
def is_text?
|
234
|
+
(!header[:Content_Type].nil? && (header[:Content_Type][0].is_a? String) && header[:Content_Type][0][/text/] != nil)
|
235
|
+
end
|
236
|
+
|
237
|
+
def is_gzip?
|
238
|
+
(!header[:Content_Encoding].nil? && (header[:Content_Encoding][0].is_a? String) && header[:Content_Encoding][0][/gzip/] != nil)
|
239
|
+
end
|
240
|
+
|
241
|
+
def inspect
|
120
242
|
str = "HTTP/%s %s (%s)" % [@http_version, @status, @message]
|
121
243
|
str << $/ + headers.join($/)
|
122
244
|
str << $/ + $/ + body if body
|
@@ -127,5 +249,11 @@ module Stella::Data
|
|
127
249
|
str = "%s: HTTP/%s %s (%s)" % [time.strftime(NICE_TIME_FORMAT), @http_version, @status, @message]
|
128
250
|
str
|
129
251
|
end
|
252
|
+
|
253
|
+
|
254
|
+
def cookies
|
255
|
+
return [] unless header.is_a?(Array) && !header[:Set_Cookie].empty?
|
256
|
+
header[:Set_Cookie]
|
257
|
+
end
|
130
258
|
end
|
131
259
|
end
|