5
5
6
6
7
7
nozzle_perf_params = [
8
- {" hec-workers" : "1" , " hec-batch-size" : " 100" },
9
- {" hec-workers" : "2" , " hec-batch-size" : " 100" },
10
- {" hec-workers" : "4" , " hec-batch-size" : " 100" },
11
- {" hec-workers" : "8" , " hec-batch-size" : " 100" },
12
- {" hec-workers" : "16" , " hec-batch-size" : " 100" },
13
- {" hec-workers" : "32" , " hec-batch-size" : " 100" },
14
- {" hec-workers" : "1" , " hec-batch-size" : " 1000" },
15
- {" hec-workers" : "2" , " hec-batch-size" : " 1000" },
16
- {" hec-workers" : "4" , " hec-batch-size" : " 1000" },
17
- {" hec-workers" : "8" , " hec-batch-size" : " 1000" },
18
- {" hec-workers" : "16" , " hec-batch-size" : " 1000" },
19
- {" hec-workers" : "32" , " hec-batch-size" : " 1000" },
8
+ {' hec-workers' : '1' , ' hec-batch-size' : ' 100' },
9
+ {' hec-workers' : '2' , ' hec-batch-size' : ' 100' },
10
+ {' hec-workers' : '4' , ' hec-batch-size' : ' 100' },
11
+ {' hec-workers' : '8' , ' hec-batch-size' : ' 100' },
12
+ {' hec-workers' : '16' , ' hec-batch-size' : ' 100' },
13
+ {' hec-workers' : '32' , ' hec-batch-size' : ' 100' },
14
+ {' hec-workers' : '1' , ' hec-batch-size' : ' 1000' },
15
+ {' hec-workers' : '2' , ' hec-batch-size' : ' 1000' },
16
+ {' hec-workers' : '4' , ' hec-batch-size' : ' 1000' },
17
+ {' hec-workers' : '8' , ' hec-batch-size' : ' 1000' },
18
+ {' hec-workers' : '16' , ' hec-batch-size' : ' 1000' },
19
+ {' hec-workers' : '32' , ' hec-batch-size' : ' 1000' },
20
20
]
21
21
22
22
nozzle_perf_suites = [
23
23
{
24
- " message-type" : " s256byte" ,
25
- " extra-fields" : " message_type:s256byte" ,
26
- " cases" : nozzle_perf_params ,
24
+ ' message-type' : ' s256byte' ,
25
+ ' extra-fields' : ' message_type:s256byte' ,
26
+ ' cases' : nozzle_perf_params ,
27
27
},
28
28
{
29
- " message-type" : " s1kbyte" ,
30
- " extra-fields" : " message_type:s1kbyte" ,
31
- " cases" : nozzle_perf_params ,
29
+ ' message-type' : ' s1kbyte' ,
30
+ ' extra-fields' : ' message_type:s1kbyte' ,
31
+ ' cases' : nozzle_perf_params ,
32
32
},
33
33
{
34
- " message-type" : " uns256byte" ,
35
- " extra-fields" : " message_type:uns256byte" ,
36
- " cases" : nozzle_perf_params ,
34
+ ' message-type' : ' uns256byte' ,
35
+ ' extra-fields' : ' message_type:uns256byte' ,
36
+ ' cases' : nozzle_perf_params ,
37
37
},
38
38
{
39
- " message-type" : " uns1kbyte" ,
40
- " extra-fields" : " message_type:uns1kbyte" ,
41
- " cases" : nozzle_perf_params ,
39
+ ' message-type' : ' uns1kbyte' ,
40
+ ' extra-fields' : ' message_type:uns1kbyte' ,
41
+ ' cases' : nozzle_perf_params ,
42
42
},
43
43
]
44
44
45
45
46
46
def run_nozzle_perf (config ):
47
47
for suite in nozzle_perf_suites :
48
- for case in suite [" cases" ]:
49
- kvs = "," .join (" {}:{}" .format (k , v ) for k , v in case .iteritems ())
50
- extra_fields = " {},{}" .format (suite [" extra-fields" ], kvs )
48
+ for case in suite [' cases' ]:
49
+ kvs = ',' .join (' {}:{}' .format (k , v ) for k , v in case .iteritems ())
50
+ extra_fields = ' {},{}' .format (suite [' extra-fields' ], kvs )
51
51
52
52
cmd = [
53
- " ./splunk-firehose-nozzle" ,
54
- " --api-endpoint" , config [" api-endpoint" ],
55
- " --user" , config [" user" ],
56
- " --password" , config [" password" ],
57
- " --splunk-host" , config [" splunk-host" ],
58
- " --splunk-token" , config [" splunk-token" ],
59
- " --splunk-index" , config [" splunk-index" ],
60
- " --hec-workers" , case [" hec-workers" ],
61
- " --hec-batch-size" , case [" hec-batch-size" ],
62
- " --events" , " ContainerMetric,CounterEvent,Error,HttpStart,HttpStartStop,HttpStop,LogMessage,ValueMetric" ,
63
- " --extra-fields" , extra_fields ,
64
- " --add-app-info" ,
65
- " --enable-event-tracing" ,
66
- " --skip-ssl-validation-cf" ,
67
- " --skip-ssl-validation-splunk" ,
53
+ ' ./splunk-firehose-nozzle' ,
54
+ ' --api-endpoint' , config [' api-endpoint' ],
55
+ ' --user' , config [' user' ],
56
+ ' --password' , config [' password' ],
57
+ ' --splunk-host' , config [' splunk-host' ],
58
+ ' --splunk-token' , config [' splunk-token' ],
59
+ ' --splunk-index' , config [' splunk-index' ],
60
+ ' --hec-workers' , case [' hec-workers' ],
61
+ ' --hec-batch-size' , case [' hec-batch-size' ],
62
+ ' --events' , ' ContainerMetric,CounterEvent,Error,HttpStart,HttpStartStop,HttpStop,LogMessage,ValueMetric' ,
63
+ ' --extra-fields' , extra_fields ,
64
+ ' --add-app-info' ,
65
+ ' --enable-event-tracing' ,
66
+ ' --skip-ssl-validation-cf' ,
67
+ ' --skip-ssl-validation-splunk' ,
68
68
]
69
- print " " .join (cmd )
70
- execute (cmd , config [" duration" ])
69
+ print ' ' .join (cmd )
70
+ execute (cmd , config [' duration' ])
71
71
72
72
73
73
def execute (cmd , duration ):
74
74
has_error = False
75
75
while 1 :
76
76
try :
77
77
start = time .time ()
78
- print " start {} {}" .format (" " .join (cmd ), start )
78
+ print ' start {} {}' .format (' ' .join (cmd ), start )
79
79
out , err = subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE ).communicate ()
80
80
except Exception as e :
81
81
has_error = True
82
82
print e
83
83
else :
84
84
has_error = False
85
- print " out:" , out
86
- print " err:" , err
85
+ print ' out:' , out
86
+ print ' err:' , err
87
87
finally :
88
88
end = time .time ()
89
89
last = end - start
90
- print " end {} {} duration={}" .format (" " .join (cmd ), end , last )
90
+ print ' end {} {} duration={}' .format (' ' .join (cmd ), end , last )
91
91
92
92
# If we run too short, rerun it
93
93
if last < 0.8 * duration :
94
- print " run too short, retry..."
94
+ print ' run too short, retry...'
95
95
time .sleep (1 )
96
96
elif has_error :
97
97
pass
@@ -101,43 +101,43 @@ def execute(cmd, duration):
101
101
102
102
def run_trafficcontroller (duration ):
103
103
for suite in nozzle_perf_suites :
104
- for case in suite [" cases" ]:
105
- ip = " pcf_{}_{}" .format (
106
- suite [" message-type" ],
107
- "_" .join (" {}-{}" .format (k , v ) for k , v in case .iteritems ()))
104
+ for case in suite [' cases' ]:
105
+ ip = ' pcf_{}_{}' .format (
106
+ suite [' message-type' ],
107
+ '_' .join (' {}-{}' .format (k , v ) for k , v in case .iteritems ()))
108
108
cmd = [
109
- " ./trafficcontroller" ,
110
- " --config" , " loggregator_trafficcontroller.json" ,
111
- " --disableAccessControl" ,
112
- " --duration" , str (duration ),
113
- " --message-type" , suite [" message-type" ],
114
- " --ip" , ip ,
109
+ ' ./trafficcontroller' ,
110
+ ' --config' , ' loggregator_trafficcontroller.json' ,
111
+ ' --disableAccessControl' ,
112
+ ' --duration' , str (duration ),
113
+ ' --message-type' , suite [' message-type' ],
114
+ ' --ip' , ip ,
115
115
]
116
116
117
117
execute (cmd , duration )
118
118
time .sleep (10 )
119
119
120
120
121
121
def main ():
122
- parser = argparse .ArgumentParser (description = " Nozzle perf test driver" )
123
- parser .add_argument (" --run" , dest = " run" , required = True , help = " nozzle or trafficcontroller" )
124
- parser .add_argument (" --duration" , dest = " duration" , type = int , required = True , help = " how long to run in seconds" )
122
+ parser = argparse .ArgumentParser (description = ' Nozzle perf test driver' )
123
+ parser .add_argument (' --run' , dest = ' run' , required = True , help = ' nozzle or trafficcontroller' )
124
+ parser .add_argument (' --duration' , dest = ' duration' , type = int , required = True , help = ' how long to run in seconds' )
125
125
args = parser .parse_args ()
126
126
127
- if args .run == " nozzle" :
127
+ if args .run == ' nozzle' :
128
128
config = {
129
- " api-endpoint" : os .environ .get (" API_ENDPOINT" , " http://trafficcontroller:9911" ),
130
- " user" : os .environ .get (" API_USER" , " admin" ),
131
- " password" : os .environ .get (" API_PASSWORD" , " admin" ),
132
- " splunk-host" : os .environ .get (" SPLUNK_HOST" , " https://heclb1:8088" ),
133
- " splunk-token" : os .environ .get (" SPLUNK_TOKEN" , " 00000000-0000-0000-0000-000000000000" ),
134
- " splunk-index" : os .environ .get (" SPLUNK_INDEX" , " main" ),
135
- " duration" : args .duration ,
129
+ ' api-endpoint' : os .environ .get (' API_ENDPOINT' , ' http://trafficcontroller:9911' ),
130
+ ' user' : os .environ .get (' API_USER' , ' admin' ),
131
+ ' password' : os .environ .get (' API_PASSWORD' , ' admin' ),
132
+ ' splunk-host' : os .environ .get (' SPLUNK_HOST' , ' https://heclb1:8088' ),
133
+ ' splunk-token' : os .environ .get (' SPLUNK_TOKEN' , ' 00000000-0000-0000-0000-000000000000' ),
134
+ ' splunk-index' : os .environ .get (' SPLUNK_INDEX' , ' main' ),
135
+ ' duration' : args .duration ,
136
136
}
137
137
run_nozzle_perf (config )
138
138
else :
139
139
run_trafficcontroller (args .duration )
140
140
141
141
142
- if __name__ == " __main__" :
142
+ if __name__ == ' __main__' :
143
143
main ()
0 commit comments