Code Monkey home page Code Monkey logo

jmeter-cookbook's Introduction

jmeter-cookbook

Release Build Status Code Coverage

Configures a system load-testing with Apache JMeter.

Requirements

There is a hard requirement of both Chef and Java for this package to install. We accomplish installing both of these by using additional dependency cookbooks which target the operating system family and install the appropriate software from either the package management system or a source URL. These settings are completely configurable using Chef JSON attributes with either the Chef Solo or Chef Zero commandline tools.

Cookbooks

The dependency cookbooks are resolved automatically using the Berkshelf commandline tool. They are also packaged so that Chef is able to work appropriately from the commandline. Each cookbook can be configured using the node attributes in the Chef JSON file.

The dependency cookbooks are:

Platforms

Since the dependencies for this really boil down to the ability to install the Omnibus Chef installer we are capable of supporting nearly any platform that has that built for it. But for testing purposes the approved platforms are locked at the latest, supported versions of both Enterprise Linux and Ubuntu Linux.

  • CentOS (RedHat) 7.0, 6.5, 5.8
  • Ubuntu 14.04, 12.04

Usage

This cookbook is designed to be flexible and light-weight. The goal was to allow for easy configuration of JMeter on the target host using a simple attributes file (JSON). Additionally, a Ruby language component is exposed so that custom test-plans can be written in wrapper cookbooks. These test plans can be deployed with software that Chef is configuring.

Packaging

Because this cookbook utilizes Berkshelf it is very easy to package up the cookbook, along with all of its dependencies, into a tarball which can be fetched over HTTP and fed into Chef Solo or Chef Zero.

bundle install --binstubs
bin/berks package

All of the cookbook dependencies must be packaged in order for the provisioning step to work properly. The easiest way to do this is using the Berkshelf package command which will create a tarball that can be uploaded to an HTTP endpoint. This endpoint can be fed into the chef-client on the commandline.

Test Plan

This cookbook embeds a Ruby plugin which allows for a test plan to be described easily inside of a recipe. A few test plans are included as files inside of this cookbook if you wish to run it manually. But inside of the default recipe we create a test plan against Google.

jmeter_plan 'google-search' do
  block do
    threads count: 10 do
      visit name: 'Google Search', url: 'http://google.com'
    end
  end
end

This lightweight resource provider in Chef will automatically generate a test plan that can be fed into JMeter on the command-line. All of the test plans will land in the directory specified by the node[:jmeter][:plan_dir] attribute. By default this is /etc/jmeter/plans.d.

Chef Zero

Using the Chef Client in local mode we can pass in attributes to configure the JMeter installation on the local machine. The dependency cookbooks can also be specified by a URL that is accessible from the host machine. The following command will install JMeter, with the attributes specified in the attributes.json file, and with the dependency cookbooks that were packaged by running the berks package command (above).

chef-client -z -j attributes.json -r http://blp.s3.amazonaws.com/jmeter-cookbooks.tar.gz

Maintainers

jmeter-cookbook's People

Contributors

ijin avatar johnbellone avatar nkadel-skyhook avatar sworisbreathing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jmeter-cookbook's Issues

Kitchen tests are failing (Nokogiri dependency)

In ab35970, kitchen converge fails due to not being able to install nokogiri, which is a transitive dependency of the ruby-jmeter gem (it's the age-old libxml2 problem).

I have a version of the cookbook which fixes this issue. Will open a PR shortly.

Jmeter cookbook fails with chefdk-0.10.0

Jmeter is failing using chefdk-0.10.0 and an up-to-date "poise cokbook", as shown below.

Recipe Compile Error in /var/chef-solo/berks-cookbooks/jmeter/libraries/plan.rb

NameError

uninitialized constant Chef::Resource::JmeterPlan::Poise

Cookbook Trace:

/var/chef-solo/berks-cookbooks/jmeter/libraries/plan.rb:11:in <class:JmeterPlan>' /var/chef-solo/berks-cookbooks/jmeter/libraries/plan.rb:10:inclass:Chef'
/var/chef-solo/berks-cookbooks/jmeter/libraries/plan.rb:9:in `<top (required)>'

Relevant File Content:

/var/chef-solo/berks-cookbooks/jmeter/libraries/plan.rb:

4: # License:: Apache 2.0
5: #
6: # Cookbook Name:: jmeter
7: # Library:: plan
8: #
9: class Chef
10: class Resource::JmeterPlan < Resource::RubyBlock
11>> include Poise
12:
13: def initialize(name, run_context=nil)
14: super
15: @resource_name = :jmeter_plan
16: end
17:
18: actions(:run)
19: attribute(:path, kind_of: String, default: lazy { node['jmeter']['plan_dir'] })
20: end

[2015-11-18T18:27:49-05:00] ERROR: Running exception handlers
[2015-11-18T18:27:49-05:00] ERROR: Exception handlers complete
[2015-11-18T18:27:49-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-11-18T18:27:49-05:00] ERROR: uninitialized constant Chef::Resource::JmeterPlan::Poise
[2015-11-18T18:27:49-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

jmeter_plan resource is broken

Looks like the refactoring of the jmeter_plan resource in ab35970 tried to make it a quasi-lwrp. Unfortunately (at least in Chef 12.4), Chef::Resource::RubyBlock doesn't inherit from Chef::Resource::LWRPBase, so that doesn't really work.

I'm close to having a fix for this and #9, and will submit a PR to fix them both.

Cookbook does not converge on ubuntu 10.04 or 14.04

I added the jmeter recipe to a roll and it fails to converge

Recipe: jmeter::default
  * directory[/etc/jmeter/plans.d] action create
    - create new directory /etc/jmeter/plans.d
  * package[jmeter] action install (skipped due to only_if)
  * ark[jmeter] action install
    * directory[/usr/local/jmeter-2.11] action create
      - create new directory /usr/local/jmeter-2.11
    * remote_file[/var/chef/cache/jmeter-2.11.tgz] action create
      - create new file /var/chef/cache/jmeter-2.11.tgz
      - update content in file /var/chef/cache/jmeter-2.11.tgz from none to 84a4ed
      (file sizes exceed 10000000 bytes, diff output suppressed)
    * execute[unpack /var/chef/cache/jmeter-2.11.tgz] action nothing (skipped due to action :nothing)
    * execute[set owner on /usr/local/jmeter-2.11] action nothing (skipped due to action :nothing)
    * link[/usr/local/bin/jmeter] action create
      - create symlink at /usr/local/bin/jmeter to /usr/local/jmeter-2.11/bin/jmeter
    * link[/usr/local/bin/jmeter-server] action create
      - create symlink at /usr/local/bin/jmeter-server to /usr/local/jmeter-2.11/bin/jmeter-server
    * link[/usr/local/bin/ApacheJMeter.jar] action create
      - create symlink at /usr/local/bin/ApacheJMeter.jar to /usr/local/jmeter-2.11/bin/ApacheJMeter.jar
    * link[/usr/local/jmeter] action create
      - create symlink at /usr/local/jmeter to /usr/local/jmeter-2.11
    * template[/etc/profile.d/jmeter.sh] action create (skipped due to only_if)
    * ruby_block[adding '/usr/local/jmeter-2.11/bin' to chef-client ENV['PATH']] action run (skipped due to only_if)
    * execute[unpack /var/chef/cache/jmeter-2.11.tgz] action run
      - execute /bin/tar xzf /var/chef/cache/jmeter-2.11.tgz --strip-components=1
    * execute[set owner on /usr/local/jmeter-2.11] action run
      - execute chown -R root:0 /usr/local/jmeter-2.11

  * chef_gem[ruby-jmeter] action nothing (skipped due to action :nothing)
  * jmeter_plan[google-search] action run

    ================================================================================
    Error executing action `run` on resource 'jmeter_plan[google-search]'
    ================================================================================

    NoMethodError
    -------------
    private method `binding' called for nil:NilClass

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/jmeter/libraries/plan.rb:28:in `block in action_run'
    /var/chef/cache/cookbooks/jmeter/libraries/plan.rb:27:in `action_run'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/jmeter/recipes/default.rb

     44: jmeter_plan 'google-search' do
     45:   test do
     46:     threads count: 10 do
     47:       visit name: 'Google Search', url: 'http://google.com'
     48:     end
     49:   end
     50: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/jmeter/recipes/default.rb:44:in `from_file'

    jmeter_plan("google-search") do
      action "run"
      retries 0
      retry_delay 2
      guard_interpreter :default
      block_name "google-search"
      cookbook_name "jmeter"
      recipe_name "default"
    end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.