Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 34e42cb174
Fetching contributors…

Cannot retrieve contributors at this time

executable file 278 lines (222 sloc) 9.213 kB
#!/usr/bin/env ruby
# example: ./runtests $package \
# $ram_quotas,csv $replica_counts,csv \
# $num_items,csv $nodes,csv $vbucket-range $val-size,csv \
# [$key=val,csv]
#
$pkg = pkg = ARGV[0] # Ex: "../couchbase-server-community_x86_64_2.0.0r-289-gc0dbb43.rpm"
unless pkg
print "usage: ./runtests $package $ram_quotas,csv $replica_counts,csv \\\n" +
" $num_items,csv $nodes,csv $vbucket-range $val-size-arr [$key=val,csv]\n"
print "example: ./runtests couchbase-server*.rpm" +
" 5000 0,1 1000,100000,1000000 1,2,3,4 1-64 128,1000,10000\n"
print "example: ./runtests couchbase-server*.rpm" +
" 5000 0 100000 1 1 1000\n"
exit(-1)
end
$pkg_base = pkg.split('/')[-1]
$pkg_base = pkg_base = $pkg_base.split('-')[0]
$start = Time.now.strftime("%Y%m%d%H%M%S")
ram_quotas_arr = (ARGV[1] || "5000").split(',').map {|x| x.to_i}
replica_counts_arr = (ARGV[2] || "0").split(',').map {|x| x.to_i}
num_items_arr = (ARGV[3] || "100000").split(',').map {|x| x.to_i}
nodes_arr = (ARGV[4] || "1,2,5").split(',').map {|x| x.to_i}
vbucket_range = (ARGV[5] || "1-64").split('-').map {|x| x.to_i}
# 0 is valid vbucket param and means use default, out-of-the-box vbucket setting.
#
vbucket_min = 1
vbucket_min = vbucket_range[0] if vbucket_range.length > 1
vbucket_max = vbucket_range[-1]
vbucket_min = [vbucket_min, vbucket_max].min
val_size_arr = (ARGV[6] || "1000").split(',').map {|x| x.to_i}
opts = {
'extra_sleep' => '',
'cluster.user' => 'ec2-user',
'cluster.hosts' => '',
'cluster.identity' => nil,
'cluster.teardown' => 'y',
'cluster.package-url-base' => 'http://packages.northscale.com/latestbuilds',
'download' => 'y', # Whether we should download the target software pkg.
'install' => 'y', # Whether we should install the target software pkg.
'target' => '127.0.0.1', # Host of 'main' node to use.
'json' => 'y',
'concurrency' => 10
}
(ARGV[7] || "").split(',').each {|x|
key, val = x.split('=')
opts[key] = val
}
$ssh = "ssh -t"
$ssh = $ssh + " -i #{opts['cluster.identity']}" if opts['cluster.identity']
def run(cmd)
print("#{cmd}\n")
`#{cmd}`
end
# ------------------------------------------
def test_name(pkg, ram_quota, replica_count, num_items, nodes, vbuckets,
val_size, opts, json)
pkg = pkg.split('/')[-1]
# Ex: 'couchbase-server-community_x86_64_2.0.0r-289-gc0dbb43.rpm'
prefix = pkg.split('-')[0]
prefix = pkg.split('-server-')[0] if pkg.split('-server-').length > 1
pkg = prefix + '-' + pkg.split('_')[-1].split('.')[0..-2].join('.')
# Ex: 'couchbase-2.0.0r-289-gc0dbb43'
j = 'j'
j = 'b' unless json
return ["test-#{$start}_#{pkg}",
"#{ram_quota}-#{replica_count}-#{num_items}-#{nodes}-#{vbuckets}-#{val_size}-#{j}"]
end
# ------------------------------------------
def prepare_cluster(pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
return nil if nodes <= 1
return prepare_cluster_existing(pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
end
def teardown_cluster(pkg, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
return if nodes <= 1
return teardown_cluster_existing(pkg, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
end
# ------------------------------------------
def prepare_cluster_existing(pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
user = opts['cluster.user']
hosts = opts['cluster.hosts'].split('+')
target = opts['target']
if target and target != '127.0.0.1' and not hosts.include?(target)
teardown_node(user, target,
pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
prepare_node(user, target, target,
pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
end
return "none" if nodes <= 1
if nodes > hosts.length + 1
print("ERROR: Not enough cluster.hosts (#{hosts})" \
" for #{nodes} number of nodes.\n")
exit(-1)
end
# Prepare a cluster a list of existing, pre-launched machines.
#
teardown_cluster_existing(pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
i = 1
while i < nodes
host = hosts[i - 1]
prepare_node(user, host, hosts[0],
pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
i = i + 1
end
return hosts[0]
end
def teardown_cluster_existing(pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
return if nodes <= 1
hosts = opts['cluster.hosts'].split('+')
user = opts['cluster.user']
hosts.each do |host|
teardown_node(user, host,
pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
end
end
# ------------------------------------------
def prepare_node(user, host, main_host,
pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
pkg = pkg_in
pkg = pkg.split('/')[-1]
pkg_base = pkg.split('-')[0]
pkg_url = "#{opts['cluster.package-url-base']}/#{pkg}"
if opts['download'] == 'y'
run "#{$ssh} #{user}@#{host} sudo wget -O #{pkg_in} #{pkg_url}"
end
if opts['install'] == 'y'
run "#{$ssh} #{user}@#{host} sudo rpm -i #{pkg_in}"
end
run "#{$ssh} #{user}@#{host} rm -f after-install"
run "#{$ssh} #{user}@#{host} wget https://raw.github.com/couchbaselabs/rampup/master/after-install"
run "#{$ssh} #{user}@#{host} chmod a+x after-install"
run "#{$ssh} #{user}@#{host} sudo ./after-install #{vbuckets}"
if host == main_host
run "#{$ssh} #{user}@#{host} /opt/#{pkg_base}/bin/membase \
cluster-init -c 127.0.0.1 \
--cluster-init-username=Administrator \
--cluster-init-password=password"
run "#{$ssh} #{user}@#{host} /opt/#{pkg_base}/bin/membase \
bucket-create -c 127.0.0.1 \
-u Administrator -p password \
--bucket=default --bucket-type=membase --bucket-password= \
--bucket-ramsize=#{ram_quota} \
--bucket-replica=#{replica_count}"
else
run "#{$ssh} #{user}@#{host} /opt/#{pkg_base}/bin/membase \
server-add -c #{main_host} \
-u Administrator -p password \
--server-add=#{host}"
end
end
def teardown_node(user, host,
pkg_in, ram_quota, replica_count,
num_items, nodes, vbuckets, val_size, opts)
pkg = pkg_in
pkg = pkg.split('/')[-1]
pkg_base = pkg.split('-')[0]
pkg_url = "#{opts['cluster.package-url-base']}/#{pkg}"
run "#{$ssh} #{user}@#{host} sudo killall -9 memcached"
run "#{$ssh} #{user}@#{host} sudo /etc/init.d/#{pkg_base}-server stop"
run "#{$ssh} #{user}@#{host} sudo killall -9 heart"
run "#{$ssh} #{user}@#{host} sudo killall -9 couchdb"
run "#{$ssh} #{user}@#{host} sudo killall -9 beam.smp"
run "#{$ssh} #{user}@#{host} sudo killall -9 epmd"
if opts['install'] == 'y'
run "#{$ssh} #{user}@#{host} sudo rpm -e #{pkg_base}-server"
end
if opts['download'] == 'y'
run "#{$ssh} #{user}@#{host} sudo rm -rf /opt/#{pkg_base} #{pkg_in}"
end
end
# ------------------------------------------
opts_csv = opts.keys.sort.map {|k| "#{k}=#{opts[k]}" }.join(',')
ram_quotas_arr.each do |ram_quota|
replica_counts_arr.each do |replica_count|
nodes_arr.each do |nodes|
i = [vbucket_min, vbucket_max].min
while i <= vbucket_max
num_items_arr.each do |num_items|
val_size_arr.each do |val_size|
test_dir, test_file = test_name(pkg, ram_quota, replica_count,
num_items, nodes, i,
val_size, opts,
opts['json'] == 'y')
`mkdir -p ./out/#{test_dir}`
test_out = "#{test_dir}/#{test_file}.out"
print "#{test_out} ...\n"
cluster = prepare_cluster(pkg, ram_quota, replica_count,
num_items, nodes, i,
val_size, opts)
j = 0
j = 1 if opts['json'] == 'y'
run "./runtest-#{pkg_base} #{test_out} #{pkg}" \
" #{ram_quota} #{replica_count} #{num_items} #{i} #{val_size}" \
" #{opts['concurrency'].to_i}" \
" #{cluster || 'none'}" \
" #{opts_csv},json=#{j}"
sleep 1
if opts['cluster.teardown'] == 'y'
teardown_cluster(pkg, ram_quota, replica_count,
num_items, nodes, i, val_size, opts)
end
end
end
i = i * 2
# Exit this loop if using default out-of-box vbucket config.
i = vbucket_max + 1 if i == 0
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.