Coder Social home page Coder Social logo

chef-client-jmeter's Introduction

Purpose

I wanted a way to load test chef server.

JMeter

Included is a plugin to be able to test your chef-client. Once you build it, copy it to your $JMETER_HOME/lib/ext directory

If you select Java Sampler, it should be availabe, named com.bb.mandolin.jmeter.ChefClientSampler

You must modify the run_lock.rb that comes with Chef to remove the system level process lock of chef-client. I've included my hacks so you can copy it to your appropriate install of chef.

Download the jmeter with extension @ http://orion-cli.rim.net/~Mandolin/jmeter-chef-client.tar.gz

###Ruby The above JMeter plugin creates a new chef client process for each sample collected and does not scale well. Therefore, I attempted to mimick chef-client registrations and re-registrations using the chef server api.

The gemspec is a way to reference a pulled copy of the chef code - it's not there to build a gem.

The essentials: concurrent_client.rb - The meat of the application config.rb - Ability to over-ride default behaviour

{
   
   :pref_max_threads => Concurrent.processor_count,
   :pref_min_threads => 1,
   :break_on_exception => false,
   :knife_bin => "/opt/chefdk/bin/knife",
   :knife_config => "/etc/chef/knife.rb",
   :log_level => Logger::INFO,
   :chef_log_level => Logger::WARN

}

Any of the above properties can be modified - but must be in the same directory as concurrent_client.rb.

Chef logging is separated from Load logging for efficiency and readability

###Basic Load Tests

require_relative 'concurrent_client.rb'

class MyLoad < Load::Runner
  
  def node_prefix
    "load_testing_"
  end
  
  #Do my task! - it must have this signature
  def task(ctx)
    Load::save_node "#{node_prefix}#{ctx.cur_num}"
    
  end

end

class SleepingLoad < Load::Runner
  
  
  #Do my task! - it must have this signature
  def task(ctx)
    Load::save_node "#{node_prefix}#{ctx.cur_num}"

    #My own pause mechanism
    #sleep(0)
    
  end

end



c = MyLoad.new
#Mix it up with another task
s = SleepingLoad.new

#Run my task this many times
c.run_times(1024*512)

#The thread pool is global! So will contend with other above submitted tasks
s.run_times(1024)


#Wait for all thread to complete and shutdown
c.shutdown

#Print out stats - Can be done at any point of execution
Load.log().info "Total time (sec): #{c.stats.total_time}, Avg Latency (sec) #{c.stats.avg_latency}, Throughput(task/sec): #{c.stats.throughput}"

new_node_registrations.rb - An approximate chef client run. There are some things missing, like a complete resolution of the cookbook dependency tree, pulling environments and roles.

node_reregistrations.rb - A node that checks in (daemon mode)

Feel free to use/abuse/comment.

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.