cloudscale-benchmark 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13111c8e4fc2d7f79ed5d8d63fbdebb29450905c
4
+ data.tar.gz: c3f62bd47e5deaf6fd2ad85511e34ace30b4d1e4
5
+ SHA512:
6
+ metadata.gz: 2401543977adc58ebdf08018f30090aa48f8876188075bd8cbf0951fa68db06badc42634bc20017119143704705970f1ba13234e21d062908549ce8282160909
7
+ data.tar.gz: 0bf2d66a95d96255fe28ae774259ed42d40f1b5665d54bcb65821501dc711e972baff3ffb8ebeee51858c1feaa23e1e4f203087e1e90198213e3246acee20935
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jörg Gottschlich
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Cloudscale::Benchmark
2
+
3
+ Benchmarking Client for the cloudscale Cloud Evaluation Platform
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cloudscale-benchmark'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install cloudscale-benchmark
20
+
21
+ To prepare system for benchmark execution, run bin/prepare_benchmark.sh.
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/cloudscale-benchmark/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
@@ -0,0 +1,193 @@
1
+ #!/bin/bash
2
+ ## prepare_benchmark.sh - Script to setup environment for benchmarking client
3
+ ## (C) Cloudscale, jgottschlich@cloudscale.de
4
+ ## Steps:
5
+ ## 1) Prepare environment, install dependencies for PTS & Java
6
+ ## 2) Download & install PTS
7
+ ## 3) Execute Benchmark Client (Java)
8
+ ## Usage:
9
+ ## prepare_benchmark.sh [instanceId] [token]
10
+ ## [instanceId] Id of the specific VM instance on which the client is executed
11
+ ## [token] security token to enable access to the Cloudscale REST API
12
+ ## Needs superuser access to install dependencies.
13
+
14
+ # must be run as root
15
+ if [ $EUID -ne 0 ]; then
16
+ echo "This script must be run as root." > /dev/stderr
17
+ exit 1
18
+ fi
19
+
20
+ TMPDIR="/tmp/phoronix-test-suite"
21
+ REPO="http://repository.cloudscale.de"
22
+
23
+ # check parameters
24
+ if [ -z "$1" ]; then
25
+ echo "Usage: prepare_benchmark.sh [instanceId]"
26
+ exit 1 # return error
27
+ fi
28
+ INSTANCEID="$1"
29
+
30
+ echo "*** PREPARE ENVIRONMENT ***"
31
+
32
+ # Detects which OS and if it is Linux then it will detect which Linux Distribution.
33
+ detectedDistro="Unknown"
34
+
35
+ OS=`uname -s`
36
+ REV=`uname -r`
37
+ MACH=`uname -m`
38
+
39
+ GetVersionFromFile()
40
+ {
41
+ VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `
42
+ }
43
+
44
+ if [ "${OS}" = "SunOS" ] ; then
45
+ OS=Solaris
46
+ ARCH=`uname -p`
47
+ OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
48
+ elif [ "${OS}" = "AIX" ] ; then
49
+ OSSTR="${OS} `oslevel` (`oslevel -r`)"
50
+ elif [ "${OS}" = "Linux" ] ; then
51
+ KERNEL=`uname -r`
52
+ if [ -f /etc/redhat-release ] ; then
53
+ DIST='RedHat'
54
+ PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
55
+ REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
56
+ elif [ -f /etc/SuSE-release ] ; then
57
+ DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
58
+ REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
59
+ elif [ -f /etc/mandrake-release ] ; then
60
+ DIST='Mandrake'
61
+ PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
62
+ REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
63
+ elif [ -f /etc/debian_version ] ; then
64
+ DIST="Debian `cat /etc/debian_version`"
65
+ REV=""
66
+
67
+ fi
68
+ if [ -f /etc/UnitedLinux-release ] ; then
69
+ DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
70
+ fi
71
+
72
+ OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"
73
+ detectedDistro="${DIST}"
74
+ fi
75
+
76
+
77
+ echo "Found the following Operation System version:"
78
+ echo ${OSSTR}
79
+
80
+ detectedDistro=`echo $detectedDistro | tr "[:upper:]" "[:lower:]"`
81
+
82
+ echo "Running cloudscale benchmark executor on ${detectedDistro} with identifier: ${INSTANCEID}"
83
+
84
+ # set functions to be used
85
+ debInst()
86
+ {
87
+ dpkg-query -Wf'${db:Status-abbrev}' "${1}" 2>/dev/null | grep -q '^i'
88
+ }
89
+
90
+ ## INSTALL DEPENDENCIES
91
+ echo "*** INSTALL DEPENDENCIES ***"
92
+ if [[ ${detectedDistro} =~ .*debian.* ]];
93
+ then
94
+ if debInst "sudo"; then
95
+ echo 'sudo is installed'
96
+ else
97
+ echo 'sudo is not installed, trying without sudo to install. Otherwise please install sudo first'
98
+ apt-get -y install sudo
99
+ fi
100
+
101
+ # update
102
+ sudo apt-get update
103
+
104
+ # install all necessary packages
105
+ sudo apt-get -fy install locales gcc php5-cli php5-gd php5-json openjdk-7-jre
106
+
107
+ # Installing phoronix-test-suite
108
+ #apt-get -y install phoronix-test-suite
109
+ echo "*** INSTALLING PHORONIX FROM INTERNET ***"
110
+ wget -q -O /tmp/phoronixsuite.deb http://phoronix-test-suite.com/releases/repo/pts.debian/files/phoronix-test-suite_4.8.2_all.deb
111
+ dpkg -i /tmp/phoronixsuite.deb
112
+ fi
113
+
114
+ ## FIXME: clean up locale preparation:
115
+
116
+ #echo 'RUNNING: Trying locale-check'
117
+
118
+ #SEARCHFOR="en_US.UTF-8"
119
+ #if [[ $(grepExistence) == 0 ]]; then
120
+ # sudo echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
121
+ # update-locale en_US.UTF-8
122
+ # locale-gen en_US.UTF-8
123
+ # update-locale en_US.UTF-8
124
+ # bash benchmark-executor.sh
125
+ # exit
126
+ #else
127
+ # echo "en_US UTF-8 already activated"
128
+ #fi
129
+
130
+ #echo 'SUCCESS: locales checked'
131
+
132
+ # Reconfiguring language settings (only relevant for amazon currently)
133
+
134
+ #locale-gen en_US.UTF-8
135
+ #export LANGUAGE=en_US.UTF-8
136
+ #export LANG=en_US.UTF-8
137
+ #update-locale en_US.UTF-8
138
+ #export LC_ALL=en_US.UTF-8
139
+ # dpkg-reconfigure locales
140
+
141
+ # ubuntu way to clean locales... develop to be more x-plattform later
142
+ echo "*** UPDATING LOCALES ***"
143
+ sudo apt-get -yf install language-pack-en-base
144
+ sudo dpkg-reconfigure locales
145
+
146
+
147
+ ## END OF LOCALE CLEANUP
148
+
149
+
150
+ # Prepare environment
151
+ echo "*** Creating temporary directory ***"
152
+ mkdir -p "$TMPDIR"
153
+ chmod 777 "$TMPDIR"
154
+
155
+ echo -n "---- HOME directory is "
156
+ echo ~
157
+
158
+ # download and execute benchmark client
159
+ echo "*** DOWNLOAD PHORONIX USER CONFIG ***"
160
+ mkdir -p ~/.phoronix-test-suite/
161
+ wget "$REPO/phoronix/user-config.xml" -O ~/.phoronix-test-suite/user-config.xml
162
+ wget "$REPO/phoronix/core.pt2so" -O ~/.phoronix-test-suite/core.pt2so
163
+
164
+ # PTS deals with home directory in a strange way preventing this batch to run smoothly
165
+ # (effective user home vs. login user home)
166
+ # The problem is that the license file core.pt2so contains information if the T&C have been
167
+ # accepted. If this is missing the client asks the user to accept the T&C and hence blocks the run
168
+ # The next block fixes problems with different home directories of administrative user and root
169
+ # UPDATE: PTS seems to use two different methods of accessing the home directory - and starts
170
+ # prompting for the T&Cs again if the right core.pt2so is not present => link it to /root
171
+ echo "*** Linking ~/.phoronix-test-suite to /root ***"
172
+ if [ ~ != "/root" ] ; then
173
+ rm -r /root/.phoronix-test-suite
174
+ ln -sf ~/.phoronix-test-suite /root
175
+ fi
176
+
177
+
178
+ ##### TODO: HIER DEN RUBY-CLIENT STARTEN UND SKRIPT BEENDEN
179
+ ##### client mit git aus repo holen und dann starten
180
+
181
+ echo "SO UND JETZT SOLLTE DER CLIENT DURCHLAUFEN :-)"
182
+ # bundle install ausführen
183
+ # ruby ....../benchmark.rb start [token]
184
+
185
+ #echo "*** DOWNLOAD BENCHMARK CLIENT ***"
186
+ #wget http://repository.cloudscale.de/benchmark-client.jar -O /tmp/benchmark-client.jar
187
+ #echo "*** START CLIENT ***"
188
+ #java -DinstanceId="$INSTANCEID" -jar /tmp/benchmark-client.jar 2>&1
189
+
190
+
191
+
192
+
193
+
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ ruby ../lib/cloudscale/benchmark.rb start $@
4
+
@@ -0,0 +1,74 @@
1
+ require "yaml"
2
+ require "logger"
3
+ require "securerandom"
4
+ require "#{File.dirname(__FILE__)}/../model/agent/benchmark_agent_instance"
5
+ require "#{File.dirname(__FILE__)}/../../constants/agent_store"
6
+ require "#{File.dirname(__FILE__)}/../../rest/rest_client"
7
+
8
+ ##
9
+ #
10
+ # @author Johannes Hiemer, cloudscale.
11
+ #
12
+ ##
13
+ module Cloudscale
14
+ module Benchmark
15
+ class Init
16
+ attr_accessor :log, :customer, :agentInstanceId, :server, :client
17
+ def initialize()
18
+ @log = Logger.new(STDOUT)
19
+ @customer = 60
20
+
21
+ @server = Socket.gethostname
22
+ @agentInstanceId = SecureRandom.hex
23
+
24
+ @client = RestClientWrapper.instance
25
+
26
+ puts " "
27
+ puts "Running preflight verification for cloudscale benchmarking agent"
28
+
29
+ stored_agent_instance = Constants::AgentInstance.load
30
+ stored_agent = Constants::Agent.load
31
+
32
+ if (stored_agent == nil)
33
+ raise "You did not provide any valid Agent file under /store/agent/agent.store."
34
+ end
35
+
36
+ agent = client.searchOne('benchmarkAgents', 'findByAgentId', { :agentId => stored_agent["agentId"] })
37
+
38
+ if (agent == nil)
39
+ raise "No agent registered yet. It is not allowed to connect this agent instance to cloudscale monitoring."
40
+ end
41
+
42
+ if (stored_agent_instance && stored_agent_instance != nil)
43
+ agent_instance = client.searchOne('benchmarkAgentInstances',
44
+ 'findByAgentInstanceId', { :id => stored_agent_instance["agentInstanceId"] })
45
+ end
46
+
47
+ if (agent_instance == nil)
48
+ puts "No Instance of this agent was started previously, starting cloudscale benchmarking agent for the first, registering..."
49
+
50
+ agent_instance = Benchmarking::BenchmarkAgentInstance.new(RestClientWrapper.load_entity_ref(agent)["href"],
51
+ agentInstanceId, customer, server, Time.now.to_i * 1000)
52
+
53
+ client.post('benchmarkAgentInstances', agent_instance)
54
+ Constants::AgentInstance.create(agent_instance.to_h)
55
+ else
56
+ puts " Instance has been started previously, loading settings and existing data... \n\n"
57
+
58
+ @agentInstanceId = agent_instance["agentInstanceId"]
59
+ agent_instance["lastInitialization"] = Time.now.to_i * 1000
60
+ agent_instance["benchmarkAgent"] = RestClientWrapper.load_entity_ref(agent)["href"]
61
+
62
+ client.put('benchmarkAgentInstances', RestClientWrapper.load_entity_id(agent_instance), agent_instance)
63
+ end
64
+
65
+ end
66
+
67
+ def agent_instance_id
68
+ return agentInstanceId
69
+ end
70
+
71
+ end
72
+
73
+ end
74
+ end
@@ -0,0 +1,32 @@
1
+ require "hashable"
2
+
3
+ ##
4
+ #
5
+ # @author Johannes Hiemer, cloudscale.
6
+ #
7
+ ##
8
+ module Cloudscale
9
+ module Benchmark
10
+
11
+ class BenchmarkAgentInstance
12
+ include Hashable
13
+
14
+ attr_accessor :benchmarkAgent, :agentInstanceId, :customer, :server, :started
15
+
16
+ def initialize(benchmarkAgent, agentInstanceId, customer, server, started)
17
+ @benchmarkAgent = benchmarkAgent
18
+ @agentInstanceId = agentInstanceId
19
+ @customer = customer
20
+ @server = server
21
+ @started = started
22
+ end
23
+
24
+ def to_h
25
+ hash = {}
26
+ instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
27
+ return hash
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,67 @@
1
+ require "hashable"
2
+
3
+ ##
4
+ #
5
+ # @author Jörg Gottschlich, cloudscale.
6
+ #
7
+ ##
8
+ module Cloudscale
9
+ module Benchmark
10
+ class BenchmarkRun
11
+ include Hashable
12
+
13
+ attr_accessor :id, :benchmarkInstance, :benchmarkTestSuite, :benchmarkTest, :scheduled, :started, :stopped, :batchName, :sequence, :status, :statusMessage
14
+
15
+ def initialize(h)
16
+ h.each {|k,v| instance_variable_set("@#{k}",v)}
17
+ end
18
+
19
+ def to_h
20
+ hash = {}
21
+ instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
22
+ return hash
23
+ end
24
+
25
+ # @see de.cloudscale.model.nosql.constants.benchmark.BenchmarkRunStatusType.java
26
+ def running!(msg)
27
+ @status = "running"
28
+ if (msg)
29
+ @statusMessage = msg
30
+ end
31
+ @started = Time.now.utc.to_s
32
+ end
33
+
34
+ def succeed!(msg)
35
+ @status = "succeeded"
36
+ if (msg)
37
+ @statusMessage = msg
38
+ end
39
+ @stopped = Time.now.utc.to_s
40
+ end
41
+
42
+ def failed!(msg)
43
+ @status = "failed"
44
+ if (msg)
45
+ @statusMessage = msg
46
+ end
47
+ @stopped = Time.now.utc.to_s
48
+ end
49
+
50
+ def no_result!(msg)
51
+ @status = "no results"
52
+ if (msg)
53
+ @statusMessage = msg
54
+ end
55
+ @stopped = Time.now.utc.to_s
56
+ end
57
+
58
+ def get_status_hash
59
+ hash = {}
60
+ hash["status"] = @status
61
+ hash["statusMessage"] = @statusMessage
62
+ hash
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,32 @@
1
+ require "hashable"
2
+
3
+ ##
4
+ #
5
+ # @author Johannes Hiemer, cloudscale.
6
+ #
7
+ ##
8
+ module Cloudscale
9
+ module Benchmark
10
+ class BenchmarkRunResult
11
+ include Hashable
12
+
13
+ attr_accessor :benchmarkRun, :rawBenchmarkOutput, :benchmarkRunResultValues, :ip_address, :hostname
14
+
15
+ def initialize(benchmarkRun)
16
+ @benchmarkRun = benchmarkRun
17
+ @benchmarkRunResultValues = Array.new
18
+ end
19
+
20
+ def to_h
21
+ hash = {}
22
+ instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
23
+ return hash
24
+ end
25
+
26
+ def pushResultValue(benchmarkRunResultValue)
27
+ @benchmarkRunResultValues.push(benchmarkRunResultValue)
28
+ end
29
+
30
+ end
31
+ end
32
+ end