-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from paegun/master
load_sim support for AUTH + minor --help for AUTH + test cleanup
- Loading branch information
Showing
4 changed files
with
64 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
$: << ::File.expand_path("../lib/", __FILE__) | ||
require "rubygems" | ||
require "bundler/setup" | ||
require 'mixlib/cli' | ||
require 'redmon' | ||
require 'redis' | ||
|
||
redis = Redis.connect | ||
class RedmonLoadSimCLI | ||
include Mixlib::CLI | ||
|
||
loop do | ||
start = rand(100000) | ||
multi = rand(5) | ||
start.upto(multi * start) do |i| | ||
redis.set("key-#{i}", "abcdedghijklmnopqrstuvwxyz") | ||
end | ||
option :redis_url, | ||
:short => '-r URL', | ||
:long => '--redis URL', | ||
:default => 'redis://127.0.0.1:6379', | ||
:description => "The Redis url to load simulated traffic against (default: redis://127.0.0.1:6379, note: password is supported, ie redis://:password@127.0.0.1:6379)" | ||
|
||
start.upto(multi * start) do |i| | ||
redis.get("key-#{i}") | ||
redis.del("key-#{i}") | ||
end | ||
end | ||
def run | ||
parse_options | ||
|
||
redis_options = Redis::Client::DEFAULTS || {} | ||
redis_options[:url] = config[:redis_url] if config[:redis_url] | ||
redis = Redis.new(redis_options) | ||
|
||
loop do | ||
start = rand(100000) | ||
multi = rand(5) | ||
start.upto(multi * start) do |i| | ||
redis.set("key-#{i}", "abcdedghijklmnopqrstuvwxyz") | ||
end | ||
|
||
start.upto(multi * start) do |i| | ||
redis.get("key-#{i}") | ||
redis.del("key-#{i}") | ||
end | ||
end | ||
end | ||
end | ||
|
||
RedmonLoadSimCLI.new.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters