cloudscale-benchmark 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ require "yaml/store"
2
+ require "logger"
3
+ require "set"
4
+ require "#{File.dirname(__FILE__)}/../constants/agent_instance_store"
5
+ require "#{File.dirname(__FILE__)}/../rest/rest_client"
6
+
7
+ ##
8
+ #
9
+ # @author Johannes Hiemer, cloudscale.
10
+ #
11
+ ##
12
+ module Cloudscale
13
+ module Plugins
14
+ class Plugin
15
+
16
+ attr_accessor :log, :plugins, :client
17
+ @plugins = Set.new
18
+
19
+ def self.log
20
+ @log = Logger.new(STDOUT)
21
+ end
22
+
23
+ def initialize()
24
+ @client = RestClientWrapper.instance
25
+ end
26
+
27
+ def self.plugins
28
+ @plugins
29
+ end
30
+
31
+ def self.inherited(klass)
32
+ @plugins << klass
33
+ #log.debug("Initialize for " << klass.to_s)
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,48 @@
1
+ require "optparse"
2
+ require "logger"
3
+ require "fsdb"
4
+ require "#{File.dirname(__FILE__)}/preop"
5
+
6
+ ##
7
+ #
8
+ # @author Johannes Hiemer, cloudscale.
9
+ #
10
+ ##
11
+ module Cloudscale
12
+ module Plugins
13
+ class PluginPreop < Plugins::Preop
14
+ include Singleton
15
+
16
+ @@options = {
17
+ :numberOfRuns => {
18
+ :argument => "--numberOfRuns",
19
+ :description => "The total numnber of runs for each test",
20
+ :required => false,
21
+ :value => 1
22
+ },
23
+ :development => {
24
+ :argument => "--development",
25
+ :description => "Development option for the runtime environment",
26
+ :required => false,
27
+ :value => false
28
+ },
29
+ :op_timeout => {
30
+ :argument => "--op_timeout",
31
+ :description => "Operation timeout for the test execution",
32
+ :required => false,
33
+ :value => 30
34
+ }
35
+ }
36
+
37
+ def options
38
+ @@options
39
+ end
40
+
41
+ def initialize
42
+ self.init
43
+ # Check prereq
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,46 @@
1
+ ##
2
+ #
3
+ # @author Johannes Hiemer, cloudscale.
4
+ #
5
+ ##
6
+ module Cloudscale
7
+ module Plugins
8
+ class Preop
9
+
10
+ def init
11
+ @plugin_settings_db = FSDB::Database.new("#{File.dirname(__FILE__)}/../../store/plugin")
12
+ init_options()
13
+ end
14
+
15
+ def set_option_value(key, val)
16
+ options[key.to_sym][:value] = val
17
+ end
18
+
19
+ def get_option(key)
20
+ options[key.to_sym]
21
+ end
22
+
23
+ def get_option_value(key)
24
+ options[key.to_sym][:value] #|| @plugin_settings_db[key.to_s]
25
+ end
26
+
27
+ def init_options
28
+ @plugin_settings_db.fetch.each do | key |
29
+ options[key.to_sym][:value] = @plugin_settings_db[key]
30
+ end
31
+ end
32
+
33
+ def save_options
34
+ options.each do | key, value |
35
+ @plugin_settings_db[key.to_s] = value[:value].to_s
36
+ end
37
+ end
38
+
39
+ def clear_options
40
+ @plugin_settings_db.fetch.each do | element |
41
+ @plugin_settings_db.delete(element)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,200 @@
1
+ require "yaml"
2
+ require "json"
3
+ require "rest_client"
4
+ require "singleton"
5
+ require "#{File.dirname(__FILE__)}/rest_client_helper"
6
+
7
+ ##
8
+ #
9
+ # @author Johannes Hiemer, cloudscale.
10
+ #
11
+ ##
12
+ class RestClientWrapper < RestClientHelper
13
+ include Singleton
14
+
15
+ attr_accessor :endpoint, :key, :token, :header
16
+
17
+ def load_hash()
18
+ begin
19
+ YAML.load(File.read("#{File.dirname(__FILE__)}/../store/rest/settings.yml"))
20
+ rescue
21
+ return nil
22
+ end
23
+ end
24
+
25
+ def initialize
26
+ if (endpoint == nil && key == nil && token == nil)
27
+ hash = load_hash()
28
+ end
29
+ @endpoint = hash["endpoint"]
30
+ @key = hash["key"]
31
+ @token = hash["token"]
32
+ @header = {
33
+ :key => key,
34
+ :token => token,
35
+ 'Content-Type' => 'application/json',
36
+ 'Accept' => 'application/json'
37
+ }
38
+ end
39
+
40
+ def list_with_params(entity, params)
41
+ uri = uri_with_params(entity, params)
42
+ load(uri)
43
+ end
44
+
45
+ def list(entity)
46
+ uri = uri(entity)
47
+ load(uri)
48
+ end
49
+
50
+ def get(entity, id)
51
+ uri = uriWithId(entity, id)
52
+ load(uri)
53
+ end
54
+
55
+ def load(uri)
56
+ RestClient.get(uri, header) { | response, request, result |
57
+ case response.code
58
+ when 200
59
+ return JSON.parse(response.body)
60
+ else
61
+ puts request.to_yaml
62
+ puts response.code
63
+ puts response.body
64
+ end
65
+ }
66
+ end
67
+
68
+ def searchOne(entity, method, params)
69
+ searchQuery = String::new(uri(entity) + '/search/' + method + '?')
70
+
71
+ params.each { | key, value|
72
+ searchQuery += key.to_s + '=' + value.to_s + '&'
73
+ }
74
+
75
+ RestClient.get(searchQuery, header) { | response, request, result |
76
+ case response.code
77
+ when 200
78
+ responseBody = JSON.parse(response.body)
79
+ if (responseBody["content"].length == 1)
80
+ return responseBody["content"][0]
81
+ end
82
+ else
83
+ puts request.to_yaml
84
+ puts response.code
85
+ puts response.body
86
+ end
87
+ }
88
+ end
89
+
90
+ def searchAny(entity, method, params)
91
+ searchQuery = String::new(uri(entity) + '/search/' + method + '?')
92
+
93
+ params.each { | key, value|
94
+ searchQuery += key.to_s + '=' + value.to_s + '&'
95
+ }
96
+
97
+ RestClient.get(searchQuery, header) { | response, request, result |
98
+ case response.code
99
+ when 200
100
+ return JSON.parse(response.body)
101
+ else
102
+ puts request.to_yaml
103
+ puts response.code
104
+ puts response.body
105
+ end
106
+ }
107
+ end
108
+
109
+ def post(entity, value)
110
+
111
+ if (value.is_a?(Object) || value.is_a?(Hash))
112
+ hash = value.to_dh
113
+ end
114
+
115
+ RestClient.post(uri(entity), hash.to_json, header) { | response, request, result |
116
+ case response.code
117
+ when 200, 201
118
+ if (response.body != nil && response.body.length > 2)
119
+ return JSON.parse(response.body)
120
+ end
121
+ else
122
+ puts request.to_yaml
123
+ puts response.code
124
+ puts response.body
125
+ end
126
+ }
127
+ end
128
+
129
+ def put(entity, id, value)
130
+ id = id.to_s.gsub('{?projection}','')
131
+
132
+ if (value.is_a?(Object) || value.is_a?(Hash))
133
+ hash = value.to_dh
134
+ end
135
+
136
+ RestClient.put(uriWithId(entity, id), hash.to_json, header) { | response, request, result |
137
+ case response.code
138
+ when 200, 204
139
+ if (response.body != nil && response.body.length > 2)
140
+ return JSON.parse(response.body)
141
+ end
142
+ else
143
+ puts request.to_yaml
144
+ puts response.code
145
+ puts response.body
146
+ end
147
+ }
148
+ end
149
+
150
+ def patch(entity, id, value)
151
+ id = id.to_s.gsub('{?projection}','')
152
+
153
+ if (value.is_a?(Object) || value.is_a?(Hash))
154
+ hash = value.to_dh
155
+ end
156
+
157
+ RestClient.patch(uriWithId(entity, id), hash.to_json, header) { | response, request, result |
158
+ case response.code
159
+ when 200, 204
160
+ if (response.body != nil && response.body.length > 2)
161
+ return JSON.parse(response.body)
162
+ end
163
+ else
164
+ puts request.to_yaml
165
+ puts response.code
166
+ puts response.body
167
+ end
168
+ }
169
+ end
170
+
171
+ def delete(entity, id)
172
+ id = id.to_s.gsub('{?projection}','')
173
+
174
+ RestClient.delete(uriWithId(entity, id), header) { | response, request, result |
175
+ case response.code
176
+ when 200, 204
177
+ else
178
+ puts response.code
179
+ end
180
+ }
181
+ end
182
+
183
+ def customDelete(entity, method, params)
184
+ id = id.to_s.gsub('{?projection}','')
185
+
186
+ query = String::new(uri(entity) + '/' + method + '?')
187
+
188
+ params.each { | key, value|
189
+ query += key.to_s + '=' + value.to_s + '&'
190
+ }
191
+ RestClient.delete(query, header) { | response, request, result |
192
+ case response.code
193
+ when 200
194
+ else
195
+ puts response.code
196
+ end
197
+ }
198
+ end
199
+
200
+ end
@@ -0,0 +1,65 @@
1
+
2
+ ##
3
+ #
4
+ # @author Johannes Hiemer, cloudscale.
5
+ #
6
+ ##
7
+ class RestClientHelper
8
+
9
+ def uri(entity)
10
+ if (!endpoint.to_s.end_with? '/')
11
+ @endpoint << '/'
12
+ end
13
+ String::new(@endpoint + entity)
14
+ end
15
+
16
+ def uri_with_params(entity, params)
17
+ if (!endpoint.to_s.end_with? '/')
18
+ @endpoint << '/'
19
+ end
20
+
21
+ uri = String::new(@endpoint + entity)
22
+ if (params.is_a?(Hash))
23
+ uri << '?'
24
+ params.each { | key, value|
25
+ uri += key.to_s + '=' + value.to_s + '&'
26
+ }
27
+ end
28
+ return uri
29
+ end
30
+
31
+ def uriWithId(entity, id)
32
+ if (!endpoint.to_s.end_with? '/')
33
+ @endpoint << '/'
34
+ end
35
+ String::new(@endpoint + entity + '/' + id.to_s)
36
+ end
37
+
38
+ def self.load_entity_id(entity)
39
+ if (entity != nil && entity["links"].is_a?(Array))
40
+ entity["links"].each { | link |
41
+ if (link["rel"] == "self")
42
+ return link["href"][link["href"].rindex('/') + 1, link["href"].length]
43
+ end
44
+ }
45
+ end
46
+ end
47
+
48
+ def self.load_entity_ref(entity)
49
+ if (entity != nil && entity["links"].is_a?(Array))
50
+ entity["links"].each { | link |
51
+ if (link["rel"] == "self")
52
+ return link
53
+ end
54
+ }
55
+ end
56
+ end
57
+
58
+ def removeLinks(hash, key)
59
+ if (hash.key?(key))
60
+ hash.tap { | x |
61
+ x.delete(key)
62
+ }
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ agentId: 'e2FsZz1IUzI1NiwgdHlwPUNUfQ.e3Y9MCwgZD1EZWZhdWx0IFBob3Jvbml4IEFnZW50LiwgaWF0PTE0MDgyMDMzMTF9.0YnXvYkSvktnEARbFybGmHdfHxGy-fOOlEP9FfHm_oM'
@@ -0,0 +1,6 @@
1
+ ---
2
+ benchmarkAgent: http://serverhost:8080/service/benchmarkAgents/53ef7a2f4d1aae1096944223
3
+ agentInstanceId: 743891af722a8c1bff7d697aaa256179
4
+ customer: 60
5
+ server: benchy
6
+ started: 1410269795000
@@ -0,0 +1 @@
1
+ I" true:EF
@@ -0,0 +1 @@
1
+ I"1:EF
@@ -0,0 +1 @@
1
+ I"30:EF
@@ -0,0 +1,4 @@
1
+ ---
2
+ endpoint: http://serverhost:8080/service
3
+ key: monitoring
4
+ token: e2FsZz1IUzI1NiwgdHlwPUNUfQ.e3Y9MCwgZD1tb25pdG9yaW5nLCBpYXQ9MTQwNDc1NzMyNH0.rG0biCuH_-X1vulEr19H2m42i4DGRR8PGwgXastyk3Q
@@ -0,0 +1,9 @@
1
+ ---
2
+ engine: phoronix
3
+ executable: /usr/bin/phoronix-test-suite
4
+ params:
5
+ env:
6
+ numberOfRunsVar: FORCE_TIMES_TO_RUN
7
+ result:
8
+ path: /tmp/cloudscale/test-results/
9
+ suffix: xml
metadata ADDED
@@ -0,0 +1,229 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloudscale-benchmark
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Johannes Hiemer
8
+ - Joerg Gottschlich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest_client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.7'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.7'
28
+ - !ruby/object:Gem::Dependency
29
+ name: OptionParser
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '0.5'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '0.5'
42
+ - !ruby/object:Gem::Dependency
43
+ name: hashable
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '0.1'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '0.1'
56
+ - !ruby/object:Gem::Dependency
57
+ name: fsdb
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '0.7'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.7'
70
+ - !ruby/object:Gem::Dependency
71
+ name: popen4
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.1.2
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 0.1.2
84
+ - !ruby/object:Gem::Dependency
85
+ name: json
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 1.8.1
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: 1.8.1
98
+ - !ruby/object:Gem::Dependency
99
+ name: http
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ version: 0.6.2
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: 0.6.2
112
+ - !ruby/object:Gem::Dependency
113
+ name: xml-simple
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: 1.1.4
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.1.4
126
+ - !ruby/object:Gem::Dependency
127
+ name: bundler
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ~>
131
+ - !ruby/object:Gem::Version
132
+ version: '1.7'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ~>
138
+ - !ruby/object:Gem::Version
139
+ version: '1.7'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rake
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ~>
145
+ - !ruby/object:Gem::Version
146
+ version: '10.0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ version: '10.0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: rspec
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ~>
159
+ - !ruby/object:Gem::Version
160
+ version: '2.14'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ~>
166
+ - !ruby/object:Gem::Version
167
+ version: '2.14'
168
+ description: A Benchmarking Client for Cloud Infrastructure provided by cloudscale.de
169
+ email:
170
+ - jhiemer@cloudscale.de
171
+ - jgottschlich@cloudscale.de
172
+ executables:
173
+ - prepare_benchmark.sh
174
+ - run_benchmark.sh
175
+ extensions: []
176
+ extra_rdoc_files: []
177
+ files:
178
+ - bin/prepare_benchmark.sh
179
+ - bin/run_benchmark.sh
180
+ - lib/cloudscale/benchmark/agent/init.rb
181
+ - lib/cloudscale/benchmark/model/agent/benchmark_agent_instance.rb
182
+ - lib/cloudscale/benchmark/model/benchmark/benchmark_run.rb
183
+ - lib/cloudscale/benchmark/model/benchmark/benchmark_run_result.rb
184
+ - lib/cloudscale/benchmark/model/benchmark/benchmark_run_result_value.rb
185
+ - lib/cloudscale/benchmark/version.rb
186
+ - lib/cloudscale/benchmark.rb
187
+ - lib/cloudscale/constants/agent_instance_store.rb
188
+ - lib/cloudscale/constants/agent_store.rb
189
+ - lib/cloudscale/plugins/phoronix/phoronix_bulk_execution.rb
190
+ - lib/cloudscale/plugins/plugin.rb
191
+ - lib/cloudscale/plugins/preops/plugin_preop.rb
192
+ - lib/cloudscale/plugins/preops/preop.rb
193
+ - lib/cloudscale/rest/rest_client.rb
194
+ - lib/cloudscale/rest/rest_client_helper.rb
195
+ - lib/cloudscale/store/agent/agent.yml
196
+ - lib/cloudscale/store/agent/agent_instance.yml
197
+ - lib/cloudscale/store/plugin/development
198
+ - lib/cloudscale/store/plugin/numberOfRuns
199
+ - lib/cloudscale/store/plugin/op_timeout
200
+ - lib/cloudscale/store/rest/settings.yml
201
+ - lib/cloudscale/store/settings/phoronix.yml
202
+ - LICENSE.txt
203
+ - README.md
204
+ homepage: http://www.cloudscale.de
205
+ licenses:
206
+ - MIT
207
+ metadata: {}
208
+ post_install_message: Please run bin/prepare_benchmark.sh to setup benchmarking on
209
+ this machine.
210
+ rdoc_options: []
211
+ require_paths:
212
+ - lib
213
+ required_ruby_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - '>='
216
+ - !ruby/object:Gem::Version
217
+ version: '0'
218
+ required_rubygems_version: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ requirements: []
224
+ rubyforge_project:
225
+ rubygems_version: 2.0.14
226
+ signing_key:
227
+ specification_version: 4
228
+ summary: Cloud Benchmarking Agent of cloudscale.de
229
+ test_files: []