blob: 219415a3bf2a67b7e86b610fcb98ca46e32c9dcf [file] [log] [blame]
TamasBakai9b780332019-02-15 08:38:16 +00001import argparse
2import os
3from werkzeug import secure_filename
4from flask import Flask, render_template, request
5from time import sleep
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00006import time
TamasBakai9b780332019-02-15 08:38:16 +00007import sys
8import json
9from flask import Flask
BjornMagnussonXAf4e18362019-04-10 13:04:08 +000010
TamasBakai9b780332019-02-15 08:38:16 +000011app = Flask(__name__)
12
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000013#Server info
14HOST_IP = "0.0.0.0"
15HOST_PORT = 2222
TamasBakai9b780332019-02-15 08:38:16 +000016
BjornMagnussonXAf4e18362019-04-10 13:04:08 +000017SFTP_PORT = 1022
18FTPS_PORT = 21
19
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000020#Test function to check server running
21@app.route('/',
22 methods=['GET'])
23def index():
24 return 'Hello world'
TamasBakai9b780332019-02-15 08:38:16 +000025
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000026#Returns number of polls
27@app.route('/ctr_requests',
28 methods=['GET'])
29def counter_requests():
30 global ctr_requests
31 return str(ctr_requests)
32
33#Returns number of replies
34@app.route('/ctr_responses',
35 methods=['GET'])
36def counter_responses():
37 global ctr_responses
38 return str(ctr_responses)
39
BjornMagnussonXA42dcb262019-04-26 19:29:54 +000040#Returns the total number of file
41@app.route('/ctr_files',
42 methods=['GET'])
43def counter_files():
44 global ctr_files
45 return str(ctr_files)
46
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000047#Returns number of unique files
48@app.route('/ctr_unique_files',
49 methods=['GET'])
50def counter_uniquefiles():
51 global fileMap
52 return str(len(fileMap))
53
54#Returns tc info
55@app.route('/tc_info',
56 methods=['GET'])
57def testcase_info():
58 global tc_num
59 return tc_num
60
BjornMagnussonXAf4e18362019-04-10 13:04:08 +000061#Returns number of events
62@app.route('/ctr_events',
63 methods=['GET'])
64def counter_events():
65 global ctr_events
66 return str(ctr_events)
67
BjornMagnussonXA42dcb262019-04-26 19:29:54 +000068#Returns execution time in mm:ss
BjornMagnussonXAf4e18362019-04-10 13:04:08 +000069@app.route('/execution_time',
70 methods=['GET'])
71def exe_time():
72 global startTime
BjornMagnussonXA42dcb262019-04-26 19:29:54 +000073
BjornMagnussonXAf4e18362019-04-10 13:04:08 +000074 stopTime = time.time()
75 minutes, seconds = divmod(stopTime-startTime, 60)
76 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
77
BjornMagnussonXA42dcb262019-04-26 19:29:54 +000078#Returns the timestamp for first poll
79@app.route('/exe_time_first_poll',
80 methods=['GET'])
81def exe_time_first_poll():
82 global firstPollTime
83
84 if (firstPollTime == 0):
85 return "--:--"
86 minutes, seconds = divmod(time.time()-firstPollTime, 60)
87 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
88
89#Starts event delivery
90@app.route('/start',
91 methods=['GET'])
92def start():
93 global runningState
94 runningState="Started"
95 return runningState
96
97#Stops event delivery
98@app.route('/stop',
99 methods=['GET'])
100def stop():
101 global runningState
102 runningState="Stopped"
103 return runningState
104
105#Returns the running state
106@app.route('/status',
107 methods=['GET'])
108def status():
109 global runningState
110 return runningState
111
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000112#Returns number of unique PNFs
113@app.route('/ctr_unique_PNFs',
114 methods=['GET'])
115def counter_uniquePNFs():
116 global pnfMap
117 return str(len(pnfMap))
118
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000119#Messages polling function
TamasBakai9b780332019-02-15 08:38:16 +0000120@app.route(
121 "/events/unauthenticated.VES_NOTIFICATION_OUTPUT/OpenDcae-c12/C12",
122 methods=['GET'])
123def MR_reply():
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000124 global ctr_requests
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000125 global ctr_responses
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000126 global args
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000127 global runningState
128 global firstPollTime
129
130 if (firstPollTime == 0):
131 firstPollTime = time.time()
TamasBakai9b780332019-02-15 08:38:16 +0000132
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000133 ctr_requests = ctr_requests + 1
134 print("MR: poll request#: " + str(ctr_requests))
TamasBakai9b780332019-02-15 08:38:16 +0000135
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000136 if (runningState == "Stopped"):
137 ctr_responses = ctr_responses + 1
138 return buildOkResponse("[]")
139
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000140 if args.tc100:
141 return tc100("sftp")
142 elif args.tc101:
143 return tc101("sftp")
144 elif args.tc102:
145 return tc102("sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000146
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000147 elif args.tc110:
148 return tc110("sftp")
149 elif args.tc111:
150 return tc111("sftp")
151 elif args.tc112:
152 return tc112("sftp")
153 elif args.tc113:
154 return tc113("sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000155
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000156 elif args.tc120:
157 return tc120("sftp")
158 elif args.tc121:
159 return tc121("sftp")
160 elif args.tc122:
161 return tc122("sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000162
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000163 elif args.tc1000:
164 return tc1000("sftp")
165 elif args.tc1001:
166 return tc1001("sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000167
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000168 elif args.tc1100:
169 return tc1100("sftp","1MB")
170 elif args.tc1101:
171 return tc1100("sftp","50MB")
172 elif args.tc1102:
173 return tc1100("sftp","50MB")
174 elif args.tc1200:
175 return tc1200("sftp","1MB")
176 elif args.tc1201:
177 return tc1200("sftp","5MB")
178 elif args.tc1202:
179 return tc1200("sftp","50MB")
180 elif args.tc1300:
181 return tc1300("sftp","1MB")
182 elif args.tc1301:
183 return tc1300("sftp","5MB")
184 elif args.tc1302:
185 return tc1300("sftp","50MB")
186
187 elif args.tc500:
188 return tc500("sftp","1MB")
189 elif args.tc501:
190 return tc500("sftp","5MB")
191 elif args.tc502:
192 return tc500("sftp","50MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000193 elif args.tc510:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000194 return tc510("sftp")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000195 elif args.tc511:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000196 return tc511("sftp")
197
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000198 elif args.tc710:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000199 return tc710("sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000200
201
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000202 elif args.tc200:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000203 return tc100("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000204 elif args.tc201:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000205 return tc101("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000206 elif args.tc202:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000207 return tc102("ftps")
TamasBakai9b780332019-02-15 08:38:16 +0000208
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000209 elif args.tc210:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000210 return tc110("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000211 elif args.tc211:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000212 return tc111("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000213 elif args.tc212:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000214 return tc112("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000215 elif args.tc213:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000216 return tc113("ftps")
TamasBakai9b780332019-02-15 08:38:16 +0000217
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000218 elif args.tc220:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000219 return tc120("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000220 elif args.tc221:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000221 return tc121("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000222 elif args.tc222:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000223 return tc122("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000224
225 elif args.tc2000:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000226 return tc1000("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000227 elif args.tc2001:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000228 return tc1001("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000229
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000230 elif args.tc2100:
231 return tc1100("ftps","1MB")
232 elif args.tc2101:
233 return tc1100("ftps","50MB")
234 elif args.tc2102:
235 return tc1100("ftps","50MB")
236 elif args.tc2200:
237 return tc1200("ftps","1MB")
238 elif args.tc2201:
239 return tc1200("ftps","5MB")
240 elif args.tc2202:
241 return tc1200("ftps","50MB")
242 elif args.tc2300:
243 return tc1300("ftps","1MB")
244 elif args.tc2301:
245 return tc1300("ftps","5MB")
246 elif args.tc2302:
247 return tc1300("ftps","50MB")
248
249 elif args.tc600:
250 return tc500("ftps","1MB")
251 elif args.tc601:
252 return tc500("ftps","5MB")
253 elif args.tc602:
254 return tc500("ftps","50MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000255 elif args.tc610:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000256 return tc510("ftps")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000257 elif args.tc611:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000258 return tc511("ftps")
259
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000260 elif args.tc810:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000261 return tc710("ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000262
263
264#### Test case functions
265
266
267def tc100(ftptype):
268 global ctr_responses
269 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000270 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000271
272 ctr_responses = ctr_responses + 1
273
274 if (ctr_responses > 1):
275 return buildOkResponse("[]")
276
277 seqNr = (ctr_responses-1)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000278 nodeName = createNodeName(0)
279 fileName = createFileName(nodeName, seqNr, "1MB")
280 msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000281 fileMap[seqNr] = seqNr
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000282 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000283 return buildOkResponse("["+msg+"]")
284
285def tc101(ftptype):
286 global ctr_responses
287 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000288 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000289
290 ctr_responses = ctr_responses + 1
291
292 if (ctr_responses > 1):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000293 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000294
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000295 seqNr = (ctr_responses-1)
296 nodeName = createNodeName(0)
297 fileName = createFileName(nodeName, seqNr, "5MB")
298 msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd()
299 fileMap[seqNr] = seqNr
300 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000301 return buildOkResponse("["+msg+"]")
302
303def tc102(ftptype):
304 global ctr_responses
305 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000306 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000307
308 ctr_responses = ctr_responses + 1
309
310 if (ctr_responses > 1):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000311 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000312
313 seqNr = (ctr_responses-1)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000314 nodeName = createNodeName(0)
315 fileName = createFileName(nodeName, seqNr, "50MB")
316 msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000317 fileMap[seqNr] = seqNr
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000318 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000319 return buildOkResponse("["+msg+"]")
320
321def tc110(ftptype):
322 global ctr_responses
323 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000324 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000325
326 ctr_responses = ctr_responses + 1
327
328 if (ctr_responses > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000329 return buildOkResponse("[]")
330
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000331 seqNr = (ctr_responses-1)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000332 nodeName = createNodeName(0)
333 fileName = createFileName(nodeName, seqNr, "1MB")
334 msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000335 fileMap[seqNr] = seqNr
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000336 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000337 return buildOkResponse("["+msg+"]")
338
339def tc111(ftptype):
340 global ctr_responses
341 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000342 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000343
344 ctr_responses = ctr_responses + 1
345
346 if (ctr_responses > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000347 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000348
349 nodeName = createNodeName(0)
350 msg = getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000351
352 for i in range(100):
353 seqNr = i+(ctr_responses-1)
354 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000355 fileName = createFileName(nodeName, seqNr, "1MB")
356 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000357 fileMap[seqNr] = seqNr
358
359 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000360 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000361
362 return buildOkResponse("["+msg+"]")
363
364def tc112(ftptype):
365 global ctr_responses
366 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000367 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000368
369 ctr_responses = ctr_responses + 1
370
371 if (ctr_responses > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000372 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000373
374 nodeName = createNodeName(0)
375 msg = getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000376
377 for i in range(100):
378 seqNr = i+(ctr_responses-1)
379 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000380 fileName = createFileName(nodeName, seqNr, "5MB")
381 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000382 fileMap[seqNr] = seqNr
383
384 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000385 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000386
387 return buildOkResponse("["+msg+"]")
388
389def tc113(ftptype):
390 global ctr_responses
391 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000392 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000393
394 ctr_responses = ctr_responses + 1
395
396 if (ctr_responses > 1):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000397 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000398
399 nodeName = createNodeName(0)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000400 msg = ""
401
402 for evts in range(100): # build 100 evts
403 if (evts > 0):
404 msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000405 msg = msg + getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000406 for i in range(100): # build 100 files
407 seqNr = i+evts+100*(ctr_responses-1)
408 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000409 fileName = createFileName(nodeName, seqNr, "1MB")
410 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000411 fileMap[seqNr] = seqNr
412
413 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000414 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000415
416 return buildOkResponse("["+msg+"]")
417
418
419def tc120(ftptype):
420 global ctr_responses
421 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000422 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000423
424 ctr_responses = ctr_responses + 1
425
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000426 nodeName = createNodeName(0)
427
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000428 if (ctr_responses > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000429 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000430
431 if (ctr_responses % 10 == 2):
432 return # Return nothing
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000433
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000434 if (ctr_responses % 10 == 3):
435 return buildOkResponse("") # Return empty message
436
437 if (ctr_responses % 10 == 4):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000438 return buildOkResponse(getEventHead(nodeName)) # Return part of a json event
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000439
440 if (ctr_responses % 10 == 5):
441 return buildEmptyResponse(404) # Return empty message with status code
442
443 if (ctr_responses % 10 == 6):
444 sleep(60)
445
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000446
447 msg = getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000448
449 for i in range(100):
450 seqNr = i+(ctr_responses-1)
451 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000452 fileName = createFileName(nodeName, seqNr, "1MB")
453 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000454 fileMap[seqNr] = seqNr
455
456 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000457 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000458
459 return buildOkResponse("["+msg+"]")
460
461def tc121(ftptype):
462 global ctr_responses
463 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000464 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000465
466 ctr_responses = ctr_responses + 1
467
468 if (ctr_responses > 100):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000469 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000470
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000471 nodeName = createNodeName(0)
472 msg = getEventHead(nodeName)
473
474 fileName = ""
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000475 for i in range(100):
476 seqNr = i+(ctr_responses-1)
477 if (seqNr%10 == 0): # Every 10th file is "missing"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000478 fileName = createMissingFileName(nodeName, seqNr, "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000479 else:
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000480 fileName = createFileName(nodeName, seqNr, "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000481 fileMap[seqNr] = seqNr
482
483 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000484 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000485
486 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000487 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000488
489 return buildOkResponse("["+msg+"]")
490
491def tc122(ftptype):
492 global ctr_responses
493 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000494 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000495
496 ctr_responses = ctr_responses + 1
497
498 if (ctr_responses > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000499 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000500
501 nodeName = createNodeName(0)
502 msg = getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000503
504 for i in range(100):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000505 fileName = createFileName(nodeName, 0, "1MB") # All files identical names
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000506 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000507 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000508
509 fileMap[0] = 0
510 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000511 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000512
513 return buildOkResponse("["+msg+"]")
514
515
516def tc1000(ftptype):
517 global ctr_responses
518 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000519 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000520
521 ctr_responses = ctr_responses + 1
522
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000523 nodeName = createNodeName(0)
524 msg = getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000525
526 for i in range(100):
527 seqNr = i+(ctr_responses-1)
528 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000529 fileName = createFileName(nodeName, seqNr, "1MB")
530 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000531 fileMap[seqNr] = seqNr
532
533 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000534 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000535
536 return buildOkResponse("["+msg+"]")
537
538def tc1001(ftptype):
539 global ctr_responses
540 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000541 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000542
543 ctr_responses = ctr_responses + 1
544
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000545 nodeName = createNodeName(0)
546 msg = getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000547
548 for i in range(100):
549 seqNr = i+(ctr_responses-1)
550 if i != 0: msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000551 fileName = createFileName(nodeName, seqNr, "5MB")
552 msg = msg + getEventName(fileName,ftptype,"onap","pano")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000553 fileMap[seqNr] = seqNr
554
555 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000556 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000557
558 return buildOkResponse("["+msg+"]")
559
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000560
561def tc1100(ftptype, filesize):
562 global ctr_responses
563 global ctr_unique_files
564 global ctr_events
565
566 ctr_responses = ctr_responses + 1
567
568 msg = ""
569
570 batch = (ctr_responses-1)%20;
571
572 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
573 if (pnfs > 0):
574 msg = msg + ","
575 nodeName = createNodeName(pnfs + batch*35)
576 msg = msg + getEventHead(nodeName)
577
578 for i in range(100): # 100 files per event
579 seqNr = i + int((ctr_responses-1)/20);
580 if i != 0: msg = msg + ","
581 fileName = createFileName(nodeName, seqNr, filesize)
582 msg = msg + getEventName(fileName,ftptype,"onap","pano")
583 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
584 fileMap[seqNr] = seqNr
585
586 msg = msg + getEventEnd()
587 ctr_events = ctr_events+1
588
589 return buildOkResponse("["+msg+"]")
590
591def tc1200(ftptype, filesize):
592 global ctr_responses
593 global ctr_unique_files
594 global ctr_events
595
596 ctr_responses = ctr_responses + 1
597
598 msg = ""
599
600 batch = (ctr_responses-1)%20;
601
602 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
603 if (pnfs > 0):
604 msg = msg + ","
605 nodeName = createNodeName(pnfs + batch*35)
606 msg = msg + getEventHead(nodeName)
607
608 for i in range(100): # 100 files per event, all new files
609 seqNr = i+100 * int((ctr_responses-1)/20);
610 if i != 0: msg = msg + ","
611 fileName = createFileName(nodeName, seqNr, filesize)
612 msg = msg + getEventName(fileName,ftptype,"onap","pano")
613 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
614 fileMap[seqNr] = seqNr
615
616 msg = msg + getEventEnd()
617 ctr_events = ctr_events+1
618
619 return buildOkResponse("["+msg+"]")
620
621
622def tc1300(ftptype, filesize):
623 global ctr_responses
624 global ctr_unique_files
625 global ctr_events
626 global rop_counter
627 global rop_timestamp
628
629 ctr_responses = ctr_responses + 1
630
631 #Start a event deliver for all 700 nodes every 15min
632 rop = time.time()-rop_timestamp
633 if ((rop < 900) & (rop_counter%20 == 0) & (rop_counter != 0)):
634 return buildOkResponse("[]")
635 else:
636 if (rop_counter%20 == 0):
637 rop_timestamp = time.time()
638
639 rop_counter = rop_counter+1
640
641 msg = ""
642
643 batch = (rop_counter-1)%20;
644
645 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
646 if (pnfs > 0):
647 msg = msg + ","
648 nodeName = createNodeName(pnfs + batch*35)
649 msg = msg + getEventHead(nodeName)
650
651 for i in range(100): # 100 files per event
652 seqNr = i + int((rop_counter-1)/20);
653 if i != 0: msg = msg + ","
654 fileName = createFileName(nodeName, seqNr, filesize)
655 msg = msg + getEventName(fileName,ftptype,"onap","pano")
656 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
657 fileMap[seqNr] = seqNr
658
659 msg = msg + getEventEnd()
660 ctr_events = ctr_events+1
661
662 return buildOkResponse("["+msg+"]")
663
664def tc500(ftptype, filesize):
665 global ctr_responses
666 global ctr_unique_files
667 global ctr_events
668
669 ctr_responses = ctr_responses + 1
670
671 if (ctr_responses > 1):
672 return buildOkResponse("[]")
673
674 msg = ""
675
676
677 for pnfs in range(700):
678 if (pnfs > 0):
679 msg = msg + ","
680 nodeName = createNodeName(pnfs)
681 msg = msg + getEventHead(nodeName)
682
683 for i in range(2):
684 seqNr = i;
685 if i != 0: msg = msg + ","
686 fileName = createFileName(nodeName, seqNr, filesize)
687 msg = msg + getEventName(fileName,ftptype,"onap","pano")
688 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
689 fileMap[seqNr] = seqNr
690
691 msg = msg + getEventEnd()
692 ctr_events = ctr_events+1
693
694 return buildOkResponse("["+msg+"]")
695
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000696def tc510(ftptype):
697 global ctr_responses
698 global ctr_unique_files
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000699 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000700
701 ctr_responses = ctr_responses + 1
702
703 if (ctr_responses > 5):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000704 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000705
706 msg = ""
707
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000708 for pnfs in range(700): # build events for 700 MEs
709 if (pnfs > 0):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000710 msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000711 nodeName = createNodeName(pnfs)
712 msg = msg + getEventHead(nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000713 seqNr = (ctr_responses-1)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000714 fileName = createFileName(nodeName, seqNr, "1MB")
715 msg = msg + getEventName(fileName,ftptype,"onap","pano")
716 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000717 fileMap[seqNr] = seqNr
718 msg = msg + getEventEnd()
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000719 ctr_events = ctr_events+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000720
721 return buildOkResponse("["+msg+"]")
722
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000723def tc511(ftptype):
724 global ctr_responses
725 global ctr_unique_files
726 global ctr_events
727
728 ctr_responses = ctr_responses + 1
729
730 if (ctr_responses > 5):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000731 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000732
733 msg = ""
734
735 for pnfs in range(700): # build events for 700 MEs
736 if (pnfs > 0):
737 msg = msg + ","
738 nodeName = createNodeName(pnfs)
739 msg = msg + getEventHead(nodeName)
740 seqNr = (ctr_responses-1)
741 fileName = createFileName(nodeName, seqNr, "1KB")
742 msg = msg + getEventName(fileName,ftptype,"onap","pano")
743 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
744 fileMap[seqNr] = seqNr
745 msg = msg + getEventEnd()
746 ctr_events = ctr_events+1
747
748 return buildOkResponse("["+msg+"]")
749
750def tc710(ftptype):
751 global ctr_responses
752 global ctr_unique_files
753 global ctr_events
754
755 ctr_responses = ctr_responses + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000756
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000757 if (ctr_responses > 100):
758 return buildOkResponse("[]")
759
760 msg = ""
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000761
762 batch = (ctr_responses-1)%20;
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000763
764 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
765 if (pnfs > 0):
766 msg = msg + ","
767 nodeName = createNodeName(pnfs + batch*35)
768 msg = msg + getEventHead(nodeName)
769
770 for i in range(100): # 100 files per event
771 seqNr = i + int((ctr_responses-1)/20);
772 if i != 0: msg = msg + ","
773 fileName = createFileName(nodeName, seqNr, "1MB")
774 msg = msg + getEventName(fileName,ftptype,"onap","pano")
775 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
776 fileMap[seqNr] = seqNr
777
778 msg = msg + getEventEnd()
779 ctr_events = ctr_events+1
780
781 return buildOkResponse("["+msg+"]")
782
783
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000784#### Functions to build json messages and respones ####
785
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000786def createNodeName(index):
787 return "PNF"+str(index);
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000788
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000789def createFileName(nodeName, index, size):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000790 global ctr_files
791 ctr_files = ctr_files + 1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000792 return "A20000626.2315+0200-2330+0200_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz";
793
794def createMissingFileName(nodeName, index, size):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000795 global ctr_files
796 ctr_files = ctr_files + 1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000797 return "AMissingFile_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz";
798
799
800# Function to build fixed beginning of an event
801
802def getEventHead(nodename):
803 global pnfMap
804 pnfMap.add(nodename)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000805 headStr = """
806 {
TamasBakai9b780332019-02-15 08:38:16 +0000807 "event": {
808 "commonEventHeader": {
809 "startEpochMicrosec": 8745745764578,
810 "eventId": "FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1",
811 "timeZoneOffset": "UTC+05.30",
812 "internalHeaderFields": {
813 "collectorTimeStamp": "Tue, 09 18 2018 10:56:52 UTC"
814 },
815 "priority": "Normal",
816 "version": "4.0.1",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000817 "reportingEntityName": \"""" + nodename + """",
TamasBakai9b780332019-02-15 08:38:16 +0000818 "sequence": 0,
819 "domain": "notification",
820 "lastEpochMicrosec": 8745745764578,
821 "eventName": "Noti_RnNode-Ericsson_FileReady",
822 "vesEventListenerVersion": "7.0.1",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000823 "sourceName": \"""" + nodename + """"
TamasBakai9b780332019-02-15 08:38:16 +0000824 },
825 "notificationFields": {
826 "notificationFieldsVersion": "2.0",
827 "changeType": "FileReady",
828 "changeIdentifier": "PM_MEAS_FILES",
829 "arrayOfNamedHashMap": [
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000830 """
831 return headStr
832
833# Function to build the variable part of an event
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000834def getEventName(fn,type,user,passwd):
835 port = SFTP_PORT
836 ip = sftp_ip
837 if (type == "ftps"):
838 port = FTPS_PORT
839 ip = ftps_ip
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000840
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000841 nameStr = """{
842 "name": \"""" + fn + """",
TamasBakai9b780332019-02-15 08:38:16 +0000843 "hashMap": {
844 "fileFormatType": "org.3GPP.32.435#measCollec",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000845 "location": \"""" + type + """://""" + user + """:""" + passwd + """@""" + ip + """:""" + str(port) + """/""" + fn + """",
TamasBakai9b780332019-02-15 08:38:16 +0000846 "fileFormatVersion": "V10",
847 "compression": "gzip"
848 }
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000849 } """
850 return nameStr
851
852# Function to build fixed end of an event
853def getEventEnd():
854 endStr = """
TamasBakai9b780332019-02-15 08:38:16 +0000855 ]
856 }
857 }
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000858 }
859 """
860 return endStr
TamasBakai9b780332019-02-15 08:38:16 +0000861
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000862# Function to build an OK reponse from a message string
863def buildOkResponse(msg):
864 response = app.response_class(
865 response=str.encode(msg),
866 status=200,
867 mimetype='application/json')
868 return response
TamasBakai9b780332019-02-15 08:38:16 +0000869
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000870# Function to build an empty message with status
871def buildEmptyResponse(status_code):
872 response = app.response_class(
873 response=str.encode(""),
874 status=status_code,
875 mimetype='application/json')
876 return response
TamasBakai9b780332019-02-15 08:38:16 +0000877
878
879if __name__ == "__main__":
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000880
881 # IP addresses to use for ftp servers, using localhost if not env var is set
882 sftp_ip = os.environ.get('SFTP_SIM_IP', 'localhost')
883 ftps_ip = os.environ.get('FTPS_SIM_IP', 'localhost')
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000884
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000885 #Counters
886 ctr_responses = 0
887 ctr_requests = 0
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000888 ctr_files=0
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000889 ctr_unique_files = 0
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000890 ctr_events = 0
891 startTime = time.time()
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000892 firstPollTime = 0
893 runningState = "Started"
894 rop_counter = 0
895 rop_timestamp = time.time()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000896
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000897 #Keeps all responded file names
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000898 fileMap = {}
899
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000900 #Keeps all responded PNF names
901 pnfMap = set()
902
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000903 tc_num = "Not set"
904 tc_help = "Not set"
TamasBakai9b780332019-02-15 08:38:16 +0000905
906 parser = argparse.ArgumentParser()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000907
908#SFTP TCs with single ME
TamasBakai9b780332019-02-15 08:38:16 +0000909 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000910 '--tc100',
TamasBakai9b780332019-02-15 08:38:16 +0000911 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000912 help='TC100 - One ME, SFTP, 1 1MB file, 1 event')
TamasBakai9b780332019-02-15 08:38:16 +0000913 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000914 '--tc101',
TamasBakai9b780332019-02-15 08:38:16 +0000915 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000916 help='TC101 - One ME, SFTP, 1 5MB file, 1 event')
TamasBakai9b780332019-02-15 08:38:16 +0000917 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000918 '--tc102',
TamasBakai9b780332019-02-15 08:38:16 +0000919 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000920 help='TC102 - One ME, SFTP, 1 50MB file, 1 event')
921
TamasBakai9b780332019-02-15 08:38:16 +0000922 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000923 '--tc110',
TamasBakai9b780332019-02-15 08:38:16 +0000924 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000925 help='TC110 - One ME, SFTP, 1MB files, 1 file per event, 100 events, 1 event per poll.')
926 parser.add_argument(
927 '--tc111',
928 action='store_true',
929 help='TC111 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll.')
930 parser.add_argument(
931 '--tc112',
932 action='store_true',
933 help='TC112 - One ME, SFTP, 5MB files, 100 files per event, 100 events, 1 event per poll.')
934 parser.add_argument(
935 '--tc113',
936 action='store_true',
937 help='TC113 - One ME, SFTP, 1MB files, 100 files per event, 100 events. All events in one poll.')
938
939 parser.add_argument(
940 '--tc120',
941 action='store_true',
942 help='TC120 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% of replies each: no response, empty message, slow response, 404-error, malformed json')
943 parser.add_argument(
944 '--tc121',
945 action='store_true',
946 help='TC121 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files')
947 parser.add_argument(
948 '--tc122',
949 action='store_true',
950 help='TC122 - One ME, SFTP, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ')
951
952 parser.add_argument(
953 '--tc1000',
954 action='store_true',
955 help='TC1000 - One ME, SFTP, 1MB files, 100 files per event, endless number of events, 1 event per poll')
956 parser.add_argument(
957 '--tc1001',
958 action='store_true',
959 help='TC1001 - One ME, SFTP, 5MB files, 100 files per event, endless number of events, 1 event per poll')
960
961# SFTP TCs with multiple MEs
962 parser.add_argument(
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000963 '--tc500',
964 action='store_true',
965 help='TC500 - 700 MEs, SFTP, 1MB files, 2 new files per event, 700 events, all event in one poll.')
966
967 parser.add_argument(
968 '--tc501',
969 action='store_true',
970 help='TC501 - 700 MEs, SFTP, 5MB files, 2 new files per event, 700 events, all event in one poll.')
971
972 parser.add_argument(
973 '--tc502',
974 action='store_true',
975 help='TC502 - 700 MEs, SFTP, 50MB files, 2 new files per event, 700 events, all event in one poll.')
976
977 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000978 '--tc510',
979 action='store_true',
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000980 help='TC510 - 700 MEs, SFTP, 1MB files, 1 file per event, 3500 events, 700 event per poll.')
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000981
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000982 parser.add_argument(
983 '--tc511',
984 action='store_true',
985 help='TC511 - 700 MEs, SFTP, 1KB files, 1 file per event, 3500 events, 700 event per poll.')
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000986
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000987 parser.add_argument(
988 '--tc710',
989 action='store_true',
990 help='TC710 - 700 MEs, SFTP, 1MB files, 100 files per event, 3500 events, 35 event per poll.')
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000991
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000992 parser.add_argument(
993 '--tc1100',
994 action='store_true',
995 help='TC1100 - 700 ME, SFTP, 1MB files, 100 files per event, endless number of events, 35 event per poll')
996 parser.add_argument(
997 '--tc1101',
998 action='store_true',
999 help='TC1101 - 700 ME, SFTP, 5MB files, 100 files per event, endless number of events, 35 event per poll')
1000 parser.add_argument(
1001 '--tc1102',
1002 action='store_true',
1003 help='TC1102 - 700 ME, SFTP, 50MB files, 100 files per event, endless number of events, 35 event per poll')
1004
1005 parser.add_argument(
1006 '--tc1200',
1007 action='store_true',
1008 help='TC1200 - 700 ME, SFTP, 1MB files, 100 new files per event, endless number of events, 35 event per poll')
1009 parser.add_argument(
1010 '--tc1201',
1011 action='store_true',
1012 help='TC1201 - 700 ME, SFTP, 5MB files, 100 new files per event, endless number of events, 35 event per poll')
1013 parser.add_argument(
1014 '--tc1202',
1015 action='store_true',
1016 help='TC1202 - 700 ME, SFTP, 50MB files, 100 new files per event, endless number of events, 35 event per poll')
1017
1018 parser.add_argument(
1019 '--tc1300',
1020 action='store_true',
1021 help='TC1300 - 700 ME, SFTP, 1MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1022 parser.add_argument(
1023 '--tc1301',
1024 action='store_true',
1025 help='TC1301 - 700 ME, SFTP, 5MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1026 parser.add_argument(
1027 '--tc1302',
1028 action='store_true',
1029 help='TC1302 - 700 ME, SFTP, 50MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1030
1031
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001032# FTPS TCs with single ME
1033 parser.add_argument(
1034 '--tc200',
1035 action='store_true',
1036 help='TC200 - One ME, FTPS, 1 1MB file, 1 event')
1037 parser.add_argument(
1038 '--tc201',
1039 action='store_true',
1040 help='TC201 - One ME, FTPS, 1 5MB file, 1 event')
1041 parser.add_argument(
1042 '--tc202',
1043 action='store_true',
1044 help='TC202 - One ME, FTPS, 1 50MB file, 1 event')
1045
1046 parser.add_argument(
1047 '--tc210',
1048 action='store_true',
1049 help='TC210 - One ME, FTPS, 1MB files, 1 file per event, 100 events, 1 event per poll.')
1050 parser.add_argument(
1051 '--tc211',
1052 action='store_true',
1053 help='TC211 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll.')
1054 parser.add_argument(
1055 '--tc212',
1056 action='store_true',
1057 help='TC212 - One ME, FTPS, 5MB files, 100 files per event, 100 events, 1 event per poll.')
1058 parser.add_argument(
1059 '--tc213',
1060 action='store_true',
1061 help='TC213 - One ME, FTPS, 1MB files, 100 files per event, 100 events. All events in one poll.')
1062
1063 parser.add_argument(
1064 '--tc220',
1065 action='store_true',
1066 help='TC220 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% of replies each: no response, empty message, slow response, 404-error, malformed json')
1067 parser.add_argument(
1068 '--tc221',
1069 action='store_true',
1070 help='TC221 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files')
1071 parser.add_argument(
1072 '--tc222',
1073 action='store_true',
1074 help='TC222 - One ME, FTPS, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ')
1075
1076 parser.add_argument(
1077 '--tc2000',
1078 action='store_true',
1079 help='TC2000 - One ME, FTPS, 1MB files, 100 files per event, endless number of events, 1 event per poll')
1080 parser.add_argument(
1081 '--tc2001',
1082 action='store_true',
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001083 help='TC2001 - One ME, FTPS, 5MB files, 100 files per event, endless number of events, 1 event per poll')
1084
1085
1086 parser.add_argument(
1087 '--tc2100',
1088 action='store_true',
1089 help='TC2100 - 700 ME, FTPS, 1MB files, 100 files per event, endless number of events, 35 event per poll')
1090 parser.add_argument(
1091 '--tc2101',
1092 action='store_true',
1093 help='TC2101 - 700 ME, FTPS, 5MB files, 100 files per event, endless number of events, 35 event per poll')
1094 parser.add_argument(
1095 '--tc2102',
1096 action='store_true',
1097 help='TC2102 - 700 ME, FTPS, 50MB files, 100 files per event, endless number of events, 35 event per poll')
1098
1099 parser.add_argument(
1100 '--tc2200',
1101 action='store_true',
1102 help='TC2200 - 700 ME, FTPS, 1MB files, 100 new files per event, endless number of events, 35 event per poll')
1103 parser.add_argument(
1104 '--tc2201',
1105 action='store_true',
1106 help='TC2201 - 700 ME, FTPS, 5MB files, 100 new files per event, endless number of events, 35 event per poll')
1107 parser.add_argument(
1108 '--tc2202',
1109 action='store_true',
1110 help='TC2202 - 700 ME, FTPS, 50MB files, 100 new files per event, endless number of events, 35 event per poll')
1111
1112 parser.add_argument(
1113 '--tc2300',
1114 action='store_true',
1115 help='TC2300 - 700 ME, FTPS, 1MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1116 parser.add_argument(
1117 '--tc2301',
1118 action='store_true',
1119 help='TC2301 - 700 ME, FTPS, 5MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1120 parser.add_argument(
1121 '--tc2302',
1122 action='store_true',
1123 help='TC2302 - 700 ME, FTPS, 50MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1124
1125 parser.add_argument(
1126 '--tc600',
1127 action='store_true',
1128 help='TC600 - 700 MEs, FTPS, 1MB files, 2 new files per event, 700 events, all event in one poll.')
1129
1130 parser.add_argument(
1131 '--tc601',
1132 action='store_true',
1133 help='TC601 - 700 MEs, FTPS, 5MB files, 2 new files per event, 700 events, all event in one poll.')
1134
1135 parser.add_argument(
1136 '--tc602',
1137 action='store_true',
1138 help='TC602 - 700 MEs, FTPS, 50MB files, 2 new files per event, 700 events, all event in one poll.')
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001139
1140 parser.add_argument(
1141 '--tc610',
1142 action='store_true',
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001143 help='TC610 - 700 MEs, FTPS, 1MB files, 1 file per event, 3500 events, 700 event per poll.')
1144
1145 parser.add_argument(
1146 '--tc611',
1147 action='store_true',
1148 help='TC611 - 700 MEs, FTPS, 1KB files, 1 file per event, 3500 events, 700 event per poll.')
1149
1150 parser.add_argument(
1151 '--tc810',
1152 action='store_true',
1153 help='TC810 - 700 MEs, FTPS, 1MB files, 100 files per event, 3500 events, 35 event per poll.')
TamasBakai9b780332019-02-15 08:38:16 +00001154
1155 args = parser.parse_args()
1156
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001157
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001158
1159 if args.tc100:
1160 tc_num = "TC# 100"
1161 elif args.tc101:
1162 tc_num = "TC# 101"
1163 elif args.tc102:
1164 tc_num = "TC# 102"
1165
1166 elif args.tc110:
1167 tc_num = "TC# 110"
1168 elif args.tc111:
1169 tc_num = "TC# 111"
1170 elif args.tc112:
1171 tc_num = "TC# 112"
1172 elif args.tc113:
1173 tc_num = "TC# 113"
1174
1175 elif args.tc120:
1176 tc_num = "TC# 120"
1177 elif args.tc121:
1178 tc_num = "TC# 121"
1179 elif args.tc122:
1180 tc_num = "TC# 122"
1181
1182 elif args.tc1000:
1183 tc_num = "TC# 1000"
1184 elif args.tc1001:
1185 tc_num = "TC# 1001"
1186
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001187 elif args.tc1100:
1188 tc_num = "TC# 1100"
1189 elif args.tc1101:
1190 tc_num = "TC# 1101"
1191 elif args.tc1102:
1192 tc_num = "TC# 1102"
1193 elif args.tc1200:
1194 tc_num = "TC# 1200"
1195 elif args.tc1201:
1196 tc_num = "TC# 1201"
1197 elif args.tc1202:
1198 tc_num = "TC# 1202"
1199 elif args.tc1300:
1200 tc_num = "TC# 1300"
1201 elif args.tc1301:
1202 tc_num = "TC# 1301"
1203 elif args.tc1302:
1204 tc_num = "TC# 1302"
1205
1206 elif args.tc500:
1207 tc_num = "TC# 500"
1208 elif args.tc501:
1209 tc_num = "TC# 501"
1210 elif args.tc502:
1211 tc_num = "TC# 502"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001212 elif args.tc510:
1213 tc_num = "TC# 510"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001214 elif args.tc511:
1215 tc_num = "TC# 511"
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001216
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001217 elif args.tc710:
1218 tc_num = "TC# 710"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001219
1220 elif args.tc200:
1221 tc_num = "TC# 200"
1222 elif args.tc201:
1223 tc_num = "TC# 201"
1224 elif args.tc202:
1225 tc_num = "TC# 202"
1226
1227 elif args.tc210:
1228 tc_num = "TC# 210"
1229 elif args.tc211:
1230 tc_num = "TC# 211"
1231 elif args.tc212:
1232 tc_num = "TC# 212"
1233 elif args.tc213:
1234 tc_num = "TC# 213"
1235
1236 elif args.tc220:
1237 tc_num = "TC# 220"
1238 elif args.tc221:
1239 tc_num = "TC# 221"
1240 elif args.tc222:
1241 tc_num = "TC# 222"
1242
1243 elif args.tc2000:
1244 tc_num = "TC# 2000"
1245 elif args.tc2001:
1246 tc_num = "TC# 2001"
1247
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001248 elif args.tc2100:
1249 tc_num = "TC# 2100"
1250 elif args.tc2101:
1251 tc_num = "TC# 2101"
1252 elif args.tc2102:
1253 tc_num = "TC# 2102"
1254 elif args.tc2200:
1255 tc_num = "TC# 2200"
1256 elif args.tc2201:
1257 tc_num = "TC# 2201"
1258 elif args.tc2202:
1259 tc_num = "TC# 2202"
1260 elif args.tc2300:
1261 tc_num = "TC# 2300"
1262 elif args.tc2301:
1263 tc_num = "TC# 2301"
1264 elif args.tc2302:
1265 tc_num = "TC# 2302"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001266
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001267 elif args.tc600:
1268 tc_num = "TC# 600"
1269 elif args.tc601:
1270 tc_num = "TC# 601"
1271 elif args.tc602:
1272 tc_num = "TC# 602"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001273 elif args.tc610:
1274 tc_num = "TC# 610"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001275 elif args.tc611:
1276 tc_num = "TC# 611"
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001277
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001278 elif args.tc810:
1279 tc_num = "TC# 810"
TamasBakai9b780332019-02-15 08:38:16 +00001280
1281 else:
1282 print("No TC was defined")
1283 print("use --help for usage info")
1284 sys.exit()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001285
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001286 print("TC num: " + tc_num)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001287
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001288 print("Using " + sftp_ip + " for sftp server address in file urls.")
1289 print("Using " + ftps_ip + " for ftps server address in file urls.")
1290
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001291 app.run(port=HOST_PORT, host=HOST_IP)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001292