The Chef Cookbooks within this repository install and configure benchmarks that are aimed to be used with Cloud WorkBench.
- CWB Server: https://github.com/sealuzh/cloud-workbench
- CWB Cookbook (Chef): https://github.com/sealuzh/cwb-benchmarks/tree/master/cwb
- CWB Client (RubyGem): https://github.com/sealuzh/cwb
- Docs: http://www.rubydoc.info/gems/cwb/
- Cwb::Client: http://www.rubydoc.info/gems/cwb/Cwb/Client
- CWB Benchmark Examples used in Papers
General conventions about Providers
- Go to your CWB-server
http://cwb-server.io/benchmark_definitions/new
(i.e., BENCHMARK > Definitions > Create New Benchmark) - Chose a
Name
and clickCreate New Benchmark
- Click
Start Execution
and confirm the popup dialog.
- Open a CWB benchmark definition
- Click
Create New Metric Definition
or edit an existing one (right sidebar) - Fill in
Name=execution_time
,Unit=seconds
,Scale type=Ratio
, and clickCreate Metric Definition
NOTE: CWB now automatically creates new metric definitions whenever a new metric instance is submitted.
- Within your benchmark definition, click
Create Schedule
- Enter your Cron expression (e.g.,
* 0,12 * * *
for midnight and lunchtime every day) and clickCreate Schedule
- Don't forget to deactivate your schedules if you don't need them anymore! Review active schedules here http://cwb-server.io/benchmark_schedules?active=true
Precondition: You need to have access to a Cloud WorkBench Server. Find the installation instructions here: https://github.com/sealuzh/cwb-chef-repo#installation
-
Clone this repository
cd $HOME/git git clone https://github.com/sealuzh/cwb-benchmarks.git
-
Install the Chef Development Kit from https://downloads.chef.io/chef-dk/
-
Configure Chef
knife
and Berkshelfberks
tools-
Update
CHEF_SERVER
andREPO_ROOT
withinknife.rb
vim config/knife.rb
-
Copy
knife.rb
to~/.chef/knife.rb
andconfig.json
to~/.berkshelf/config.json
mkdir ~/.chef && cp knife.rb $HOME/.chef/knife.rb mkdir ~/.berkshelf && cp config.json $HOME/.berkshelf/config.json
-
Paste your Chef client key to
$HOME/.chef/cwb-user.pem
. Refer to https://github.com/sealuzh/cwb-chef-repo#installation how to create a Chef client if you have not created one yet.
-
-
Verify connection to Chef Server
knife client list
-
Copy the benchmark cookbook template (replace
benchmark-name
approprietly)cd $HOME/git/cwb-benchmarks cp -r _template benchmark-name cd benchmark-name
-
Update
metadata.rb
to use the samebenchmark-name
asname
vim metadata.rb
-
Update
benchmark-name
in the default recipevim recipes/default.rb
-
Write the
install
recipe that leverages Chef to install all the benchmark dependencies.- Search Chef docs: https://docs.chef.io/search.html
- Chef resources: http://docs.chef.io/resources.html
- Install a package (e.g., apt package on Debian system): https://docs.chef.io/resource_package.html
- Create file: https://docs.chef.io/resource_file.html
- Create file from cookbook: https://docs.chef.io/resource_cookbook_file.html
- Create file from template: https://docs.chef.io/resource_template.html
- Download file from URI: https://docs.chef.io/resource_remote_file.html
- Create directory: https://docs.chef.io/resource_directory.html
- Execute command: https://docs.chef.io/resource_execute.html
vim recipes/install.rb
-
Write the
configure
recipe that leverages Chef and the 'cwb' cookbook to configure the benchmark for Cloud WorkBench.- Use the
cwb_benchmark
resource to define your benchmark. - Rename the file approprietly
vim recipes/configure.rb mv files/default/benchmark_name.rb files/default/your_benchmark_name.rb
- Use the
-
Write your benchmark logic as Ruby code.
- Rename the class
BenchmarkName
using CamelCase (e.g., ssl-benchmark => SslBenchmark) - Your logic goes into the
execute
method hook
vim files/default/your_benchmark_name.rb
- Rename the class
-
(OPTIONAL) You might want to make your benchmark configurable via attributes that can be passed from the Vagrantfile in the CWB web interface.
- Access attributes in a Chef recipe via
node['benchmark-name']['attribute_1']
- Access attributes in the Ruby class via
@cwb.deep_fetch('benchmark-name', 'attribute_1')
- RECOMMENDATION: It is highly recommended to use the
benchmark-name
as the namespace for your attributes. NEVER use the reserved namespacescwb
orbenchmark
.
vim attributes/default.rb
- Access attributes in a Chef recipe via
-
(OPTIONAL) Update documentation and lint your cookbook.
- Foodcritic will lint your cookbook and discover errors early. Find docs here: http://acrmp.github.io/foodcritic/
vim README.md vim CHANGELOG.md foodcritic .
-
Upload your benchmark cookbook to the Chef Server
berks upload
will freeze your cookbook version => bump version (the--force
flag allows to overwrite already uploaded cookbooks)- Mac OS X users might get the following error:
Ridley::Errors::HTTPBadRequest: {"error":["Invalid element in array value of 'files'."]}
The workaround is to delete all.DS_STORE
files within the cookbook directory viafind . -name '*.DS_Store' -type f -delete
berks install && berks upload
-
Execute your benchmark
- Create a new
Benchmark Definition
via the CWB Web interface (analoguous toExecute a basic CLI Benchmark
) - Create the corresponding metrics for your benchmark definition (metric names must match)
- Create a new
CWB comes with an interactive debug mode to ease benchmark development in case your benchmark fails during preparation (i.e., provisioning) or execution.
Preparation: Click the Enable Keep Alive
button within your benchmark execution view.
- WARNING: Make sure you toggle this button once you're done because otherwise your VMs will live and cost FOREVER!
- CWB will automatically terminate VMs on failure after a configurable timout. Per default, you'll have 15 minutes time to enable the
Keep Alive
mode.
- Fix your Chef recipes by using the
Started preparing
log - Upload your fixed cookbooks via
berks upload
(overwrite existing versions with--force
) - Click the
Reprovision
button - Repeat step 1. - 3. until Chef completes successfully
- IMPORTANT: Click the
Disable Keep Alive
andAbort
buttons to release all resources once you're done.
-
SSH into the target VM
ssh ubuntu@TARGET_HOST -i $HOME/.ssh/cloud-benchmarking.pem
-
Check log files
cd /usr/local/cloud-benchmark cat start.log
-
Manually execute the benchmark or the entire benchmark suite
cwb execute benchmark-name/benchmark_name.rb cwb execute .
You can leverage the powerful pry shell to interactively debug your Chef recipes and your benchmark code (both are plain Ruby code).
Preparation: Set a breakpoint anywhere in your code. Make sure you upload your updated cookbook to the Chef Server.
require 'pry'
binding.pry
-
Reprovision via the CWB Web interface
-
SSH into the target VM
ssh ubuntu@TARGET_HOST -i $HOME/.ssh/cloud-benchmarking.pem
-
Navigate to chef directory
cd /etc/chef
-
Manually run the
chef-client
sudo chef-client -c client.rb -j dna.json
- Simply manually start the benchmark according to
Debug your benchmark > Failed on running
The cwb
command line utility allows for "smoke-testing" benchmarks locally. Chef node attributes can be mocked via a node.yml
YAML file.
Find examples in cli-benchmark
(local node.yml attribute config), sysbench
(RSpec unit testing), fio
(custom config file).
gem install cwb
cwb execute benchmark-name/benchmark_name.rb
More sophisticated integration testing can be achieved with Test Kitchen. Have a look at .kitchen.yml
in sysbench
, cli-benchmark
, and iperf
. In order to use this feature, you'll have to install Virtualbox, Vagrant, and the Vagrant plugin vagrant plugin install vagrant-omnibus
. An example integration test can be found in the cwb
cookbook.
Use the helper.rb
utility to resolve dependencies among your custom cookbooks:
-
Import the helper at the very beginning of your Berksfile
require_relative "../helper"
-
Specify your local cookbook dependencies within your Berksfile
local_cookbook "my-first-benchmark"