Skip to content

Commit

Permalink
Add test scenarios (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Wang committed Jul 30, 2014
1 parent 3231eeb commit dbf80b1
Show file tree
Hide file tree
Showing 12 changed files with 2,683 additions and 10 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,14 @@ sudo python benchmark_runner.py /home/alex/benchmark_runner.cfg /home/alex/locus

FIXME:
locust should be installed as package. I used venv in this script.

There are 8 test scenarios under tests. You need to change tests/config.py to use your project Id and Keystone token.

Some test cases are ordered. Test case ending with *_populated_table.py needs to run after the corresponding *_with_no_table.py is run, which will create and populate tables for it.

For each test scenario, follow the steps below:
1. python my_test_scenario.py http://my_magnetodb_api_server:8480 start
2. run benchmark_runner as above
3. python my_test_scenario.py http://my_magnetodb_api_server:8480 end

These 3 steps will be integrated into benchmark_runner.py soon.
24 changes: 15 additions & 9 deletions benchmark_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,19 @@ def runbg(cmd, sockname="dtach"):

def start_locust_master(master_ip, master_port, master_user, master_password, locust_file, host, requests_count):
with (settings(host_string=master_ip, user=master_user, password=master_password)):
with cd('locust'), prefix('source .venv/bin/activate'):
cmd = 'locust -f %s -H %s --master -n %s --master-bind-host=%s --master-bind-port=%s'
run(cmd % (locust_file, host, requests_count, master_ip, master_port))
# with cd('locust'), prefix('source .venv/bin/activate'):
# with cd('locust'):
cmd = 'locust -f %s -H %s --master -n %s --master-bind-host=%s --master-bind-port=%s'
run(cmd % (locust_file, host, requests_count, master_ip, master_port))


def start_locust_slave(slave_ip, slave_user, slave_password, locust_file, host, master_ip, master_port):
with (settings(host_string=slave_ip, user=slave_user, password=slave_password)):
with cd('locust'), prefix('source .venv/bin/activate'):
cmd = 'locust -f %s -H %s --no-web --slave --master-host=%s --master-port=%s'
slave_locust_file = '/tmp/%s.py' % uuid.uuid4()
put(locust_file, slave_locust_file)
runbg(cmd % (slave_locust_file, host, master_ip, master_port))
# with cd('locust'):
cmd = 'locust -f %s -H %s --no-web --slave --master-host=%s --master-port=%s'
slave_locust_file = '/tmp/%s.py' % uuid.uuid4()
put(locust_file, slave_locust_file)
runbg(cmd % (slave_locust_file, host, master_ip, master_port))


def get_timestamp_str(timestamp=None):
Expand Down Expand Up @@ -127,8 +128,11 @@ def main(cfg_file, locust_file):
conf = get_collectd_conf()
set_collectd_conf(change_rrd_dir(conf, rrd_dir))

# host = cfg.get('locust', 'host_to_test')
# subprocess.call(' '.join("python", locust_file, host, "start"))

start_monitoring()

print ("Start loading...")
start_load(cfg, locust_file)

Expand All @@ -137,6 +141,8 @@ def main(cfg_file, locust_file):
print ("Saving results...")
store_results(results_dir)

# subprocess.call(' '.join("python", locust_file, host, "end"))

print ("Done.")


Expand Down
2 changes: 1 addition & 1 deletion locust_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def read(data=None):
data = rsp.json()

if not data or ('stats' not in data):
collectd.error('redis plugin: No info received')
collectd.error('locust plugin: No info received')
return

for r in data['stats']:
Expand Down
Loading

0 comments on commit dbf80b1

Please sign in to comment.