~coreygoldberg/+junk/isd-app-probes

« back to all changes in this revision

Viewing changes to isdprobes/runner.py

  • Committer: Corey Goldberg
  • Date: 2012-06-24 15:11:20 UTC
  • Revision ID: cgoldberg@gmail.com-20120624151120-e5jlakvi7casdihs
fixed imports

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import sys
5
5
import time
6
6
 
7
 
import transactions
8
 
from sender import send_to_carbon
 
7
import sender
 
8
from transactions import sso_web_login
 
9
from transactions import sso_api_auth
 
10
 
 
11
 
9
12
 
10
13
try:
11
14
    from settings import (
27
30
    def _send_metric(name, value):
28
31
        base_metric_path = 'test'
29
32
        metric_path = '%s.%s' % (base_metric_path, name)
30
 
        send_to_carbon(CARBON_SERVER, CARBON_PORT, metric_path, value)
 
33
        sender.send_to_carbon(CARBON_SERVER, CARBON_PORT, metric_path, value)
31
34
        return metric_path
32
35
    
33
36
    def run_single_trans(metric, transaction):
34
 
        elapsed_time = transaction.run(SSO_HOST, SSO_EMAIL, SSO_PASSWORD)
 
37
        elapsed_time = transaction_func(SSO_HOST, SSO_EMAIL, SSO_PASSWORD)
35
38
        metric_path = _send_metric(metric, elapsed_time)
36
39
        print 'time: %.0f ms\n%r sent to carbon' % (elapsed_time, metric_path)
37
40
    
38
 
    trans = {
39
 
        'sso_web_login_time': transactions.sso_web_login,
40
 
        'sso_api_auth_time': transactions.sso_api_auth,
 
41
    transactions = {
 
42
        'sso_web_login_time': sso_web_login.run,
 
43
        'sso_api_auth_time': sso_api_auth.run,
41
44
    }
42
45
    
43
46
    print 'running...'
44
47
    print '-' * 80    
45
 
    for metric_name, transaction_module in trans.items():
46
 
        run_single_trans(metric_name, transaction_module)
 
48
    for metric_name, transaction_func in transactions.items():
 
49
        run_single_trans(metric_name, transaction_func)
47
50
        print '-' * 80
48
51
    print 'OK'
49
52
    print '-' * 80
50
 
 
51
 
 
52
 
    
53
 
if __name__ == '__main__':
54
 
    run()
55