blob: 51e0badef577259447bf0918607f00f1d2c66ac9 [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
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000017sftp_hosts=[]
18sftp_ports=[]
19ftps_hosts=[]
20ftps_ports=[]
TamasBakaifa357df2019-08-15 08:25:27 +000021num_ftp_servers=1
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000022
23def sumList(ctrArray):
24 tmp=0
25 for i in range(len(ctrArray)):
26 tmp=tmp+ctrArray[i];
27
28 return str(tmp);
29
30def sumListLength(ctrArray):
31 tmp=0
32 for i in range(len(ctrArray)):
33 tmp=tmp+len(ctrArray[i]);
34
35 return str(tmp);
BjornMagnussonXAf4e18362019-04-10 13:04:08 +000036
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000037#Test function to check server running
38@app.route('/',
39 methods=['GET'])
40def index():
41 return 'Hello world'
TamasBakai9b780332019-02-15 08:38:16 +000042
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000043#Returns the list of configured groups
44@app.route('/groups',
45 methods=['GET'])
46def group_ids():
47 global configuredGroups
48 return configuredGroups
49
50#Returns the list of configured changeids
51@app.route('/changeids',
52 methods=['GET'])
53def change_ids():
54 global configuredChangeIds
55 return configuredChangeIds
56
57#Returns the list of configured fileprefixes
58@app.route('/fileprefixes',
59 methods=['GET'])
60def fileprefixes():
61 global configuredPrefixes
62 return configuredPrefixes
63
64
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000065#Returns number of polls
66@app.route('/ctr_requests',
67 methods=['GET'])
68def counter_requests():
69 global ctr_requests
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000070 return sumList(ctr_requests)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000071
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000072#Returns number of polls for all groups
73@app.route('/groups/ctr_requests',
74 methods=['GET'])
75def group_counter_requests():
76 global ctr_requests
77 global groupNames
78 tmp=''
79 for i in range(len(groupNames)):
80 if (i > 0):
81 tmp=tmp+','
82 tmp=tmp+str(ctr_requests[i])
83 return tmp
84
85#Returns the total number of polls for a group
86@app.route('/ctr_requests/<groupId>',
87 methods=['GET'])
88def counter_requests_group(groupId):
89 global ctr_requests
90 global groupNameIndexes
91 return str(ctr_requests[groupNameIndexes[groupId]])
92
93#Returns number of poll replies
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000094@app.route('/ctr_responses',
95 methods=['GET'])
96def counter_responses():
97 global ctr_responses
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000098 return sumList(ctr_responses)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000099
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000100#Returns number of poll replies for all groups
101@app.route('/groups/ctr_responses',
102 methods=['GET'])
103def group_counter_responses():
104 global ctr_responses
105 global groupNames
106 tmp=''
107 for i in range(len(groupNames)):
108 if (i > 0):
109 tmp=tmp+','
110 tmp=tmp+str(ctr_responses[i])
111 return tmp
112
113#Returns the total number of poll replies for a group
114@app.route('/ctr_responses/<groupId>',
115 methods=['GET'])
116def counter_responses_group(groupId):
117 global ctr_responses
118 global groupNameIndexes
119 return str(ctr_responses[groupNameIndexes[groupId]])
120
121#Returns the total number of files
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000122@app.route('/ctr_files',
123 methods=['GET'])
124def counter_files():
125 global ctr_files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000126 return sumList(ctr_files)
127
128#Returns the total number of file for all groups
129@app.route('/groups/ctr_files',
130 methods=['GET'])
131def group_counter_files():
132 global ctr_files
133 global groupNames
134 tmp=''
135 for i in range(len(groupNames)):
136 if (i > 0):
137 tmp=tmp+','
138 tmp=tmp+str(ctr_files[i])
139 return tmp
140
141#Returns the total number of files for a group
142@app.route('/ctr_files/<groupId>',
143 methods=['GET'])
144def counter_files_group(groupId):
145 global ctr_files
146 global groupNameIndexes
147 return str(ctr_files[groupNameIndexes[groupId]])
148
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000149
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000150#Returns number of unique files
151@app.route('/ctr_unique_files',
152 methods=['GET'])
153def counter_uniquefiles():
154 global fileMap
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000155 return sumListLength(fileMap)
156
157#Returns number of unique files for all groups
158@app.route('/groups/ctr_unique_files',
159 methods=['GET'])
160def group_counter_uniquefiles():
161 global fileMap
162 global groupNames
163 tmp=''
164 for i in range(len(groupNames)):
165 if (i > 0):
166 tmp=tmp+','
167 tmp=tmp+str(len(fileMap[i]))
168 return tmp
169
170#Returns the total number of unique files for a group
171@app.route('/ctr_unique_files/<groupId>',
172 methods=['GET'])
173def counter_uniquefiles_group(groupId):
174 global fileMap
175 global groupNameIndexes
176 return str(len(fileMap[groupNameIndexes[groupId]]))
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000177
178#Returns tc info
179@app.route('/tc_info',
180 methods=['GET'])
181def testcase_info():
182 global tc_num
183 return tc_num
184
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000185#Returns number of events
186@app.route('/ctr_events',
187 methods=['GET'])
188def counter_events():
189 global ctr_events
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000190 return sumList(ctr_events)
191
192#Returns number of events for all groups
193@app.route('/groups/ctr_events',
194 methods=['GET'])
195def group_counter_events():
196 global ctr_events
197 global groupNames
198 tmp=''
199 for i in range(len(groupNames)):
200 if (i > 0):
201 tmp=tmp+','
202 tmp=tmp+str(ctr_events[i])
203 return tmp
204
205#Returns the total number of events for a group
206@app.route('/ctr_events/<groupId>',
207 methods=['GET'])
208def counter_events_group(groupId):
209 global ctr_events
210 global groupNameIndexes
211 return str(ctr_events[groupNameIndexes[groupId]])
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000212
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000213#Returns execution time in mm:ss
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000214@app.route('/execution_time',
215 methods=['GET'])
216def exe_time():
217 global startTime
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000218
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000219 stopTime = time.time()
220 minutes, seconds = divmod(stopTime-startTime, 60)
221 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
222
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000223#Returns the timestamp for first poll
224@app.route('/exe_time_first_poll',
225 methods=['GET'])
226def exe_time_first_poll():
227 global firstPollTime
228
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000229 tmp = 0
230 for i in range(len(groupNames)):
231 if (firstPollTime[i] > tmp):
232 tmp = firstPollTime[i]
233
234 if (tmp == 0):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000235 return "--:--"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000236 minutes, seconds = divmod(time.time()-tmp, 60)
237 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
238
239#Returns the timestamp for first poll for all groups
240@app.route('/groups/exe_time_first_poll',
241 methods=['GET'])
242def group_exe_time_first_poll():
243 global firstPollTime
244 global groupNames
245
246 tmp=''
247 for i in range(len(groupNames)):
248 if (i > 0):
249 tmp=tmp+','
250 if (firstPollTime[i] == 0):
251 tmp=tmp+ "--:--"
252 else:
253 minutes, seconds = divmod(time.time()-firstPollTime[i], 60)
254 tmp=tmp+"{:0>2}:{:0>2}".format(int(minutes),int(seconds))
255 return tmp
256
257#Returns the timestamp for first poll for a group
258@app.route('/exe_time_first_poll/<groupId>',
259 methods=['GET'])
260def exe_time_first_poll_group(groupId):
261 global ctr_requests
262 global groupNameIndexes
263
264 if (firstPollTime[groupNameIndexes[groupId]] == 0):
265 return "--:--"
266 minutes, seconds = divmod(time.time()-firstPollTime[groupNameIndexes[groupId]], 60)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000267 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
268
269#Starts event delivery
270@app.route('/start',
271 methods=['GET'])
272def start():
273 global runningState
274 runningState="Started"
275 return runningState
276
277#Stops event delivery
278@app.route('/stop',
279 methods=['GET'])
280def stop():
281 global runningState
282 runningState="Stopped"
283 return runningState
284
285#Returns the running state
286@app.route('/status',
287 methods=['GET'])
288def status():
289 global runningState
290 return runningState
291
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000292#Returns number of unique PNFs
293@app.route('/ctr_unique_PNFs',
294 methods=['GET'])
295def counter_uniquePNFs():
296 global pnfMap
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000297 return sumListLength(pnfMap)
298
299#Returns number of unique PNFs for all groups
300@app.route('/groups/ctr_unique_PNFs',
301 methods=['GET'])
302def group_counter_uniquePNFs():
303 global pnfMap
304 global groupNames
305 tmp=''
306 for i in range(len(groupNames)):
307 if (i > 0):
308 tmp=tmp+','
309 tmp=tmp+str(len(pnfMap[i]))
310 return tmp
311
312#Returns the unique PNFs for a group
313@app.route('/ctr_unique_PNFs/<groupId>',
314 methods=['GET'])
315def counter_uniquePNFs_group(groupId):
316 global pnfMap
317 global groupNameIndexes
318 return str(len(pnfMap[groupNameIndexes[groupId]]))
319
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000320
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000321#Messages polling function
TamasBakai9b780332019-02-15 08:38:16 +0000322@app.route(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000323 "/events/unauthenticated.VES_NOTIFICATION_OUTPUT/<consumerGroup>/<consumerId>",
TamasBakai9b780332019-02-15 08:38:16 +0000324 methods=['GET'])
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000325def MR_reply(consumerGroup, consumerId):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000326 global ctr_requests
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000327 global ctr_responses
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000328 global args
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000329 global runningState
330 global firstPollTime
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000331 global groupNameIndexes
332 global changeIds
333 global filePrefixes
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000334
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000335 groupIndex = groupNameIndexes[consumerGroup]
336 print("Setting groupIndex: " + str(groupIndex))
TamasBakai9b780332019-02-15 08:38:16 +0000337
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000338 reqCtr = ctr_requests[groupIndex]
339 changeId = changeIds[groupIndex][reqCtr%len(changeIds[groupIndex])]
340 print("Setting changeid: " + changeId)
341 filePrefix = filePrefixes[changeId]
342 print("Setting file name prefix: " + filePrefix)
343
344 if (firstPollTime[groupIndex] == 0):
345 firstPollTime[groupIndex] = time.time()
346
347 ctr_requests[groupIndex] = ctr_requests[groupIndex] + 1
348 print("MR: poll request#: " + str(ctr_requests[groupIndex]))
TamasBakai9b780332019-02-15 08:38:16 +0000349
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000350 if (runningState == "Stopped"):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000351 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000352 return buildOkResponse("[]")
353
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000354
355
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000356 if args.tc100:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000357 return tc100(groupIndex, changeId, filePrefix, "sftp", "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000358 elif args.tc101:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000359 return tc100(groupIndex, changeId, filePrefix, "sftp", "5MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000360 elif args.tc102:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000361 return tc100(groupIndex, changeId, filePrefix, "sftp", "50MB")
TamasBakai9b780332019-02-15 08:38:16 +0000362
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000363 elif args.tc110:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000364 return tc110(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000365 elif args.tc111:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000366 return tc111(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000367 elif args.tc112:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000368 return tc112(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000369 elif args.tc113:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000370 return tc113(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000371
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000372 elif args.tc120:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000373 return tc120(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000374 elif args.tc121:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000375 return tc121(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000376 elif args.tc122:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000377 return tc122(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000378
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000379 elif args.tc1000:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000380 return tc1000(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000381 elif args.tc1001:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000382 return tc1001(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000383
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000384 elif args.tc1100:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000385 return tc1100(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000386 elif args.tc1101:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000387 return tc1100(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000388 elif args.tc1102:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000389 return tc1100(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000390 elif args.tc1200:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000391 return tc1200(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000392 elif args.tc1201:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000393 return tc1200(groupIndex, changeId, filePrefix, "sftp","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000394 elif args.tc1202:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000395 return tc1200(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000396 elif args.tc1300:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000397 return tc1300(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000398 elif args.tc1301:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000399 return tc1300(groupIndex, changeId, filePrefix, "sftp","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000400 elif args.tc1302:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000401 return tc1300(groupIndex, changeId, filePrefix, "sftp","50MB")
402
403 elif args.tc1500:
404 return tc1500(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000405
406 elif args.tc500:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000407 return tc500(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000408 elif args.tc501:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000409 return tc500(groupIndex, changeId, filePrefix, "sftp","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000410 elif args.tc502:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000411 return tc500(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000412 elif args.tc510:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000413 return tc510(groupIndex, changeId, filePrefix, "sftp", "1MB")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000414 elif args.tc511:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000415 return tc511(groupIndex, changeId, filePrefix, "sftp", "1KB")
416
417 elif args.tc550:
418 return tc510(groupIndex, changeId, filePrefix, "sftp", "50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000419
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000420 elif args.tc710:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000421 return tc710(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000422
423
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000424 elif args.tc200:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000425 return tc100(groupIndex, changeId, filePrefix, "ftps", "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000426 elif args.tc201:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000427 return tc100(groupIndex, changeId, filePrefix, "ftps", "5MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000428 elif args.tc202:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000429 return tc100(groupIndex, changeId, filePrefix, "ftps", "50MB")
TamasBakai9b780332019-02-15 08:38:16 +0000430
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000431 elif args.tc210:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000432 return tc110(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000433 elif args.tc211:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000434 return tc111(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000435 elif args.tc212:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000436 return tc112(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000437 elif args.tc213:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000438 return tc113(groupIndex, changeId, filePrefix, "ftps")
TamasBakai9b780332019-02-15 08:38:16 +0000439
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000440 elif args.tc220:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000441 return tc120(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000442 elif args.tc221:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000443 return tc121(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000444 elif args.tc222:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000445 return tc122(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000446
447 elif args.tc2000:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000448 return tc1000(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000449 elif args.tc2001:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000450 return tc1001(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000451
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000452 elif args.tc2100:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000453 return tc1100(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000454 elif args.tc2101:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000455 return tc1100(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000456 elif args.tc2102:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000457 return tc1100(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000458 elif args.tc2200:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000459 return tc1200(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000460 elif args.tc2201:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000461 return tc1200(groupIndex, changeId, filePrefix, "ftps","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000462 elif args.tc2202:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000463 return tc1200(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000464 elif args.tc2300:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000465 return tc1300(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000466 elif args.tc2301:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000467 return tc1300(groupIndex, changeId, filePrefix, "ftps","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000468 elif args.tc2302:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000469 return tc1300(groupIndex, changeId, filePrefix, "ftps","50MB")
470
471 elif args.tc2500:
472 return tc1500(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000473
474 elif args.tc600:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000475 return tc500(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000476 elif args.tc601:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000477 return tc500(groupIndex, changeId, filePrefix, "ftps","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000478 elif args.tc602:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000479 return tc500(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000480 elif args.tc610:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000481 return tc510(groupIndex, changeId, filePrefix, "ftps", "1MB")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000482 elif args.tc611:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000483 return tc511(groupIndex, changeId, filePrefix, "ftps", "1KB")
484 elif args.tc650:
485 return tc510(groupIndex, changeId, filePrefix, "ftps", "50MB")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000486 elif args.tc810:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000487 return tc710(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000488
489
490#### Test case functions
491
492
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000493def tc100(groupIndex, changeId, filePrefix, ftpType, fileSize):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000494 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000495 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000496
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000497
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000498 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
499
500 if (ctr_responses[groupIndex] > 1):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000501 return buildOkResponse("[]")
502
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000503 seqNr = (ctr_responses[groupIndex]-1)
504 nodeIndex=0
505 nodeName = createNodeName(nodeIndex)
506 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, fileSize)
507 msg = getEventHead(groupIndex, changeId, nodeName) + getEventName(fileName,ftpType,"onap","pano",nodeIndex) + getEventEnd()
508 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
509 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000510 return buildOkResponse("["+msg+"]")
511
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000512#def tc101(groupIndex, ftpType):
513# global ctr_responses
514# global ctr_events
515#
516# ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
517#
518# if (ctr_responses[groupIndex] > 1):
519# return buildOkResponse("[]")
520#
521# seqNr = (ctr_responses[groupIndex]-1)
522# nodeName = createNodeName(0)
523# fileName = createFileName(groupIndex, nodeName, seqNr, "5MB")
524# msg = getEventHead(groupIndex, nodeName) + getEventName(fileName,ftpType,"onap","pano") + getEventEnd()
525# fileMap[groupIndex][seqNr] = seqNr
526# ctr_events[groupIndex] = ctr_events[groupIndex]+1
527# return buildOkResponse("["+msg+"]")
528#
529#def tc102(groupIndex, ftpType):
530# global ctr_responses
531# global ctr_events
532#
533# ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
534#
535# if (ctr_responses[groupIndex] > 1):
536# return buildOkResponse("[]")
537#
538# seqNr = (ctr_responses[groupIndex]-1)
539# nodeName = createNodeName(0)
540# fileName = createFileName(groupIndex, nodeName, seqNr, "50MB")
541# msg = getEventHead(groupIndex, nodeName) + getEventName(fileName,ftpType,"onap","pano") + getEventEnd()
542# fileMap[groupIndex][seqNr] = seqNr
543# ctr_events[groupIndex] = ctr_events[groupIndex]+1
544# return buildOkResponse("["+msg+"]")
545
546def tc110(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000547 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000548 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000549
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000550
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000551 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
552
553 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000554 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000555
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000556 seqNr = (ctr_responses[groupIndex]-1)
557 nodeIndex=0
558 nodeName = createNodeName(nodeIndex)
559 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
560 msg = getEventHead(groupIndex, changeId, nodeName) + getEventName(fileName,ftpType,"onap","pano",nodeIndex) + getEventEnd()
561 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
562 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000563 return buildOkResponse("["+msg+"]")
564
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000565def tc111(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000566 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000567 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000568
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000569
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000570 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
571
572 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000573 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000574
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000575 nodeIndex=0
576 nodeName = createNodeName(nodeIndex)
577 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000578
579 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000580 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000581 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000582 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
583 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
584 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000585
586 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000587 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000588
589 return buildOkResponse("["+msg+"]")
590
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000591def tc112(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000592 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000593 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000594
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000595
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000596 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
597
598 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000599 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000600
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000601 nodeIndex=0
602 nodeName = createNodeName(nodeIndex)
603 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000604
605 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000606 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000607 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000608 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "5MB")
609 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
610 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000611
612 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000613 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000614
615 return buildOkResponse("["+msg+"]")
616
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000617def tc113(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000618 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000619 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000620
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000621
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000622 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
623
624 if (ctr_responses[groupIndex] > 1):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000625 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000626
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000627 nodeIndex=0
628 nodeName = createNodeName(nodeIndex)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000629 msg = ""
630
631 for evts in range(100): # build 100 evts
632 if (evts > 0):
633 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000634 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000635 for i in range(100): # build 100 files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000636 seqNr = i+evts+100*(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000637 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000638 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
639 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
640 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000641
642 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000643 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000644
645 return buildOkResponse("["+msg+"]")
646
647
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000648def tc120(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000649 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000650 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000651
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000652
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000653 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000654
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000655 nodeIndex=0
656 nodeName = createNodeName(nodeIndex)
657
658 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000659 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000660
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000661 if (ctr_responses[groupIndex] % 10 == 2):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000662 return # Return nothing
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000663
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000664 if (ctr_responses[groupIndex] % 10 == 3):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000665 return buildOkResponse("") # Return empty message
666
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000667 if (ctr_responses[groupIndex] % 10 == 4):
668 return buildOkResponse(getEventHead(groupIndex, changeId, nodeName)) # Return part of a json event
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000669
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000670 if (ctr_responses[groupIndex] % 10 == 5):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000671 return buildEmptyResponse(404) # Return empty message with status code
672
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000673 if (ctr_responses[groupIndex] % 10 == 6):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000674 sleep(60)
675
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000676
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000677 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000678
679 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000680 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000681 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000682 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
683 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
684 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000685
686 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000687 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000688
689 return buildOkResponse("["+msg+"]")
690
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000691def tc121(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000692 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000693 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000694
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000695
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000696 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
697
698 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000699 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000700
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000701 nodeIndex=0
702 nodeName = createNodeName(nodeIndex)
703 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000704
705 fileName = ""
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000706 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000707 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000708 if (seqNr%10 == 0): # Every 10th file is "missing"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000709 fileName = createMissingFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000710 else:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000711 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
712 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000713
714 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000715 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000716
717 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000718 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000719
720 return buildOkResponse("["+msg+"]")
721
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000722def tc122(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000723 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000724 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000725
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000726
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000727 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
728
729 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000730 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000731
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000732 nodeIndex=0
733 nodeName = createNodeName(nodeIndex)
734 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000735
736 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000737 fileName = createFileName(groupIndex, filePrefix, nodeName, 0, "1MB") # All files identical names
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000738 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000739 msg = msg + getEventName(fileName,ftpType,"onap","pano", nodeIndex)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000740
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000741 fileMap[groupIndex][0] = 0
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000742 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000743 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000744
745 return buildOkResponse("["+msg+"]")
746
747
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000748def tc1000(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000749 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000750 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000751
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000752
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000753 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
754
755 nodeIndex=0
756 nodeName = createNodeName(nodeIndex)
757 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000758
759 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000760 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000761 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000762 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
763 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
764 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000765
766 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000767 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000768
769 return buildOkResponse("["+msg+"]")
770
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000771def tc1001(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000772 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000773 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000774
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000775
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000776 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
777
778 nodeIndex=0
779 nodeName = createNodeName(nodeIndex)
780 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000781
782 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000783 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000784 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000785 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "5MB")
786 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
787 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000788
789 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000790 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000791
792 return buildOkResponse("["+msg+"]")
793
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000794
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000795def tc1100(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000796 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000797 global ctr_events
798
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000799
800 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000801
802 msg = ""
803
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000804 batch = (ctr_responses[groupIndex]-1)%20;
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000805
806 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
807 if (pnfs > 0):
808 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000809 nodeIndex=pnfs + batch*35
810 nodeName = createNodeName(nodeIndex)
811 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000812
813 for i in range(100): # 100 files per event
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000814 seqNr = i + int((ctr_responses[groupIndex]-1)/20);
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000815 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000816 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
817 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000818 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000819 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000820
821 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000822 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000823
824 return buildOkResponse("["+msg+"]")
825
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000826def tc1200(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000827 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000828 global ctr_events
829
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000830
831 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000832
833 msg = ""
834
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000835 batch = (ctr_responses[groupIndex]-1)%20;
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000836
837 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
838 if (pnfs > 0):
839 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000840 nodeIndex=pnfs + batch*35
841 nodeName = createNodeName(nodeIndex)
842 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000843
844 for i in range(100): # 100 files per event, all new files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000845 seqNr = i+100 * int((ctr_responses[groupIndex]-1)/20);
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000846 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000847 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
848 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000849 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000850 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000851
852 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000853 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000854
855 return buildOkResponse("["+msg+"]")
856
857
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000858def tc1300(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000859 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000860 global ctr_events
861 global rop_counter
862 global rop_timestamp
863
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000864 if (rop_counter == 0):
865 rop_timestamp = time.time()
866
867 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000868
869 #Start a event deliver for all 700 nodes every 15min
870 rop = time.time()-rop_timestamp
871 if ((rop < 900) & (rop_counter%20 == 0) & (rop_counter != 0)):
872 return buildOkResponse("[]")
873 else:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000874 if (rop_counter%20 == 0) & (rop_counter > 0):
875 rop_timestamp = rop_timestamp+900
876
877 rop_counter = rop_counter+1
878
879 msg = ""
880
881 batch = (rop_counter-1)%20;
882
883 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
884 if (pnfs > 0):
885 msg = msg + ","
886 nodeIndex=pnfs + batch*35
887 nodeName = createNodeName(nodeIndex)
888 msg = msg + getEventHead(groupIndex, changeId, nodeName)
889
890 for i in range(100): # 100 files per event
891 seqNr = i + int((rop_counter-1)/20);
892 if i != 0: msg = msg + ","
893 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
894 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
895 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
896 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
897
898 msg = msg + getEventEnd()
899 ctr_events[groupIndex] = ctr_events[groupIndex]+1
900
901 return buildOkResponse("["+msg+"]")
902
903def tc1500(groupIndex, changeId, filePrefix, ftpType, filesize):
904 global ctr_responses
905 global ctr_events
906 global rop_counter
907 global rop_timestamp
908
909 if (rop_counter == 0):
910 rop_timestamp = time.time()
911
912 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
913
914 if (ctr_responses[groupIndex] <= 2000 ): #first 25h of event doess not care of 15min rop timer
915
916 msg = ""
917
918 batch = (ctr_responses[groupIndex]-1)%20;
919
920 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
921 if (pnfs > 0):
922 msg = msg + ","
923
924 nodeIndex=pnfs + batch*35
925 nodeName = createNodeName(nodeIndex)
926 msg = msg + getEventHead(groupIndex, changeId, nodeName)
927
928 for i in range(100): # 100 files per event
929 seqNr = i + int((ctr_responses[groupIndex]-1)/20);
930 if i != 0: msg = msg + ","
931 if (seqNr < 100):
932 fileName = createMissingFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
933 else:
934 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
935 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
936 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
937 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
938
939
940 msg = msg + getEventEnd()
941 ctr_events[groupIndex] = ctr_events[groupIndex]+1
942
943 rop_counter = rop_counter+1
944 return buildOkResponse("["+msg+"]")
945
946 #Start an event delivery for all 700 nodes every 15min
947 rop = time.time()-rop_timestamp
948 if ((rop < 900) & (rop_counter%20 == 0) & (rop_counter != 0)):
949 return buildOkResponse("[]")
950 else:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000951 if (rop_counter%20 == 0):
952 rop_timestamp = time.time()
953
954 rop_counter = rop_counter+1
955
956 msg = ""
957
958 batch = (rop_counter-1)%20;
959
960 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
961 if (pnfs > 0):
962 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000963 nodeIndex=pnfs + batch*35
964 nodeName = createNodeName(nodeIndex)
965 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000966
967 for i in range(100): # 100 files per event
968 seqNr = i + int((rop_counter-1)/20);
969 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000970 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
971 msg = msg + getEventName(fileName,ftpType,"onap","pano", nodeIndex)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000972 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000973 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000974
975 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000976 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000977
978 return buildOkResponse("["+msg+"]")
979
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000980def tc500(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000981 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000982 global ctr_events
983
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000984
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000985 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
986
987 if (ctr_responses[groupIndex] > 1):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000988 return buildOkResponse("[]")
989
990 msg = ""
991
992
993 for pnfs in range(700):
994 if (pnfs > 0):
995 msg = msg + ","
996 nodeName = createNodeName(pnfs)
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000997 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000998
999 for i in range(2):
1000 seqNr = i;
1001 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001002 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
1003 msg = msg + getEventName(fileName,ftpType,"onap","pano",pnfs)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001004 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001005 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001006
1007 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001008 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001009
1010 return buildOkResponse("["+msg+"]")
1011
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001012def tc510(groupIndex, changeId, filePrefix, ftpType, fileSize):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001013 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001014 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001015
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001016
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001017 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
1018
1019 if (ctr_responses[groupIndex] > 5):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001020 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001021
1022 msg = ""
1023
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001024 for pnfs in range(700): # build events for 700 MEs
1025 if (pnfs > 0):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001026 msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001027 nodeName = createNodeName(pnfs)
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001028 msg = msg + getEventHead(groupIndex, changeId, nodeName)
1029 seqNr = (ctr_responses[groupIndex]-1)
1030 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, fileSize)
1031 msg = msg + getEventName(fileName,ftpType,"onap","pano",pnfs)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001032 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001033 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001034 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001035 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001036
1037 return buildOkResponse("["+msg+"]")
1038
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001039def tc511(groupIndex, changeId, filePrefix, ftpType, fileSize):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001040 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001041 global ctr_events
1042
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001043
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001044 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
1045
1046 if (ctr_responses[groupIndex] > 5):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001047 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001048
1049 msg = ""
1050
1051 for pnfs in range(700): # build events for 700 MEs
1052 if (pnfs > 0):
1053 msg = msg + ","
1054 nodeName = createNodeName(pnfs)
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001055 msg = msg + getEventHead(groupIndex, changeId, nodeName)
1056 seqNr = (ctr_responses[groupIndex]-1)
1057 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, fileSize)
1058 msg = msg + getEventName(fileName,ftpType,"onap","pano",pnfs)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001059 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001060 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001061 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001062 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001063
1064 return buildOkResponse("["+msg+"]")
1065
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001066def tc710(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001067 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001068 global ctr_events
1069
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001070
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001071 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
1072
1073 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001074 return buildOkResponse("[]")
1075
1076 msg = ""
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001077
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001078 batch = (ctr_responses[groupIndex]-1)%20;
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001079
1080 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
1081 if (pnfs > 0):
1082 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001083 nodeIndex=pnfs + batch*35
1084 nodeName = createNodeName(nodeIndex)
1085 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001086
1087 for i in range(100): # 100 files per event
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001088 seqNr = i + int((ctr_responses[groupIndex]-1)/20);
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001089 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001090 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
1091 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001092 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001093 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001094
1095 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001096 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001097
1098 return buildOkResponse("["+msg+"]")
1099
1100
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001101#### Functions to build json messages and respones ####
1102
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001103def createNodeName(index):
1104 return "PNF"+str(index);
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001105
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001106def createFileName(groupIndex, filePrefix, nodeName, index, size):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001107 global ctr_files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001108 ctr_files[groupIndex] = ctr_files[groupIndex] + 1
1109 return filePrefix+"20000626.2315+0200-2330+0200_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz";
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001110
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001111def createMissingFileName(groupIndex, filePrefix, nodeName, index, size):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001112 global ctr_files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001113 ctr_files[groupIndex] = ctr_files[groupIndex] + 1
1114 return filePrefix+"MissingFile_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz";
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001115
1116
1117# Function to build fixed beginning of an event
1118
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001119def getEventHead(groupIndex, changeId, nodename):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001120 global pnfMap
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001121 pnfMap[groupIndex].add(nodename)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001122 headStr = """
1123 {
TamasBakai9b780332019-02-15 08:38:16 +00001124 "event": {
1125 "commonEventHeader": {
1126 "startEpochMicrosec": 8745745764578,
1127 "eventId": "FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1",
1128 "timeZoneOffset": "UTC+05.30",
1129 "internalHeaderFields": {
1130 "collectorTimeStamp": "Tue, 09 18 2018 10:56:52 UTC"
1131 },
1132 "priority": "Normal",
1133 "version": "4.0.1",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001134 "reportingEntityName": \"""" + nodename + """",
TamasBakai9b780332019-02-15 08:38:16 +00001135 "sequence": 0,
1136 "domain": "notification",
1137 "lastEpochMicrosec": 8745745764578,
1138 "eventName": "Noti_RnNode-Ericsson_FileReady",
1139 "vesEventListenerVersion": "7.0.1",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001140 "sourceName": \"""" + nodename + """"
TamasBakai9b780332019-02-15 08:38:16 +00001141 },
1142 "notificationFields": {
1143 "notificationFieldsVersion": "2.0",
1144 "changeType": "FileReady",
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001145 "changeIdentifier": \"""" + changeId + """",
TamasBakai9b780332019-02-15 08:38:16 +00001146 "arrayOfNamedHashMap": [
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001147 """
1148 return headStr
1149
1150# Function to build the variable part of an event
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001151def getEventName(fn,type,user,passwd, nodeIndex):
1152 nodeIndex=nodeIndex%num_ftp_servers
1153 port = sftp_ports[nodeIndex]
1154 ip = sftp_hosts[nodeIndex]
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001155 if (type == "ftps"):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001156 port = ftps_ports[nodeIndex]
1157 ip = ftps_hosts[nodeIndex]
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001158
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001159 nameStr = """{
1160 "name": \"""" + fn + """",
TamasBakai9b780332019-02-15 08:38:16 +00001161 "hashMap": {
1162 "fileFormatType": "org.3GPP.32.435#measCollec",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001163 "location": \"""" + type + """://""" + user + """:""" + passwd + """@""" + ip + """:""" + str(port) + """/""" + fn + """",
TamasBakai9b780332019-02-15 08:38:16 +00001164 "fileFormatVersion": "V10",
1165 "compression": "gzip"
1166 }
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001167 } """
1168 return nameStr
1169
1170# Function to build fixed end of an event
1171def getEventEnd():
1172 endStr = """
TamasBakai9b780332019-02-15 08:38:16 +00001173 ]
1174 }
1175 }
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001176 }
1177 """
1178 return endStr
TamasBakai9b780332019-02-15 08:38:16 +00001179
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001180# Function to build an OK reponse from a message string
1181def buildOkResponse(msg):
1182 response = app.response_class(
1183 response=str.encode(msg),
1184 status=200,
1185 mimetype='application/json')
1186 return response
TamasBakai9b780332019-02-15 08:38:16 +00001187
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001188# Function to build an empty message with status
1189def buildEmptyResponse(status_code):
1190 response = app.response_class(
1191 response=str.encode(""),
1192 status=status_code,
1193 mimetype='application/json')
1194 return response
TamasBakai9b780332019-02-15 08:38:16 +00001195
1196
1197if __name__ == "__main__":
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001198
1199 # IP addresses to use for ftp servers, using localhost if not env var is set
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001200 sftp_sims = os.environ.get('SFTP_SIMS', 'localhost:1022')
1201 ftps_sims = os.environ.get('FTPS_SIMS', 'localhost:21')
1202 num_ftp_servers = int(os.environ.get('NUM_FTP_SERVERS', 1))
1203
1204 print("Configured sftp sims: " + sftp_sims)
1205 print("Configured ftps sims: " + ftps_sims)
1206 print("Configured number of ftp servers: " + str(num_ftp_servers))
1207
1208 tmp=sftp_sims.split(',')
1209 for i in range(len(tmp)):
1210 hp=tmp[i].split(':')
1211 sftp_hosts.append(hp[0])
1212 sftp_ports.append(hp[1])
1213
1214 tmp=ftps_sims.split(',')
1215 for i in range(len(tmp)):
1216 hp=tmp[i].split(':')
1217 ftps_hosts.append(hp[0])
1218 ftps_ports.append(hp[1])
1219
1220 groups = os.environ.get('MR_GROUPS', 'OpenDcae-c12:PM_MEAS_FILES')
TamasBakaifa357df2019-08-15 08:25:27 +00001221 print("Groups detected: " + groups )
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001222 configuredPrefixes = os.environ.get('MR_FILE_PREFIX_MAPPING', 'PM_MEAS_FILES:A')
1223
1224 if (len(groups) == 0 ):
1225 groups='OpenDcae-c12:PM_MEAS_FILES'
1226 print("Using default group: " + groups)
1227 else:
1228 print("Configured groups: " + groups)
1229
1230 if (len(configuredPrefixes) == 0 ):
1231 configuredPrefixes='PM_MEAS_FILES:A'
1232 print("Using default changeid to file prefix mapping: " + configuredPrefixes)
1233 else:
1234 print("Configured changeid to file prefix mapping: " + configuredPrefixes)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001235
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001236 #Counters
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001237 ctr_responses = []
1238 ctr_requests = []
1239 ctr_files=[]
1240 ctr_events = []
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001241 startTime = time.time()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001242 firstPollTime = []
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001243 runningState = "Started"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001244 #Keeps all responded file names
1245 fileMap = []
1246 #Keeps all responded PNF names
1247 pnfMap = []
1248 #Handles rop periods for tests that deliveres events every 15 min
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001249 rop_counter = 0
1250 rop_timestamp = time.time()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001251
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001252 #List of configured group names
1253 groupNames = []
1254 #Mapping between group name and index in groupNames
1255 groupNameIndexes = {}
1256 #String of configured groups
1257 configuredGroups = ""
1258 #String of configured change identifiers
1259 configuredChangeIds = ""
1260 #List of changed identifiers
1261 changeIds = []
1262 #List of filePrefixes
1263 filePrefixes = {}
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001264
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001265 tmp=groups.split(',')
1266 for i in range(len(tmp)):
1267 g=tmp[i].split(':')
1268 for j in range(len(g)):
1269 g[j] = g[j].strip()
1270 if (j == 0):
1271 if (len(configuredGroups) > 0):
1272 configuredGroups=configuredGroups+","
1273 configuredGroups=configuredGroups+g[0]
1274 groupNames.append(g[0])
1275 groupNameIndexes[g[0]] = i
1276 changeIds.append({})
1277 ctr_responses.append(0)
1278 ctr_requests.append(0)
1279 ctr_files.append(0)
1280 ctr_events.append(0)
1281 firstPollTime.append(0)
1282 pnfMap.append(set())
1283 fileMap.append({})
1284 if (len(configuredChangeIds) > 0):
1285 configuredChangeIds=configuredChangeIds+","
1286 else:
1287 changeIds[i][j-1]=g[j]
1288 if (j > 1):
1289 configuredChangeIds=configuredChangeIds+":"
1290 configuredChangeIds=configuredChangeIds+g[j]
1291
1292 # Create a map between changeid and file name prefix
1293 tmp=configuredPrefixes.split(',')
1294 for i in range(len(tmp)):
1295 p=tmp[i].split(':')
1296 filePrefixes[p[0]] = p[1]
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001297
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001298 tc_num = "Not set"
1299 tc_help = "Not set"
TamasBakai9b780332019-02-15 08:38:16 +00001300
1301 parser = argparse.ArgumentParser()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001302
1303#SFTP TCs with single ME
TamasBakai9b780332019-02-15 08:38:16 +00001304 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001305 '--tc100',
TamasBakai9b780332019-02-15 08:38:16 +00001306 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001307 help='TC100 - One ME, SFTP, 1 1MB file, 1 event')
TamasBakai9b780332019-02-15 08:38:16 +00001308 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001309 '--tc101',
TamasBakai9b780332019-02-15 08:38:16 +00001310 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001311 help='TC101 - One ME, SFTP, 1 5MB file, 1 event')
TamasBakai9b780332019-02-15 08:38:16 +00001312 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001313 '--tc102',
TamasBakai9b780332019-02-15 08:38:16 +00001314 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001315 help='TC102 - One ME, SFTP, 1 50MB file, 1 event')
1316
TamasBakai9b780332019-02-15 08:38:16 +00001317 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001318 '--tc110',
TamasBakai9b780332019-02-15 08:38:16 +00001319 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001320 help='TC110 - One ME, SFTP, 1MB files, 1 file per event, 100 events, 1 event per poll.')
1321 parser.add_argument(
1322 '--tc111',
1323 action='store_true',
1324 help='TC111 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll.')
1325 parser.add_argument(
1326 '--tc112',
1327 action='store_true',
1328 help='TC112 - One ME, SFTP, 5MB files, 100 files per event, 100 events, 1 event per poll.')
1329 parser.add_argument(
1330 '--tc113',
1331 action='store_true',
1332 help='TC113 - One ME, SFTP, 1MB files, 100 files per event, 100 events. All events in one poll.')
1333
1334 parser.add_argument(
1335 '--tc120',
1336 action='store_true',
1337 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')
1338 parser.add_argument(
1339 '--tc121',
1340 action='store_true',
1341 help='TC121 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files')
1342 parser.add_argument(
1343 '--tc122',
1344 action='store_true',
1345 help='TC122 - One ME, SFTP, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ')
1346
1347 parser.add_argument(
1348 '--tc1000',
1349 action='store_true',
1350 help='TC1000 - One ME, SFTP, 1MB files, 100 files per event, endless number of events, 1 event per poll')
1351 parser.add_argument(
1352 '--tc1001',
1353 action='store_true',
1354 help='TC1001 - One ME, SFTP, 5MB files, 100 files per event, endless number of events, 1 event per poll')
1355
1356# SFTP TCs with multiple MEs
1357 parser.add_argument(
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001358 '--tc500',
1359 action='store_true',
1360 help='TC500 - 700 MEs, SFTP, 1MB files, 2 new files per event, 700 events, all event in one poll.')
1361
1362 parser.add_argument(
1363 '--tc501',
1364 action='store_true',
1365 help='TC501 - 700 MEs, SFTP, 5MB files, 2 new files per event, 700 events, all event in one poll.')
1366
1367 parser.add_argument(
1368 '--tc502',
1369 action='store_true',
1370 help='TC502 - 700 MEs, SFTP, 50MB files, 2 new files per event, 700 events, all event in one poll.')
1371
1372 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001373 '--tc510',
1374 action='store_true',
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001375 help='TC510 - 700 MEs, SFTP, 1MB files, 1 file per event, 3500 events, 700 event per poll.')
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001376
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001377 parser.add_argument(
1378 '--tc511',
1379 action='store_true',
1380 help='TC511 - 700 MEs, SFTP, 1KB files, 1 file per event, 3500 events, 700 event per poll.')
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001381
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001382 parser.add_argument(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001383 '--tc550',
1384 action='store_true',
1385 help='TC550 - 700 MEs, SFTP, 50MB files, 1 file per event, 3500 events, 700 event per poll.')
1386
1387 parser.add_argument(
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001388 '--tc710',
1389 action='store_true',
1390 help='TC710 - 700 MEs, SFTP, 1MB files, 100 files per event, 3500 events, 35 event per poll.')
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001391
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001392 parser.add_argument(
1393 '--tc1100',
1394 action='store_true',
1395 help='TC1100 - 700 ME, SFTP, 1MB files, 100 files per event, endless number of events, 35 event per poll')
1396 parser.add_argument(
1397 '--tc1101',
1398 action='store_true',
1399 help='TC1101 - 700 ME, SFTP, 5MB files, 100 files per event, endless number of events, 35 event per poll')
1400 parser.add_argument(
1401 '--tc1102',
1402 action='store_true',
1403 help='TC1102 - 700 ME, SFTP, 50MB files, 100 files per event, endless number of events, 35 event per poll')
1404
1405 parser.add_argument(
1406 '--tc1200',
1407 action='store_true',
1408 help='TC1200 - 700 ME, SFTP, 1MB files, 100 new files per event, endless number of events, 35 event per poll')
1409 parser.add_argument(
1410 '--tc1201',
1411 action='store_true',
1412 help='TC1201 - 700 ME, SFTP, 5MB files, 100 new files per event, endless number of events, 35 event per poll')
1413 parser.add_argument(
1414 '--tc1202',
1415 action='store_true',
1416 help='TC1202 - 700 ME, SFTP, 50MB files, 100 new files per event, endless number of events, 35 event per poll')
1417
1418 parser.add_argument(
1419 '--tc1300',
1420 action='store_true',
1421 help='TC1300 - 700 ME, SFTP, 1MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1422 parser.add_argument(
1423 '--tc1301',
1424 action='store_true',
1425 help='TC1301 - 700 ME, SFTP, 5MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1426 parser.add_argument(
1427 '--tc1302',
1428 action='store_true',
1429 help='TC1302 - 700 ME, SFTP, 50MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1430
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001431 parser.add_argument(
1432 '--tc1500',
1433 action='store_true',
1434 help='TC1500 - 700 ME, SFTP, 1MB files, 100 files per event, 35 events per poll, simulating 25h backlog of decreasing number of outdated files and then 20 event polls every 15min for 1h')
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001435
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001436# FTPS TCs with single ME
1437 parser.add_argument(
1438 '--tc200',
1439 action='store_true',
1440 help='TC200 - One ME, FTPS, 1 1MB file, 1 event')
1441 parser.add_argument(
1442 '--tc201',
1443 action='store_true',
1444 help='TC201 - One ME, FTPS, 1 5MB file, 1 event')
1445 parser.add_argument(
1446 '--tc202',
1447 action='store_true',
1448 help='TC202 - One ME, FTPS, 1 50MB file, 1 event')
1449
1450 parser.add_argument(
1451 '--tc210',
1452 action='store_true',
1453 help='TC210 - One ME, FTPS, 1MB files, 1 file per event, 100 events, 1 event per poll.')
1454 parser.add_argument(
1455 '--tc211',
1456 action='store_true',
1457 help='TC211 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll.')
1458 parser.add_argument(
1459 '--tc212',
1460 action='store_true',
1461 help='TC212 - One ME, FTPS, 5MB files, 100 files per event, 100 events, 1 event per poll.')
1462 parser.add_argument(
1463 '--tc213',
1464 action='store_true',
1465 help='TC213 - One ME, FTPS, 1MB files, 100 files per event, 100 events. All events in one poll.')
1466
1467 parser.add_argument(
1468 '--tc220',
1469 action='store_true',
1470 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')
1471 parser.add_argument(
1472 '--tc221',
1473 action='store_true',
1474 help='TC221 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files')
1475 parser.add_argument(
1476 '--tc222',
1477 action='store_true',
1478 help='TC222 - One ME, FTPS, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ')
1479
1480 parser.add_argument(
1481 '--tc2000',
1482 action='store_true',
1483 help='TC2000 - One ME, FTPS, 1MB files, 100 files per event, endless number of events, 1 event per poll')
1484 parser.add_argument(
1485 '--tc2001',
1486 action='store_true',
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001487 help='TC2001 - One ME, FTPS, 5MB files, 100 files per event, endless number of events, 1 event per poll')
1488
1489
1490 parser.add_argument(
1491 '--tc2100',
1492 action='store_true',
1493 help='TC2100 - 700 ME, FTPS, 1MB files, 100 files per event, endless number of events, 35 event per poll')
1494 parser.add_argument(
1495 '--tc2101',
1496 action='store_true',
1497 help='TC2101 - 700 ME, FTPS, 5MB files, 100 files per event, endless number of events, 35 event per poll')
1498 parser.add_argument(
1499 '--tc2102',
1500 action='store_true',
1501 help='TC2102 - 700 ME, FTPS, 50MB files, 100 files per event, endless number of events, 35 event per poll')
1502
1503 parser.add_argument(
1504 '--tc2200',
1505 action='store_true',
1506 help='TC2200 - 700 ME, FTPS, 1MB files, 100 new files per event, endless number of events, 35 event per poll')
1507 parser.add_argument(
1508 '--tc2201',
1509 action='store_true',
1510 help='TC2201 - 700 ME, FTPS, 5MB files, 100 new files per event, endless number of events, 35 event per poll')
1511 parser.add_argument(
1512 '--tc2202',
1513 action='store_true',
1514 help='TC2202 - 700 ME, FTPS, 50MB files, 100 new files per event, endless number of events, 35 event per poll')
1515
1516 parser.add_argument(
1517 '--tc2300',
1518 action='store_true',
1519 help='TC2300 - 700 ME, FTPS, 1MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1520 parser.add_argument(
1521 '--tc2301',
1522 action='store_true',
1523 help='TC2301 - 700 ME, FTPS, 5MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1524 parser.add_argument(
1525 '--tc2302',
1526 action='store_true',
1527 help='TC2302 - 700 ME, FTPS, 50MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1528
1529 parser.add_argument(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001530 '--tc2500',
1531 action='store_true',
1532 help='TC2500 - 700 ME, FTPS, 1MB files, 100 files per event, 35 events per poll, simulating 25h backlog of decreasing number of outdated files and then 20 event polls every 15min for 1h')
1533
1534 parser.add_argument(
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001535 '--tc600',
1536 action='store_true',
1537 help='TC600 - 700 MEs, FTPS, 1MB files, 2 new files per event, 700 events, all event in one poll.')
1538
1539 parser.add_argument(
1540 '--tc601',
1541 action='store_true',
1542 help='TC601 - 700 MEs, FTPS, 5MB files, 2 new files per event, 700 events, all event in one poll.')
1543
1544 parser.add_argument(
1545 '--tc602',
1546 action='store_true',
1547 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 +00001548
1549 parser.add_argument(
1550 '--tc610',
1551 action='store_true',
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001552 help='TC610 - 700 MEs, FTPS, 1MB files, 1 file per event, 3500 events, 700 event per poll.')
1553
1554 parser.add_argument(
1555 '--tc611',
1556 action='store_true',
1557 help='TC611 - 700 MEs, FTPS, 1KB files, 1 file per event, 3500 events, 700 event per poll.')
1558
1559 parser.add_argument(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001560 '--tc650',
1561 action='store_true',
1562 help='TC610 - 700 MEs, FTPS, 50MB files, 1 file per event, 3500 events, 700 event per poll.')
1563
1564 parser.add_argument(
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001565 '--tc810',
1566 action='store_true',
1567 help='TC810 - 700 MEs, FTPS, 1MB files, 100 files per event, 3500 events, 35 event per poll.')
TamasBakai9b780332019-02-15 08:38:16 +00001568
1569 args = parser.parse_args()
1570
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001571
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001572
1573 if args.tc100:
1574 tc_num = "TC# 100"
1575 elif args.tc101:
1576 tc_num = "TC# 101"
1577 elif args.tc102:
1578 tc_num = "TC# 102"
1579
1580 elif args.tc110:
1581 tc_num = "TC# 110"
1582 elif args.tc111:
1583 tc_num = "TC# 111"
1584 elif args.tc112:
1585 tc_num = "TC# 112"
1586 elif args.tc113:
1587 tc_num = "TC# 113"
1588
1589 elif args.tc120:
1590 tc_num = "TC# 120"
1591 elif args.tc121:
1592 tc_num = "TC# 121"
1593 elif args.tc122:
1594 tc_num = "TC# 122"
1595
1596 elif args.tc1000:
1597 tc_num = "TC# 1000"
1598 elif args.tc1001:
1599 tc_num = "TC# 1001"
1600
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001601 elif args.tc1100:
1602 tc_num = "TC# 1100"
1603 elif args.tc1101:
1604 tc_num = "TC# 1101"
1605 elif args.tc1102:
1606 tc_num = "TC# 1102"
1607 elif args.tc1200:
1608 tc_num = "TC# 1200"
1609 elif args.tc1201:
1610 tc_num = "TC# 1201"
1611 elif args.tc1202:
1612 tc_num = "TC# 1202"
1613 elif args.tc1300:
1614 tc_num = "TC# 1300"
1615 elif args.tc1301:
1616 tc_num = "TC# 1301"
1617 elif args.tc1302:
1618 tc_num = "TC# 1302"
1619
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001620 elif args.tc1500:
1621 tc_num = "TC# 1500"
1622
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001623 elif args.tc500:
1624 tc_num = "TC# 500"
1625 elif args.tc501:
1626 tc_num = "TC# 501"
1627 elif args.tc502:
1628 tc_num = "TC# 502"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001629 elif args.tc510:
1630 tc_num = "TC# 510"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001631 elif args.tc511:
1632 tc_num = "TC# 511"
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001633
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001634 elif args.tc550:
1635 tc_num = "TC# 550"
1636
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001637 elif args.tc710:
1638 tc_num = "TC# 710"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001639
1640 elif args.tc200:
1641 tc_num = "TC# 200"
1642 elif args.tc201:
1643 tc_num = "TC# 201"
1644 elif args.tc202:
1645 tc_num = "TC# 202"
1646
1647 elif args.tc210:
1648 tc_num = "TC# 210"
1649 elif args.tc211:
1650 tc_num = "TC# 211"
1651 elif args.tc212:
1652 tc_num = "TC# 212"
1653 elif args.tc213:
1654 tc_num = "TC# 213"
1655
1656 elif args.tc220:
1657 tc_num = "TC# 220"
1658 elif args.tc221:
1659 tc_num = "TC# 221"
1660 elif args.tc222:
1661 tc_num = "TC# 222"
1662
1663 elif args.tc2000:
1664 tc_num = "TC# 2000"
1665 elif args.tc2001:
1666 tc_num = "TC# 2001"
1667
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001668 elif args.tc2100:
1669 tc_num = "TC# 2100"
1670 elif args.tc2101:
1671 tc_num = "TC# 2101"
1672 elif args.tc2102:
1673 tc_num = "TC# 2102"
1674 elif args.tc2200:
1675 tc_num = "TC# 2200"
1676 elif args.tc2201:
1677 tc_num = "TC# 2201"
1678 elif args.tc2202:
1679 tc_num = "TC# 2202"
1680 elif args.tc2300:
1681 tc_num = "TC# 2300"
1682 elif args.tc2301:
1683 tc_num = "TC# 2301"
1684 elif args.tc2302:
1685 tc_num = "TC# 2302"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001686
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001687 elif args.tc2500:
1688 tc_num = "TC# 2500"
1689
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001690 elif args.tc600:
1691 tc_num = "TC# 600"
1692 elif args.tc601:
1693 tc_num = "TC# 601"
1694 elif args.tc602:
1695 tc_num = "TC# 602"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001696 elif args.tc610:
1697 tc_num = "TC# 610"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001698 elif args.tc611:
1699 tc_num = "TC# 611"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001700 elif args.tc650:
1701 tc_num = "TC# 650"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001702 elif args.tc810:
1703 tc_num = "TC# 810"
TamasBakai9b780332019-02-15 08:38:16 +00001704
1705 else:
1706 print("No TC was defined")
1707 print("use --help for usage info")
1708 sys.exit()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001709
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001710 print("TC num: " + tc_num)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001711
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001712 for i in range(len(sftp_hosts)):
1713 print("Using " + str(sftp_hosts[i]) + ":" + str(sftp_ports[i]) + " for sftp server with index " + str(i) + " for sftp server address and port in file urls.")
1714
1715 for i in range(len(ftps_hosts)):
1716 print("Using " + str(ftps_hosts[i]) + ":" + str(ftps_ports[i]) + " for ftps server with index " + str(i) + " for ftps server address and port in file urls.")
1717
1718 print("Using up to " + str(num_ftp_servers) + " ftp servers, for each protocol for PNFs.")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001719
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001720 app.run(port=HOST_PORT, host=HOST_IP)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001721