blob: 6345ab69fa954addf19f4ae9cba50272799d765e [file] [log] [blame]
TamasBakai9b780332019-02-15 08:38:16 +00001import argparse
TamasBakai9b780332019-02-15 08:38:16 +00002import json
ecaiyanlinux796e8fe2019-08-21 12:10:33 +00003import os
4import sys
5import time
6from time import sleep
7
8from flask import Flask, render_template, request
9from werkzeug import secure_filename
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
ecaiyanlinux796e8fe2019-08-21 12:10:33 +000016HOST_PORT_TLS = 2223
TamasBakai9b780332019-02-15 08:38:16 +000017
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000018sftp_hosts=[]
19sftp_ports=[]
20ftps_hosts=[]
21ftps_ports=[]
TamasBakaifa357df2019-08-15 08:25:27 +000022num_ftp_servers=1
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000023
24def sumList(ctrArray):
25 tmp=0
26 for i in range(len(ctrArray)):
27 tmp=tmp+ctrArray[i];
28
29 return str(tmp);
30
31def sumListLength(ctrArray):
32 tmp=0
33 for i in range(len(ctrArray)):
34 tmp=tmp+len(ctrArray[i]);
35
36 return str(tmp);
BjornMagnussonXAf4e18362019-04-10 13:04:08 +000037
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000038#Test function to check server running
39@app.route('/',
40 methods=['GET'])
41def index():
42 return 'Hello world'
TamasBakai9b780332019-02-15 08:38:16 +000043
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000044#Returns the list of configured groups
45@app.route('/groups',
46 methods=['GET'])
47def group_ids():
48 global configuredGroups
49 return configuredGroups
50
51#Returns the list of configured changeids
52@app.route('/changeids',
53 methods=['GET'])
54def change_ids():
55 global configuredChangeIds
56 return configuredChangeIds
57
58#Returns the list of configured fileprefixes
59@app.route('/fileprefixes',
60 methods=['GET'])
61def fileprefixes():
62 global configuredPrefixes
63 return configuredPrefixes
64
65
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000066#Returns number of polls
67@app.route('/ctr_requests',
68 methods=['GET'])
69def counter_requests():
70 global ctr_requests
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000071 return sumList(ctr_requests)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000072
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000073#Returns number of polls for all groups
74@app.route('/groups/ctr_requests',
75 methods=['GET'])
76def group_counter_requests():
77 global ctr_requests
78 global groupNames
79 tmp=''
80 for i in range(len(groupNames)):
81 if (i > 0):
82 tmp=tmp+','
83 tmp=tmp+str(ctr_requests[i])
84 return tmp
85
86#Returns the total number of polls for a group
87@app.route('/ctr_requests/<groupId>',
88 methods=['GET'])
89def counter_requests_group(groupId):
90 global ctr_requests
91 global groupNameIndexes
92 return str(ctr_requests[groupNameIndexes[groupId]])
93
94#Returns number of poll replies
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +000095@app.route('/ctr_responses',
96 methods=['GET'])
97def counter_responses():
98 global ctr_responses
BjornMagnussonXAa79a0432019-07-17 08:26:50 +000099 return sumList(ctr_responses)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000100
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000101#Returns number of poll replies for all groups
102@app.route('/groups/ctr_responses',
103 methods=['GET'])
104def group_counter_responses():
105 global ctr_responses
106 global groupNames
107 tmp=''
108 for i in range(len(groupNames)):
109 if (i > 0):
110 tmp=tmp+','
111 tmp=tmp+str(ctr_responses[i])
112 return tmp
113
114#Returns the total number of poll replies for a group
115@app.route('/ctr_responses/<groupId>',
116 methods=['GET'])
117def counter_responses_group(groupId):
118 global ctr_responses
119 global groupNameIndexes
120 return str(ctr_responses[groupNameIndexes[groupId]])
121
122#Returns the total number of files
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000123@app.route('/ctr_files',
124 methods=['GET'])
125def counter_files():
126 global ctr_files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000127 return sumList(ctr_files)
128
129#Returns the total number of file for all groups
130@app.route('/groups/ctr_files',
131 methods=['GET'])
132def group_counter_files():
133 global ctr_files
134 global groupNames
135 tmp=''
136 for i in range(len(groupNames)):
137 if (i > 0):
138 tmp=tmp+','
139 tmp=tmp+str(ctr_files[i])
140 return tmp
141
142#Returns the total number of files for a group
143@app.route('/ctr_files/<groupId>',
144 methods=['GET'])
145def counter_files_group(groupId):
146 global ctr_files
147 global groupNameIndexes
148 return str(ctr_files[groupNameIndexes[groupId]])
149
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000150
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000151#Returns number of unique files
152@app.route('/ctr_unique_files',
153 methods=['GET'])
154def counter_uniquefiles():
155 global fileMap
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000156 return sumListLength(fileMap)
157
158#Returns number of unique files for all groups
159@app.route('/groups/ctr_unique_files',
160 methods=['GET'])
161def group_counter_uniquefiles():
162 global fileMap
163 global groupNames
164 tmp=''
165 for i in range(len(groupNames)):
166 if (i > 0):
167 tmp=tmp+','
168 tmp=tmp+str(len(fileMap[i]))
169 return tmp
170
171#Returns the total number of unique files for a group
172@app.route('/ctr_unique_files/<groupId>',
173 methods=['GET'])
174def counter_uniquefiles_group(groupId):
175 global fileMap
176 global groupNameIndexes
177 return str(len(fileMap[groupNameIndexes[groupId]]))
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000178
179#Returns tc info
180@app.route('/tc_info',
181 methods=['GET'])
182def testcase_info():
183 global tc_num
184 return tc_num
185
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000186#Returns number of events
187@app.route('/ctr_events',
188 methods=['GET'])
189def counter_events():
190 global ctr_events
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000191 return sumList(ctr_events)
192
193#Returns number of events for all groups
194@app.route('/groups/ctr_events',
195 methods=['GET'])
196def group_counter_events():
197 global ctr_events
198 global groupNames
199 tmp=''
200 for i in range(len(groupNames)):
201 if (i > 0):
202 tmp=tmp+','
203 tmp=tmp+str(ctr_events[i])
204 return tmp
205
206#Returns the total number of events for a group
207@app.route('/ctr_events/<groupId>',
208 methods=['GET'])
209def counter_events_group(groupId):
210 global ctr_events
211 global groupNameIndexes
212 return str(ctr_events[groupNameIndexes[groupId]])
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000213
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000214#Returns execution time in mm:ss
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000215@app.route('/execution_time',
216 methods=['GET'])
217def exe_time():
218 global startTime
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000219
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000220 stopTime = time.time()
221 minutes, seconds = divmod(stopTime-startTime, 60)
222 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
223
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000224#Returns the timestamp for first poll
225@app.route('/exe_time_first_poll',
226 methods=['GET'])
227def exe_time_first_poll():
228 global firstPollTime
229
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000230 tmp = 0
231 for i in range(len(groupNames)):
232 if (firstPollTime[i] > tmp):
233 tmp = firstPollTime[i]
234
235 if (tmp == 0):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000236 return "--:--"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000237 minutes, seconds = divmod(time.time()-tmp, 60)
238 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
239
240#Returns the timestamp for first poll for all groups
241@app.route('/groups/exe_time_first_poll',
242 methods=['GET'])
243def group_exe_time_first_poll():
244 global firstPollTime
245 global groupNames
246
247 tmp=''
248 for i in range(len(groupNames)):
249 if (i > 0):
250 tmp=tmp+','
251 if (firstPollTime[i] == 0):
252 tmp=tmp+ "--:--"
253 else:
254 minutes, seconds = divmod(time.time()-firstPollTime[i], 60)
255 tmp=tmp+"{:0>2}:{:0>2}".format(int(minutes),int(seconds))
256 return tmp
257
258#Returns the timestamp for first poll for a group
259@app.route('/exe_time_first_poll/<groupId>',
260 methods=['GET'])
261def exe_time_first_poll_group(groupId):
262 global ctr_requests
263 global groupNameIndexes
264
265 if (firstPollTime[groupNameIndexes[groupId]] == 0):
266 return "--:--"
267 minutes, seconds = divmod(time.time()-firstPollTime[groupNameIndexes[groupId]], 60)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000268 return "{:0>2}:{:0>2}".format(int(minutes),int(seconds))
269
270#Starts event delivery
271@app.route('/start',
272 methods=['GET'])
273def start():
274 global runningState
275 runningState="Started"
276 return runningState
277
278#Stops event delivery
279@app.route('/stop',
280 methods=['GET'])
281def stop():
282 global runningState
283 runningState="Stopped"
284 return runningState
285
286#Returns the running state
287@app.route('/status',
288 methods=['GET'])
289def status():
290 global runningState
291 return runningState
292
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000293#Returns number of unique PNFs
294@app.route('/ctr_unique_PNFs',
295 methods=['GET'])
296def counter_uniquePNFs():
297 global pnfMap
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000298 return sumListLength(pnfMap)
299
300#Returns number of unique PNFs for all groups
301@app.route('/groups/ctr_unique_PNFs',
302 methods=['GET'])
303def group_counter_uniquePNFs():
304 global pnfMap
305 global groupNames
306 tmp=''
307 for i in range(len(groupNames)):
308 if (i > 0):
309 tmp=tmp+','
310 tmp=tmp+str(len(pnfMap[i]))
311 return tmp
312
313#Returns the unique PNFs for a group
314@app.route('/ctr_unique_PNFs/<groupId>',
315 methods=['GET'])
316def counter_uniquePNFs_group(groupId):
317 global pnfMap
318 global groupNameIndexes
319 return str(len(pnfMap[groupNameIndexes[groupId]]))
320
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000321
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000322#Messages polling function
TamasBakai9b780332019-02-15 08:38:16 +0000323@app.route(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000324 "/events/unauthenticated.VES_NOTIFICATION_OUTPUT/<consumerGroup>/<consumerId>",
TamasBakai9b780332019-02-15 08:38:16 +0000325 methods=['GET'])
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000326def MR_reply(consumerGroup, consumerId):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000327 global ctr_requests
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000328 global ctr_responses
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000329 global args
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000330 global runningState
331 global firstPollTime
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000332 global groupNameIndexes
333 global changeIds
334 global filePrefixes
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000335
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000336 groupIndex = groupNameIndexes[consumerGroup]
337 print("Setting groupIndex: " + str(groupIndex))
TamasBakai9b780332019-02-15 08:38:16 +0000338
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000339 reqCtr = ctr_requests[groupIndex]
340 changeId = changeIds[groupIndex][reqCtr%len(changeIds[groupIndex])]
341 print("Setting changeid: " + changeId)
342 filePrefix = filePrefixes[changeId]
343 print("Setting file name prefix: " + filePrefix)
344
345 if (firstPollTime[groupIndex] == 0):
346 firstPollTime[groupIndex] = time.time()
347
348 ctr_requests[groupIndex] = ctr_requests[groupIndex] + 1
349 print("MR: poll request#: " + str(ctr_requests[groupIndex]))
TamasBakai9b780332019-02-15 08:38:16 +0000350
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000351 if (runningState == "Stopped"):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000352 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000353 return buildOkResponse("[]")
354
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000355
356
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000357 if args.tc100:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000358 return tc100(groupIndex, changeId, filePrefix, "sftp", "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000359 elif args.tc101:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000360 return tc100(groupIndex, changeId, filePrefix, "sftp", "5MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000361 elif args.tc102:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000362 return tc100(groupIndex, changeId, filePrefix, "sftp", "50MB")
TamasBakai9b780332019-02-15 08:38:16 +0000363
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000364 elif args.tc110:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000365 return tc110(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000366 elif args.tc111:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000367 return tc111(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000368 elif args.tc112:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000369 return tc112(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000370 elif args.tc113:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000371 return tc113(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000372
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000373 elif args.tc120:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000374 return tc120(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000375 elif args.tc121:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000376 return tc121(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000377 elif args.tc122:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000378 return tc122(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000379
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000380 elif args.tc1000:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000381 return tc1000(groupIndex, changeId, filePrefix, "sftp")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000382 elif args.tc1001:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000383 return tc1001(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000384
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000385 elif args.tc1100:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000386 return tc1100(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000387 elif args.tc1101:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000388 return tc1100(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000389 elif args.tc1102:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000390 return tc1100(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000391 elif args.tc1200:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000392 return tc1200(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000393 elif args.tc1201:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000394 return tc1200(groupIndex, changeId, filePrefix, "sftp","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000395 elif args.tc1202:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000396 return tc1200(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000397 elif args.tc1300:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000398 return tc1300(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000399 elif args.tc1301:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000400 return tc1300(groupIndex, changeId, filePrefix, "sftp","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000401 elif args.tc1302:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000402 return tc1300(groupIndex, changeId, filePrefix, "sftp","50MB")
403
404 elif args.tc1500:
405 return tc1500(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000406
407 elif args.tc500:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000408 return tc500(groupIndex, changeId, filePrefix, "sftp","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000409 elif args.tc501:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000410 return tc500(groupIndex, changeId, filePrefix, "sftp","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000411 elif args.tc502:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000412 return tc500(groupIndex, changeId, filePrefix, "sftp","50MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000413 elif args.tc510:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000414 return tc510(groupIndex, changeId, filePrefix, "sftp", "1MB")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000415 elif args.tc511:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000416 return tc511(groupIndex, changeId, filePrefix, "sftp", "1KB")
417
418 elif args.tc550:
419 return tc510(groupIndex, changeId, filePrefix, "sftp", "50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000420
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000421 elif args.tc710:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000422 return tc710(groupIndex, changeId, filePrefix, "sftp")
TamasBakai9b780332019-02-15 08:38:16 +0000423
424
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000425 elif args.tc200:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000426 return tc100(groupIndex, changeId, filePrefix, "ftps", "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000427 elif args.tc201:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000428 return tc100(groupIndex, changeId, filePrefix, "ftps", "5MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000429 elif args.tc202:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000430 return tc100(groupIndex, changeId, filePrefix, "ftps", "50MB")
TamasBakai9b780332019-02-15 08:38:16 +0000431
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000432 elif args.tc210:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000433 return tc110(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000434 elif args.tc211:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000435 return tc111(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000436 elif args.tc212:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000437 return tc112(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000438 elif args.tc213:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000439 return tc113(groupIndex, changeId, filePrefix, "ftps")
TamasBakai9b780332019-02-15 08:38:16 +0000440
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000441 elif args.tc220:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000442 return tc120(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000443 elif args.tc221:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000444 return tc121(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000445 elif args.tc222:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000446 return tc122(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000447
448 elif args.tc2000:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000449 return tc1000(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000450 elif args.tc2001:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000451 return tc1001(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000452
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000453 elif args.tc2100:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000454 return tc1100(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000455 elif args.tc2101:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000456 return tc1100(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000457 elif args.tc2102:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000458 return tc1100(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000459 elif args.tc2200:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000460 return tc1200(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000461 elif args.tc2201:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000462 return tc1200(groupIndex, changeId, filePrefix, "ftps","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000463 elif args.tc2202:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000464 return tc1200(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000465 elif args.tc2300:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000466 return tc1300(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000467 elif args.tc2301:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000468 return tc1300(groupIndex, changeId, filePrefix, "ftps","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000469 elif args.tc2302:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000470 return tc1300(groupIndex, changeId, filePrefix, "ftps","50MB")
471
472 elif args.tc2500:
473 return tc1500(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000474
475 elif args.tc600:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000476 return tc500(groupIndex, changeId, filePrefix, "ftps","1MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000477 elif args.tc601:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000478 return tc500(groupIndex, changeId, filePrefix, "ftps","5MB")
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000479 elif args.tc602:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000480 return tc500(groupIndex, changeId, filePrefix, "ftps","50MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000481 elif args.tc610:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000482 return tc510(groupIndex, changeId, filePrefix, "ftps", "1MB")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000483 elif args.tc611:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000484 return tc511(groupIndex, changeId, filePrefix, "ftps", "1KB")
485 elif args.tc650:
486 return tc510(groupIndex, changeId, filePrefix, "ftps", "50MB")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000487 elif args.tc810:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000488 return tc710(groupIndex, changeId, filePrefix, "ftps")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000489
490
491#### Test case functions
492
493
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000494def tc100(groupIndex, changeId, filePrefix, ftpType, fileSize):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000495 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000496 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000497
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000498
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000499 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
500
501 if (ctr_responses[groupIndex] > 1):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000502 return buildOkResponse("[]")
503
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000504 seqNr = (ctr_responses[groupIndex]-1)
505 nodeIndex=0
506 nodeName = createNodeName(nodeIndex)
507 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, fileSize)
508 msg = getEventHead(groupIndex, changeId, nodeName) + getEventName(fileName,ftpType,"onap","pano",nodeIndex) + getEventEnd()
509 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
510 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000511 return buildOkResponse("["+msg+"]")
512
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000513#def tc101(groupIndex, ftpType):
514# global ctr_responses
515# global ctr_events
516#
517# ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
518#
519# if (ctr_responses[groupIndex] > 1):
520# return buildOkResponse("[]")
521#
522# seqNr = (ctr_responses[groupIndex]-1)
523# nodeName = createNodeName(0)
524# fileName = createFileName(groupIndex, nodeName, seqNr, "5MB")
525# msg = getEventHead(groupIndex, nodeName) + getEventName(fileName,ftpType,"onap","pano") + getEventEnd()
526# fileMap[groupIndex][seqNr] = seqNr
527# ctr_events[groupIndex] = ctr_events[groupIndex]+1
528# return buildOkResponse("["+msg+"]")
529#
530#def tc102(groupIndex, ftpType):
531# global ctr_responses
532# global ctr_events
533#
534# ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
535#
536# if (ctr_responses[groupIndex] > 1):
537# return buildOkResponse("[]")
538#
539# seqNr = (ctr_responses[groupIndex]-1)
540# nodeName = createNodeName(0)
541# fileName = createFileName(groupIndex, nodeName, seqNr, "50MB")
542# msg = getEventHead(groupIndex, nodeName) + getEventName(fileName,ftpType,"onap","pano") + getEventEnd()
543# fileMap[groupIndex][seqNr] = seqNr
544# ctr_events[groupIndex] = ctr_events[groupIndex]+1
545# return buildOkResponse("["+msg+"]")
546
547def tc110(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000548 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000549 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000550
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000551
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000552 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
553
554 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000555 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000556
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000557 seqNr = (ctr_responses[groupIndex]-1)
558 nodeIndex=0
559 nodeName = createNodeName(nodeIndex)
560 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
561 msg = getEventHead(groupIndex, changeId, nodeName) + getEventName(fileName,ftpType,"onap","pano",nodeIndex) + getEventEnd()
562 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
563 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000564 return buildOkResponse("["+msg+"]")
565
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000566def tc111(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000567 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000568 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000569
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000570
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000571 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
572
573 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000574 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000575
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000576 nodeIndex=0
577 nodeName = createNodeName(nodeIndex)
578 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000579
580 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000581 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000582 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000583 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
584 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
585 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000586
587 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000588 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000589
590 return buildOkResponse("["+msg+"]")
591
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000592def tc112(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000593 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000594 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000595
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000596
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000597 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
598
599 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000600 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000601
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000602 nodeIndex=0
603 nodeName = createNodeName(nodeIndex)
604 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000605
606 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000607 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000608 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000609 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "5MB")
610 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
611 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000612
613 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000614 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000615
616 return buildOkResponse("["+msg+"]")
617
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000618def tc113(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000619 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000620 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000621
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000622
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000623 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
624
625 if (ctr_responses[groupIndex] > 1):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000626 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000627
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000628 nodeIndex=0
629 nodeName = createNodeName(nodeIndex)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000630 msg = ""
631
632 for evts in range(100): # build 100 evts
633 if (evts > 0):
634 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000635 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000636 for i in range(100): # build 100 files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000637 seqNr = i+evts+100*(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000638 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000639 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
640 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
641 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000642
643 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000644 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000645
646 return buildOkResponse("["+msg+"]")
647
648
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000649def tc120(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000650 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000651 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000652
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000653
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000654 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000655
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000656 nodeIndex=0
657 nodeName = createNodeName(nodeIndex)
658
659 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000660 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000661
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000662 if (ctr_responses[groupIndex] % 10 == 2):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000663 return # Return nothing
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000664
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000665 if (ctr_responses[groupIndex] % 10 == 3):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000666 return buildOkResponse("") # Return empty message
667
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000668 if (ctr_responses[groupIndex] % 10 == 4):
669 return buildOkResponse(getEventHead(groupIndex, changeId, nodeName)) # Return part of a json event
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000670
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000671 if (ctr_responses[groupIndex] % 10 == 5):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000672 return buildEmptyResponse(404) # Return empty message with status code
673
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000674 if (ctr_responses[groupIndex] % 10 == 6):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000675 sleep(60)
676
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000677
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000678 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000679
680 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000681 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000682 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000683 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
684 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
685 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000686
687 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000688 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000689
690 return buildOkResponse("["+msg+"]")
691
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000692def tc121(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000693 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000694 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000695
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000696
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000697 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
698
699 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000700 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000701
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000702 nodeIndex=0
703 nodeName = createNodeName(nodeIndex)
704 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000705
706 fileName = ""
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000707 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000708 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000709 if (seqNr%10 == 0): # Every 10th file is "missing"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000710 fileName = createMissingFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000711 else:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000712 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
713 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000714
715 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000716 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000717
718 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000719 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000720
721 return buildOkResponse("["+msg+"]")
722
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000723def tc122(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000724 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000725 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000726
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000727
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000728 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
729
730 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000731 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000732
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000733 nodeIndex=0
734 nodeName = createNodeName(nodeIndex)
735 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000736
737 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000738 fileName = createFileName(groupIndex, filePrefix, nodeName, 0, "1MB") # All files identical names
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000739 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000740 msg = msg + getEventName(fileName,ftpType,"onap","pano", nodeIndex)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000741
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000742 fileMap[groupIndex][0] = 0
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000743 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000744 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000745
746 return buildOkResponse("["+msg+"]")
747
748
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000749def tc1000(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000750 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000751 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000752
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000753
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000754 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
755
756 nodeIndex=0
757 nodeName = createNodeName(nodeIndex)
758 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000759
760 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000761 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000762 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000763 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
764 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
765 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000766
767 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000768 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000769
770 return buildOkResponse("["+msg+"]")
771
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000772def tc1001(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000773 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +0000774 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000775
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000776
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000777 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
778
779 nodeIndex=0
780 nodeName = createNodeName(nodeIndex)
781 msg = getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000782
783 for i in range(100):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000784 seqNr = i+(ctr_responses[groupIndex]-1)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000785 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000786 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "5MB")
787 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
788 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000789
790 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000791 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +0000792
793 return buildOkResponse("["+msg+"]")
794
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000795
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000796def tc1100(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000797 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000798 global ctr_events
799
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000800
801 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000802
803 msg = ""
804
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000805 batch = (ctr_responses[groupIndex]-1)%20;
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000806
807 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
808 if (pnfs > 0):
809 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000810 nodeIndex=pnfs + batch*35
811 nodeName = createNodeName(nodeIndex)
812 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000813
814 for i in range(100): # 100 files per event
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000815 seqNr = i + int((ctr_responses[groupIndex]-1)/20);
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000816 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000817 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
818 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000819 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000820 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000821
822 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000823 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000824
825 return buildOkResponse("["+msg+"]")
826
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000827def tc1200(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000828 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000829 global ctr_events
830
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000831
832 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000833
834 msg = ""
835
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000836 batch = (ctr_responses[groupIndex]-1)%20;
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000837
838 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
839 if (pnfs > 0):
840 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000841 nodeIndex=pnfs + batch*35
842 nodeName = createNodeName(nodeIndex)
843 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000844
845 for i in range(100): # 100 files per event, all new files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000846 seqNr = i+100 * int((ctr_responses[groupIndex]-1)/20);
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000847 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000848 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
849 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000850 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000851 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000852
853 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000854 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000855
856 return buildOkResponse("["+msg+"]")
857
858
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000859def tc1300(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000860 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000861 global ctr_events
862 global rop_counter
863 global rop_timestamp
864
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000865 if (rop_counter == 0):
866 rop_timestamp = time.time()
867
868 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000869
870 #Start a event deliver for all 700 nodes every 15min
871 rop = time.time()-rop_timestamp
872 if ((rop < 900) & (rop_counter%20 == 0) & (rop_counter != 0)):
873 return buildOkResponse("[]")
874 else:
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000875 if (rop_counter%20 == 0) & (rop_counter > 0):
876 rop_timestamp = rop_timestamp+900
877
878 rop_counter = rop_counter+1
879
880 msg = ""
881
882 batch = (rop_counter-1)%20;
883
884 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
885 if (pnfs > 0):
886 msg = msg + ","
887 nodeIndex=pnfs + batch*35
888 nodeName = createNodeName(nodeIndex)
889 msg = msg + getEventHead(groupIndex, changeId, nodeName)
890
891 for i in range(100): # 100 files per event
892 seqNr = i + int((rop_counter-1)/20);
893 if i != 0: msg = msg + ","
894 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
895 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
896 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
897 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
898
899 msg = msg + getEventEnd()
900 ctr_events[groupIndex] = ctr_events[groupIndex]+1
901
902 return buildOkResponse("["+msg+"]")
903
904def tc1500(groupIndex, changeId, filePrefix, ftpType, filesize):
905 global ctr_responses
906 global ctr_events
907 global rop_counter
908 global rop_timestamp
909
910 if (rop_counter == 0):
911 rop_timestamp = time.time()
912
913 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
914
915 if (ctr_responses[groupIndex] <= 2000 ): #first 25h of event doess not care of 15min rop timer
916
917 msg = ""
918
919 batch = (ctr_responses[groupIndex]-1)%20;
920
921 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
922 if (pnfs > 0):
923 msg = msg + ","
924
925 nodeIndex=pnfs + batch*35
926 nodeName = createNodeName(nodeIndex)
927 msg = msg + getEventHead(groupIndex, changeId, nodeName)
928
929 for i in range(100): # 100 files per event
930 seqNr = i + int((ctr_responses[groupIndex]-1)/20);
931 if i != 0: msg = msg + ","
932 if (seqNr < 100):
933 fileName = createMissingFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
934 else:
935 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
936 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
937 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
938 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
939
940
941 msg = msg + getEventEnd()
942 ctr_events[groupIndex] = ctr_events[groupIndex]+1
943
944 rop_counter = rop_counter+1
945 return buildOkResponse("["+msg+"]")
946
947 #Start an event delivery for all 700 nodes every 15min
948 rop = time.time()-rop_timestamp
949 if ((rop < 900) & (rop_counter%20 == 0) & (rop_counter != 0)):
950 return buildOkResponse("[]")
951 else:
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000952 if (rop_counter%20 == 0):
953 rop_timestamp = time.time()
954
955 rop_counter = rop_counter+1
956
957 msg = ""
958
959 batch = (rop_counter-1)%20;
960
961 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
962 if (pnfs > 0):
963 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000964 nodeIndex=pnfs + batch*35
965 nodeName = createNodeName(nodeIndex)
966 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000967
968 for i in range(100): # 100 files per event
969 seqNr = i + int((rop_counter-1)/20);
970 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000971 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
972 msg = msg + getEventName(fileName,ftpType,"onap","pano", nodeIndex)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000973 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000974 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000975
976 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000977 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000978
979 return buildOkResponse("["+msg+"]")
980
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000981def tc500(groupIndex, changeId, filePrefix, ftpType, filesize):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000982 global ctr_responses
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000983 global ctr_events
984
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000985
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000986 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
987
988 if (ctr_responses[groupIndex] > 1):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000989 return buildOkResponse("[]")
990
991 msg = ""
992
993
994 for pnfs in range(700):
995 if (pnfs > 0):
996 msg = msg + ","
997 nodeName = createNodeName(pnfs)
BjornMagnussonXAa79a0432019-07-17 08:26:50 +0000998 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +0000999
1000 for i in range(2):
1001 seqNr = i;
1002 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001003 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, filesize)
1004 msg = msg + getEventName(fileName,ftpType,"onap","pano",pnfs)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001005 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001006 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001007
1008 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001009 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001010
1011 return buildOkResponse("["+msg+"]")
1012
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001013def tc510(groupIndex, changeId, filePrefix, ftpType, fileSize):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001014 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001015 global ctr_events
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001016
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001017
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001018 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
1019
1020 if (ctr_responses[groupIndex] > 5):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001021 return buildOkResponse("[]")
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001022
1023 msg = ""
1024
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001025 for pnfs in range(700): # build events for 700 MEs
1026 if (pnfs > 0):
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001027 msg = msg + ","
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001028 nodeName = createNodeName(pnfs)
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001029 msg = msg + getEventHead(groupIndex, changeId, nodeName)
1030 seqNr = (ctr_responses[groupIndex]-1)
1031 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, fileSize)
1032 msg = msg + getEventName(fileName,ftpType,"onap","pano",pnfs)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001033 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001034 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001035 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001036 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001037
1038 return buildOkResponse("["+msg+"]")
1039
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001040def tc511(groupIndex, changeId, filePrefix, ftpType, fileSize):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001041 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001042 global ctr_events
1043
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001044
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001045 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
1046
1047 if (ctr_responses[groupIndex] > 5):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001048 return buildOkResponse("[]")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001049
1050 msg = ""
1051
1052 for pnfs in range(700): # build events for 700 MEs
1053 if (pnfs > 0):
1054 msg = msg + ","
1055 nodeName = createNodeName(pnfs)
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001056 msg = msg + getEventHead(groupIndex, changeId, nodeName)
1057 seqNr = (ctr_responses[groupIndex]-1)
1058 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, fileSize)
1059 msg = msg + getEventName(fileName,ftpType,"onap","pano",pnfs)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001060 seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001061 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001062 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001063 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001064
1065 return buildOkResponse("["+msg+"]")
1066
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001067def tc710(groupIndex, changeId, filePrefix, ftpType):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001068 global ctr_responses
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001069 global ctr_events
1070
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001071
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001072 ctr_responses[groupIndex] = ctr_responses[groupIndex] + 1
1073
1074 if (ctr_responses[groupIndex] > 100):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001075 return buildOkResponse("[]")
1076
1077 msg = ""
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001078
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001079 batch = (ctr_responses[groupIndex]-1)%20;
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001080
1081 for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700
1082 if (pnfs > 0):
1083 msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001084 nodeIndex=pnfs + batch*35
1085 nodeName = createNodeName(nodeIndex)
1086 msg = msg + getEventHead(groupIndex, changeId, nodeName)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001087
1088 for i in range(100): # 100 files per event
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001089 seqNr = i + int((ctr_responses[groupIndex]-1)/20);
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001090 if i != 0: msg = msg + ","
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001091 fileName = createFileName(groupIndex, filePrefix, nodeName, seqNr, "1MB")
1092 msg = msg + getEventName(fileName,ftpType,"onap","pano",nodeIndex)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001093 seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001094 fileMap[groupIndex][seqNr*hash(filePrefix)] = seqNr
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001095
1096 msg = msg + getEventEnd()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001097 ctr_events[groupIndex] = ctr_events[groupIndex]+1
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001098
1099 return buildOkResponse("["+msg+"]")
1100
1101
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001102#### Functions to build json messages and respones ####
1103
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001104def createNodeName(index):
1105 return "PNF"+str(index);
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001106
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001107def createFileName(groupIndex, filePrefix, nodeName, index, size):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001108 global ctr_files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001109 ctr_files[groupIndex] = ctr_files[groupIndex] + 1
1110 return filePrefix+"20000626.2315+0200-2330+0200_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz";
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001111
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001112def createMissingFileName(groupIndex, filePrefix, nodeName, index, size):
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001113 global ctr_files
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001114 ctr_files[groupIndex] = ctr_files[groupIndex] + 1
1115 return filePrefix+"MissingFile_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz";
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001116
1117
1118# Function to build fixed beginning of an event
1119
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001120def getEventHead(groupIndex, changeId, nodename):
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001121 global pnfMap
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001122 pnfMap[groupIndex].add(nodename)
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001123 headStr = """
1124 {
TamasBakai9b780332019-02-15 08:38:16 +00001125 "event": {
1126 "commonEventHeader": {
1127 "startEpochMicrosec": 8745745764578,
1128 "eventId": "FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1",
1129 "timeZoneOffset": "UTC+05.30",
1130 "internalHeaderFields": {
1131 "collectorTimeStamp": "Tue, 09 18 2018 10:56:52 UTC"
1132 },
1133 "priority": "Normal",
1134 "version": "4.0.1",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001135 "reportingEntityName": \"""" + nodename + """",
TamasBakai9b780332019-02-15 08:38:16 +00001136 "sequence": 0,
1137 "domain": "notification",
1138 "lastEpochMicrosec": 8745745764578,
1139 "eventName": "Noti_RnNode-Ericsson_FileReady",
1140 "vesEventListenerVersion": "7.0.1",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001141 "sourceName": \"""" + nodename + """"
TamasBakai9b780332019-02-15 08:38:16 +00001142 },
1143 "notificationFields": {
1144 "notificationFieldsVersion": "2.0",
1145 "changeType": "FileReady",
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001146 "changeIdentifier": \"""" + changeId + """",
TamasBakai9b780332019-02-15 08:38:16 +00001147 "arrayOfNamedHashMap": [
ecaiyanlinux796e8fe2019-08-21 12:10:33 +00001148 """
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001149 return headStr
1150
1151# Function to build the variable part of an event
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001152def getEventName(fn,type,user,passwd, nodeIndex):
1153 nodeIndex=nodeIndex%num_ftp_servers
1154 port = sftp_ports[nodeIndex]
1155 ip = sftp_hosts[nodeIndex]
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001156 if (type == "ftps"):
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001157 port = ftps_ports[nodeIndex]
1158 ip = ftps_hosts[nodeIndex]
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001159
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001160 nameStr = """{
1161 "name": \"""" + fn + """",
TamasBakai9b780332019-02-15 08:38:16 +00001162 "hashMap": {
1163 "fileFormatType": "org.3GPP.32.435#measCollec",
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001164 "location": \"""" + type + """://""" + user + """:""" + passwd + """@""" + ip + """:""" + str(port) + """/""" + fn + """",
TamasBakai9b780332019-02-15 08:38:16 +00001165 "fileFormatVersion": "V10",
1166 "compression": "gzip"
1167 }
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001168 } """
1169 return nameStr
1170
1171# Function to build fixed end of an event
1172def getEventEnd():
1173 endStr = """
TamasBakai9b780332019-02-15 08:38:16 +00001174 ]
1175 }
1176 }
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001177 }
1178 """
1179 return endStr
TamasBakai9b780332019-02-15 08:38:16 +00001180
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001181# Function to build an OK reponse from a message string
1182def buildOkResponse(msg):
1183 response = app.response_class(
1184 response=str.encode(msg),
1185 status=200,
1186 mimetype='application/json')
1187 return response
TamasBakai9b780332019-02-15 08:38:16 +00001188
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001189# Function to build an empty message with status
1190def buildEmptyResponse(status_code):
1191 response = app.response_class(
1192 response=str.encode(""),
1193 status=status_code,
1194 mimetype='application/json')
1195 return response
TamasBakai9b780332019-02-15 08:38:16 +00001196
1197
1198if __name__ == "__main__":
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001199
1200 # IP addresses to use for ftp servers, using localhost if not env var is set
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001201 sftp_sims = os.environ.get('SFTP_SIMS', 'localhost:1022')
1202 ftps_sims = os.environ.get('FTPS_SIMS', 'localhost:21')
1203 num_ftp_servers = int(os.environ.get('NUM_FTP_SERVERS', 1))
1204
1205 print("Configured sftp sims: " + sftp_sims)
1206 print("Configured ftps sims: " + ftps_sims)
1207 print("Configured number of ftp servers: " + str(num_ftp_servers))
1208
1209 tmp=sftp_sims.split(',')
1210 for i in range(len(tmp)):
1211 hp=tmp[i].split(':')
1212 sftp_hosts.append(hp[0])
1213 sftp_ports.append(hp[1])
1214
1215 tmp=ftps_sims.split(',')
1216 for i in range(len(tmp)):
1217 hp=tmp[i].split(':')
1218 ftps_hosts.append(hp[0])
1219 ftps_ports.append(hp[1])
1220
1221 groups = os.environ.get('MR_GROUPS', 'OpenDcae-c12:PM_MEAS_FILES')
TamasBakaifa357df2019-08-15 08:25:27 +00001222 print("Groups detected: " + groups )
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001223 configuredPrefixes = os.environ.get('MR_FILE_PREFIX_MAPPING', 'PM_MEAS_FILES:A')
1224
1225 if (len(groups) == 0 ):
1226 groups='OpenDcae-c12:PM_MEAS_FILES'
1227 print("Using default group: " + groups)
1228 else:
1229 print("Configured groups: " + groups)
1230
1231 if (len(configuredPrefixes) == 0 ):
1232 configuredPrefixes='PM_MEAS_FILES:A'
1233 print("Using default changeid to file prefix mapping: " + configuredPrefixes)
1234 else:
1235 print("Configured changeid to file prefix mapping: " + configuredPrefixes)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001236
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001237 #Counters
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001238 ctr_responses = []
1239 ctr_requests = []
1240 ctr_files=[]
1241 ctr_events = []
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001242 startTime = time.time()
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001243 firstPollTime = []
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001244 runningState = "Started"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001245 #Keeps all responded file names
1246 fileMap = []
1247 #Keeps all responded PNF names
1248 pnfMap = []
1249 #Handles rop periods for tests that deliveres events every 15 min
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001250 rop_counter = 0
1251 rop_timestamp = time.time()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001252
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001253 #List of configured group names
1254 groupNames = []
1255 #Mapping between group name and index in groupNames
1256 groupNameIndexes = {}
1257 #String of configured groups
1258 configuredGroups = ""
1259 #String of configured change identifiers
1260 configuredChangeIds = ""
1261 #List of changed identifiers
1262 changeIds = []
1263 #List of filePrefixes
1264 filePrefixes = {}
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001265
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001266 tmp=groups.split(',')
1267 for i in range(len(tmp)):
1268 g=tmp[i].split(':')
1269 for j in range(len(g)):
1270 g[j] = g[j].strip()
1271 if (j == 0):
1272 if (len(configuredGroups) > 0):
1273 configuredGroups=configuredGroups+","
1274 configuredGroups=configuredGroups+g[0]
1275 groupNames.append(g[0])
1276 groupNameIndexes[g[0]] = i
1277 changeIds.append({})
1278 ctr_responses.append(0)
1279 ctr_requests.append(0)
1280 ctr_files.append(0)
1281 ctr_events.append(0)
1282 firstPollTime.append(0)
1283 pnfMap.append(set())
1284 fileMap.append({})
1285 if (len(configuredChangeIds) > 0):
1286 configuredChangeIds=configuredChangeIds+","
1287 else:
1288 changeIds[i][j-1]=g[j]
1289 if (j > 1):
1290 configuredChangeIds=configuredChangeIds+":"
1291 configuredChangeIds=configuredChangeIds+g[j]
1292
1293 # Create a map between changeid and file name prefix
1294 tmp=configuredPrefixes.split(',')
1295 for i in range(len(tmp)):
1296 p=tmp[i].split(':')
1297 filePrefixes[p[0]] = p[1]
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001298
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001299 tc_num = "Not set"
1300 tc_help = "Not set"
TamasBakai9b780332019-02-15 08:38:16 +00001301
1302 parser = argparse.ArgumentParser()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001303
ecaiyanlinux796e8fe2019-08-21 12:10:33 +00001304#SFTP TCs with single ME
TamasBakai9b780332019-02-15 08:38:16 +00001305 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001306 '--tc100',
TamasBakai9b780332019-02-15 08:38:16 +00001307 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001308 help='TC100 - One ME, SFTP, 1 1MB file, 1 event')
TamasBakai9b780332019-02-15 08:38:16 +00001309 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001310 '--tc101',
TamasBakai9b780332019-02-15 08:38:16 +00001311 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001312 help='TC101 - One ME, SFTP, 1 5MB file, 1 event')
TamasBakai9b780332019-02-15 08:38:16 +00001313 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001314 '--tc102',
TamasBakai9b780332019-02-15 08:38:16 +00001315 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001316 help='TC102 - One ME, SFTP, 1 50MB file, 1 event')
1317
TamasBakai9b780332019-02-15 08:38:16 +00001318 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001319 '--tc110',
TamasBakai9b780332019-02-15 08:38:16 +00001320 action='store_true',
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001321 help='TC110 - One ME, SFTP, 1MB files, 1 file per event, 100 events, 1 event per poll.')
1322 parser.add_argument(
1323 '--tc111',
1324 action='store_true',
1325 help='TC111 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll.')
1326 parser.add_argument(
1327 '--tc112',
1328 action='store_true',
1329 help='TC112 - One ME, SFTP, 5MB files, 100 files per event, 100 events, 1 event per poll.')
1330 parser.add_argument(
1331 '--tc113',
1332 action='store_true',
1333 help='TC113 - One ME, SFTP, 1MB files, 100 files per event, 100 events. All events in one poll.')
1334
1335 parser.add_argument(
1336 '--tc120',
1337 action='store_true',
1338 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')
1339 parser.add_argument(
1340 '--tc121',
1341 action='store_true',
1342 help='TC121 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files')
1343 parser.add_argument(
1344 '--tc122',
1345 action='store_true',
1346 help='TC122 - One ME, SFTP, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ')
1347
1348 parser.add_argument(
1349 '--tc1000',
1350 action='store_true',
1351 help='TC1000 - One ME, SFTP, 1MB files, 100 files per event, endless number of events, 1 event per poll')
1352 parser.add_argument(
1353 '--tc1001',
1354 action='store_true',
1355 help='TC1001 - One ME, SFTP, 5MB files, 100 files per event, endless number of events, 1 event per poll')
1356
1357# SFTP TCs with multiple MEs
1358 parser.add_argument(
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001359 '--tc500',
1360 action='store_true',
1361 help='TC500 - 700 MEs, SFTP, 1MB files, 2 new files per event, 700 events, all event in one poll.')
1362
1363 parser.add_argument(
1364 '--tc501',
1365 action='store_true',
1366 help='TC501 - 700 MEs, SFTP, 5MB files, 2 new files per event, 700 events, all event in one poll.')
1367
1368 parser.add_argument(
1369 '--tc502',
1370 action='store_true',
1371 help='TC502 - 700 MEs, SFTP, 50MB files, 2 new files per event, 700 events, all event in one poll.')
1372
1373 parser.add_argument(
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001374 '--tc510',
1375 action='store_true',
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001376 help='TC510 - 700 MEs, SFTP, 1MB files, 1 file per event, 3500 events, 700 event per poll.')
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001377
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001378 parser.add_argument(
1379 '--tc511',
1380 action='store_true',
1381 help='TC511 - 700 MEs, SFTP, 1KB files, 1 file per event, 3500 events, 700 event per poll.')
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001382
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001383 parser.add_argument(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001384 '--tc550',
1385 action='store_true',
1386 help='TC550 - 700 MEs, SFTP, 50MB files, 1 file per event, 3500 events, 700 event per poll.')
1387
1388 parser.add_argument(
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001389 '--tc710',
1390 action='store_true',
1391 help='TC710 - 700 MEs, SFTP, 1MB files, 100 files per event, 3500 events, 35 event per poll.')
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001392
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001393 parser.add_argument(
1394 '--tc1100',
1395 action='store_true',
1396 help='TC1100 - 700 ME, SFTP, 1MB files, 100 files per event, endless number of events, 35 event per poll')
1397 parser.add_argument(
1398 '--tc1101',
1399 action='store_true',
1400 help='TC1101 - 700 ME, SFTP, 5MB files, 100 files per event, endless number of events, 35 event per poll')
1401 parser.add_argument(
1402 '--tc1102',
1403 action='store_true',
1404 help='TC1102 - 700 ME, SFTP, 50MB files, 100 files per event, endless number of events, 35 event per poll')
1405
1406 parser.add_argument(
1407 '--tc1200',
1408 action='store_true',
1409 help='TC1200 - 700 ME, SFTP, 1MB files, 100 new files per event, endless number of events, 35 event per poll')
1410 parser.add_argument(
1411 '--tc1201',
1412 action='store_true',
1413 help='TC1201 - 700 ME, SFTP, 5MB files, 100 new files per event, endless number of events, 35 event per poll')
1414 parser.add_argument(
1415 '--tc1202',
1416 action='store_true',
1417 help='TC1202 - 700 ME, SFTP, 50MB files, 100 new files per event, endless number of events, 35 event per poll')
1418
1419 parser.add_argument(
1420 '--tc1300',
1421 action='store_true',
1422 help='TC1300 - 700 ME, SFTP, 1MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1423 parser.add_argument(
1424 '--tc1301',
1425 action='store_true',
1426 help='TC1301 - 700 ME, SFTP, 5MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1427 parser.add_argument(
1428 '--tc1302',
1429 action='store_true',
1430 help='TC1302 - 700 ME, SFTP, 50MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1431
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001432 parser.add_argument(
1433 '--tc1500',
1434 action='store_true',
1435 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 +00001436
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001437# FTPS TCs with single ME
1438 parser.add_argument(
1439 '--tc200',
1440 action='store_true',
1441 help='TC200 - One ME, FTPS, 1 1MB file, 1 event')
1442 parser.add_argument(
1443 '--tc201',
1444 action='store_true',
1445 help='TC201 - One ME, FTPS, 1 5MB file, 1 event')
1446 parser.add_argument(
1447 '--tc202',
1448 action='store_true',
1449 help='TC202 - One ME, FTPS, 1 50MB file, 1 event')
1450
1451 parser.add_argument(
1452 '--tc210',
1453 action='store_true',
1454 help='TC210 - One ME, FTPS, 1MB files, 1 file per event, 100 events, 1 event per poll.')
1455 parser.add_argument(
1456 '--tc211',
1457 action='store_true',
1458 help='TC211 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll.')
1459 parser.add_argument(
1460 '--tc212',
1461 action='store_true',
1462 help='TC212 - One ME, FTPS, 5MB files, 100 files per event, 100 events, 1 event per poll.')
1463 parser.add_argument(
1464 '--tc213',
1465 action='store_true',
1466 help='TC213 - One ME, FTPS, 1MB files, 100 files per event, 100 events. All events in one poll.')
1467
1468 parser.add_argument(
1469 '--tc220',
1470 action='store_true',
1471 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')
1472 parser.add_argument(
1473 '--tc221',
1474 action='store_true',
1475 help='TC221 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files')
1476 parser.add_argument(
1477 '--tc222',
1478 action='store_true',
1479 help='TC222 - One ME, FTPS, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ')
1480
1481 parser.add_argument(
1482 '--tc2000',
1483 action='store_true',
1484 help='TC2000 - One ME, FTPS, 1MB files, 100 files per event, endless number of events, 1 event per poll')
1485 parser.add_argument(
1486 '--tc2001',
1487 action='store_true',
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001488 help='TC2001 - One ME, FTPS, 5MB files, 100 files per event, endless number of events, 1 event per poll')
1489
1490
1491 parser.add_argument(
1492 '--tc2100',
1493 action='store_true',
1494 help='TC2100 - 700 ME, FTPS, 1MB files, 100 files per event, endless number of events, 35 event per poll')
1495 parser.add_argument(
1496 '--tc2101',
1497 action='store_true',
1498 help='TC2101 - 700 ME, FTPS, 5MB files, 100 files per event, endless number of events, 35 event per poll')
1499 parser.add_argument(
1500 '--tc2102',
1501 action='store_true',
1502 help='TC2102 - 700 ME, FTPS, 50MB files, 100 files per event, endless number of events, 35 event per poll')
1503
1504 parser.add_argument(
1505 '--tc2200',
1506 action='store_true',
1507 help='TC2200 - 700 ME, FTPS, 1MB files, 100 new files per event, endless number of events, 35 event per poll')
1508 parser.add_argument(
1509 '--tc2201',
1510 action='store_true',
1511 help='TC2201 - 700 ME, FTPS, 5MB files, 100 new files per event, endless number of events, 35 event per poll')
1512 parser.add_argument(
1513 '--tc2202',
1514 action='store_true',
1515 help='TC2202 - 700 ME, FTPS, 50MB files, 100 new files per event, endless number of events, 35 event per poll')
1516
1517 parser.add_argument(
1518 '--tc2300',
1519 action='store_true',
1520 help='TC2300 - 700 ME, FTPS, 1MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1521 parser.add_argument(
1522 '--tc2301',
1523 action='store_true',
1524 help='TC2301 - 700 ME, FTPS, 5MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1525 parser.add_argument(
1526 '--tc2302',
1527 action='store_true',
1528 help='TC2302 - 700 ME, FTPS, 50MB files, 100 files per event, endless number of events, 35 event per poll, 20 event polls every 15min')
1529
1530 parser.add_argument(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001531 '--tc2500',
1532 action='store_true',
1533 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')
1534
1535 parser.add_argument(
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001536 '--tc600',
1537 action='store_true',
1538 help='TC600 - 700 MEs, FTPS, 1MB files, 2 new files per event, 700 events, all event in one poll.')
1539
1540 parser.add_argument(
1541 '--tc601',
1542 action='store_true',
1543 help='TC601 - 700 MEs, FTPS, 5MB files, 2 new files per event, 700 events, all event in one poll.')
1544
1545 parser.add_argument(
1546 '--tc602',
1547 action='store_true',
1548 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 +00001549
1550 parser.add_argument(
1551 '--tc610',
1552 action='store_true',
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001553 help='TC610 - 700 MEs, FTPS, 1MB files, 1 file per event, 3500 events, 700 event per poll.')
1554
1555 parser.add_argument(
1556 '--tc611',
1557 action='store_true',
1558 help='TC611 - 700 MEs, FTPS, 1KB files, 1 file per event, 3500 events, 700 event per poll.')
1559
1560 parser.add_argument(
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001561 '--tc650',
1562 action='store_true',
1563 help='TC610 - 700 MEs, FTPS, 50MB files, 1 file per event, 3500 events, 700 event per poll.')
1564
1565 parser.add_argument(
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001566 '--tc810',
1567 action='store_true',
1568 help='TC810 - 700 MEs, FTPS, 1MB files, 100 files per event, 3500 events, 35 event per poll.')
TamasBakai9b780332019-02-15 08:38:16 +00001569
1570 args = parser.parse_args()
1571
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001572
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001573
1574 if args.tc100:
1575 tc_num = "TC# 100"
1576 elif args.tc101:
1577 tc_num = "TC# 101"
1578 elif args.tc102:
1579 tc_num = "TC# 102"
1580
1581 elif args.tc110:
1582 tc_num = "TC# 110"
1583 elif args.tc111:
1584 tc_num = "TC# 111"
1585 elif args.tc112:
1586 tc_num = "TC# 112"
1587 elif args.tc113:
1588 tc_num = "TC# 113"
1589
1590 elif args.tc120:
1591 tc_num = "TC# 120"
1592 elif args.tc121:
1593 tc_num = "TC# 121"
1594 elif args.tc122:
1595 tc_num = "TC# 122"
1596
1597 elif args.tc1000:
1598 tc_num = "TC# 1000"
1599 elif args.tc1001:
1600 tc_num = "TC# 1001"
1601
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001602 elif args.tc1100:
1603 tc_num = "TC# 1100"
1604 elif args.tc1101:
1605 tc_num = "TC# 1101"
1606 elif args.tc1102:
1607 tc_num = "TC# 1102"
1608 elif args.tc1200:
1609 tc_num = "TC# 1200"
1610 elif args.tc1201:
1611 tc_num = "TC# 1201"
1612 elif args.tc1202:
1613 tc_num = "TC# 1202"
1614 elif args.tc1300:
1615 tc_num = "TC# 1300"
1616 elif args.tc1301:
1617 tc_num = "TC# 1301"
1618 elif args.tc1302:
1619 tc_num = "TC# 1302"
1620
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001621 elif args.tc1500:
1622 tc_num = "TC# 1500"
1623
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001624 elif args.tc500:
1625 tc_num = "TC# 500"
1626 elif args.tc501:
1627 tc_num = "TC# 501"
1628 elif args.tc502:
1629 tc_num = "TC# 502"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001630 elif args.tc510:
1631 tc_num = "TC# 510"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001632 elif args.tc511:
1633 tc_num = "TC# 511"
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001634
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001635 elif args.tc550:
1636 tc_num = "TC# 550"
1637
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001638 elif args.tc710:
1639 tc_num = "TC# 710"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001640
1641 elif args.tc200:
1642 tc_num = "TC# 200"
1643 elif args.tc201:
1644 tc_num = "TC# 201"
1645 elif args.tc202:
1646 tc_num = "TC# 202"
1647
1648 elif args.tc210:
1649 tc_num = "TC# 210"
1650 elif args.tc211:
1651 tc_num = "TC# 211"
1652 elif args.tc212:
1653 tc_num = "TC# 212"
1654 elif args.tc213:
1655 tc_num = "TC# 213"
1656
1657 elif args.tc220:
1658 tc_num = "TC# 220"
1659 elif args.tc221:
1660 tc_num = "TC# 221"
1661 elif args.tc222:
1662 tc_num = "TC# 222"
1663
1664 elif args.tc2000:
1665 tc_num = "TC# 2000"
1666 elif args.tc2001:
1667 tc_num = "TC# 2001"
1668
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001669 elif args.tc2100:
1670 tc_num = "TC# 2100"
1671 elif args.tc2101:
1672 tc_num = "TC# 2101"
1673 elif args.tc2102:
1674 tc_num = "TC# 2102"
1675 elif args.tc2200:
1676 tc_num = "TC# 2200"
1677 elif args.tc2201:
1678 tc_num = "TC# 2201"
1679 elif args.tc2202:
1680 tc_num = "TC# 2202"
1681 elif args.tc2300:
1682 tc_num = "TC# 2300"
1683 elif args.tc2301:
1684 tc_num = "TC# 2301"
1685 elif args.tc2302:
1686 tc_num = "TC# 2302"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001687
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001688 elif args.tc2500:
1689 tc_num = "TC# 2500"
1690
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001691 elif args.tc600:
1692 tc_num = "TC# 600"
1693 elif args.tc601:
1694 tc_num = "TC# 601"
1695 elif args.tc602:
1696 tc_num = "TC# 602"
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001697 elif args.tc610:
1698 tc_num = "TC# 610"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001699 elif args.tc611:
1700 tc_num = "TC# 611"
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001701 elif args.tc650:
1702 tc_num = "TC# 650"
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001703 elif args.tc810:
1704 tc_num = "TC# 810"
TamasBakai9b780332019-02-15 08:38:16 +00001705
1706 else:
1707 print("No TC was defined")
1708 print("use --help for usage info")
1709 sys.exit()
BjornMagnussonXAf8b34f02019-03-22 09:48:38 +00001710
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001711 print("TC num: " + tc_num)
BjornMagnussonXA42dcb262019-04-26 19:29:54 +00001712
BjornMagnussonXAa79a0432019-07-17 08:26:50 +00001713 for i in range(len(sftp_hosts)):
1714 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.")
1715
1716 for i in range(len(ftps_hosts)):
1717 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.")
1718
1719 print("Using up to " + str(num_ftp_servers) + " ftp servers, for each protocol for PNFs.")
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001720
ecaiyanlinux796e8fe2019-08-21 12:10:33 +00001721 def https_app(**kwargs):
1722 import ssl
1723 context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
1724 context.load_cert_chain('cert/cert.pem', 'cert/key.pem')
1725 app.run(ssl_context=context, **kwargs)
BjornMagnussonXAf4e18362019-04-10 13:04:08 +00001726
ecaiyanlinux796e8fe2019-08-21 12:10:33 +00001727 from multiprocessing import Process
1728
1729 kwargs = dict(host=HOST_IP)
1730 Process(target=https_app, kwargs=dict(kwargs, port=HOST_PORT_TLS),
1731 daemon=True).start()
1732
1733 app.run(port=HOST_PORT, host=HOST_IP)