4 ## Copyright (c) 2010-2017 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
10 ## http://www.apache.org/licenses/LICENSE-2.0
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
19 from testerset import *
20 from proxdpisut import *
21 from statsconsfile import *
22 from time import sleep
28 from itertools import chain
30 from csvwriter import *
31 from csvreader import *
33 from progress import *
34 from resultprocessor import *
36 def runTest(coreCount, testParam):
37 print "Running test with following parameters:"
38 print testParam.toString();
41 testers = testerSet(config._test_systems, config._max_port_rate, testParam);
43 ret = TestResult(testers.getCount());
44 thresh = testParam.getConnections() * config._threshold;
47 sut = ProxDpiSut(config._sut, coreCount);
53 testers.wait_links_up();
55 sut.waitCmdFinished();
56 testers.start_cores();
58 ret.addTimeTS(testers.getTsc());
59 ret.addTimeSUT(sut.getTsc());
61 print "Running until convergence (%s connections)" % str(thresh)
62 p = Progress(thresh, ["connections", "setup rate", "reTX"], False);
63 while (not converged):
64 sleep(config._interCheckDuration)
65 testers.update_stats();
67 tot = testers.get_total_connections();
68 tot_retx = testers.get_total_retx();
69 rates = testers.get_rates();
70 cur_setup_rate = testers.get_setup_rate();
71 ierrors = testers.getIerrors();
72 converged = tot >= thresh;
74 if (not converged and not testers.conditionsGood()):
75 print "conditions are bad: " + testers.getReason();
81 if (sut.getIerrors() != 0):
87 print "Sending quit failed"
92 p.setProgress(tot, [tot, cur_setup_rate, tot_retx]);
95 skipTime = config._skipTime
96 print "Connection threshold reached, waiting for " + str(skipTime) + "s, conditions checked = " + str(config._checkConditions)
98 skipTime -= config._interCheckDuration
99 sleep(config._interCheckDuration)
100 testers.update_stats();
101 if (config._checkConditions and not testers.conditionsGood()):
102 print "conditions are bad: " + testers.getReason();
108 ret.addTimeTS(testers.getTsc());
109 ret.addTimeSUT(sut.getTsc());
111 testers.tx_rate_meassurement();
113 testLength = config._testLength
114 print "Waiting final " + str(testLength) + "s"
115 while (testLength > 0):
116 testLength -= config._interCheckDuration
117 testers.update_stats();
118 if (not testers.conditionsGood()):
119 print "conditions are bad: " + testers.getReason();
125 if (sut.getIerrors() != 0):
131 print "Sending quit failed"
135 sleep(config._interCheckDuration)
137 rates = testers.tx_rate_meassurement();
138 ret.addTimeTS(testers.getTsc());
139 ret.addTimeSUT(sut.getTsc());
141 print "Quiting Prox on SUT"
142 # make sure stats are flushed
144 print "Quiting Prox on test system(s)"
149 sutStatsDump = "stats_dump_sut"
150 tsStatsDumpBaseName = "stats_dump_ts"
152 sut.scpStatsDump(sutStatsDump);
153 tsStatsDump = testers.scpStatsDump(tsStatsDumpBaseName);
155 ret.setTSStatsDump(tsStatsDump);
156 ret.setSUTStatsDump(sutStatsDump);
159 def meassurePerf(coreCount, maxSetupRate, total_connections, ss_hi):
161 accuracy = 10**config._accuracy
163 ss_hi = int(round(ss_hi * accuracy, 0))
168 iterationOverride = [ss_hi, ss_lo];
169 while (ss_lo <= ss_hi):
170 if (iterationCount < len(iterationOverride)):
171 ss = iterationOverride[iterationCount]
173 ss = (ss_lo + ss_hi)/2;
175 testParam = TestParameters(maxSetupRate, total_connections, float(ss)/accuracy);
177 result = runTest(coreCount, testParam);
182 rp = ResultProcessor(result)
184 success = rp.percentHandled() > 0.99999
186 print "test result = " + str(success)
189 highest_ss = max(highest_ss, ss);
191 downrate = sum(result.rates)/len(result.rates)
196 return downrate, float(highest_ss)/accuracy
199 config.parse(sys.argv[0], sys.argv[1:])
201 err = config.getErrorTestTwo();
202 if (err is not None):
203 print "Invalid configuration: " + err;
206 print config.toString()
209 infileFields += [("msr", "int")]
210 infileFields += [("conn", "int")]
211 infileFields += [("ss", "Decimal")]
212 infileFields += [("bw", "Decimal")]
214 infile = CsvReader(infileFields);
215 infile.open(config.getInputFileName())
216 inputs = infile.readAll()
219 summary = CsvWriter();
220 summary.open(config._output_file_name);
222 print "Will test up SUT config with " + str(config._dpiCoreList) + " DPI cores"
225 for coreCount in config._dpiCoreList:
226 downrate, ss = meassurePerf(coreCount, a["msr"], a["conn"], a["ss"]);
227 summary.write([coreCount, a["msr"], a["conn"], ss, downrate]);