TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 1 | import argparse |
| 2 | import os |
| 3 | from werkzeug import secure_filename |
| 4 | from flask import Flask, render_template, request |
| 5 | from time import sleep |
| 6 | import sys |
| 7 | import json |
| 8 | from flask import Flask |
| 9 | app = Flask(__name__) |
| 10 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 11 | #Server info |
| 12 | HOST_IP = "0.0.0.0" |
| 13 | HOST_PORT = 2222 |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 14 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 15 | #Test function to check server running |
| 16 | @app.route('/', |
| 17 | methods=['GET']) |
| 18 | def index(): |
| 19 | return 'Hello world' |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 20 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 21 | #Returns number of polls |
| 22 | @app.route('/ctr_requests', |
| 23 | methods=['GET']) |
| 24 | def counter_requests(): |
| 25 | global ctr_requests |
| 26 | return str(ctr_requests) |
| 27 | |
| 28 | #Returns number of replies |
| 29 | @app.route('/ctr_responses', |
| 30 | methods=['GET']) |
| 31 | def counter_responses(): |
| 32 | global ctr_responses |
| 33 | return str(ctr_responses) |
| 34 | |
| 35 | #Returns number of unique files |
| 36 | @app.route('/ctr_unique_files', |
| 37 | methods=['GET']) |
| 38 | def counter_uniquefiles(): |
| 39 | global fileMap |
| 40 | return str(len(fileMap)) |
| 41 | |
| 42 | #Returns tc info |
| 43 | @app.route('/tc_info', |
| 44 | methods=['GET']) |
| 45 | def testcase_info(): |
| 46 | global tc_num |
| 47 | return tc_num |
| 48 | |
| 49 | #Messages polling function |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 50 | @app.route( |
| 51 | "/events/unauthenticated.VES_NOTIFICATION_OUTPUT/OpenDcae-c12/C12", |
| 52 | methods=['GET']) |
| 53 | def MR_reply(): |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 54 | global ctr_requests |
| 55 | global args |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 56 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 57 | ctr_requests = ctr_requests + 1 |
| 58 | print("MR: poll request#: " + str(ctr_requests)) |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 59 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 60 | if args.tc100: |
| 61 | return tc100("sftp") |
| 62 | elif args.tc101: |
| 63 | return tc101("sftp") |
| 64 | elif args.tc102: |
| 65 | return tc102("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 66 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 67 | elif args.tc110: |
| 68 | return tc110("sftp") |
| 69 | elif args.tc111: |
| 70 | return tc111("sftp") |
| 71 | elif args.tc112: |
| 72 | return tc112("sftp") |
| 73 | elif args.tc113: |
| 74 | return tc113("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 75 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 76 | elif args.tc120: |
| 77 | return tc120("sftp") |
| 78 | elif args.tc121: |
| 79 | return tc121("sftp") |
| 80 | elif args.tc122: |
| 81 | return tc122("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 82 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 83 | elif args.tc1000: |
| 84 | return tc1000("sftp") |
| 85 | elif args.tc1001: |
| 86 | return tc1001("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 87 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 88 | elif args.tc510: |
| 89 | return tc510("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 90 | |
| 91 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 92 | elif args.tc200: |
| 93 | return tc200("ftps") |
| 94 | elif args.tc201: |
| 95 | return tc201("ftps") |
| 96 | elif args.tc202: |
| 97 | return tc202("ftps") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 98 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 99 | elif args.tc210: |
| 100 | return tc210("ftps") |
| 101 | elif args.tc211: |
| 102 | return tc211("ftps") |
| 103 | elif args.tc212: |
| 104 | return tc212("ftps") |
| 105 | elif args.tc213: |
| 106 | return tc213("ftps") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 107 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 108 | elif args.tc220: |
| 109 | return tc220("ftps") |
| 110 | elif args.tc221: |
| 111 | return tc221("ftps") |
| 112 | elif args.tc222: |
| 113 | return tc222("ftps") |
| 114 | |
| 115 | elif args.tc2000: |
| 116 | return tc2000("ftps") |
| 117 | elif args.tc2001: |
| 118 | return tc2001("ftps") |
| 119 | |
| 120 | elif args.tc610: |
| 121 | return tc510("ftps") |
| 122 | |
| 123 | |
| 124 | #### Test case functions |
| 125 | |
| 126 | |
| 127 | def tc100(ftptype): |
| 128 | global ctr_responses |
| 129 | global ctr_unique_files |
| 130 | |
| 131 | ctr_responses = ctr_responses + 1 |
| 132 | |
| 133 | if (ctr_responses > 1): |
| 134 | return buildOkResponse("[]") |
| 135 | |
| 136 | seqNr = (ctr_responses-1) |
| 137 | msg = getEventHead() + getEventName("1MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) + getEventEnd() |
| 138 | fileMap[seqNr] = seqNr |
| 139 | return buildOkResponse("["+msg+"]") |
| 140 | |
| 141 | def tc101(ftptype): |
| 142 | global ctr_responses |
| 143 | global ctr_unique_files |
| 144 | |
| 145 | ctr_responses = ctr_responses + 1 |
| 146 | |
| 147 | if (ctr_responses > 1): |
| 148 | return buildOkResponse("[]") |
| 149 | |
| 150 | seqNr = (ctr_responses-1) |
| 151 | msg = getEventHead() + getEventName("5MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) + getEventEnd() |
| 152 | fileMap[seqNr] = seqNr |
| 153 | |
| 154 | return buildOkResponse("["+msg+"]") |
| 155 | |
| 156 | def tc102(ftptype): |
| 157 | global ctr_responses |
| 158 | global ctr_unique_files |
| 159 | |
| 160 | ctr_responses = ctr_responses + 1 |
| 161 | |
| 162 | if (ctr_responses > 1): |
| 163 | return buildOkResponse("[]") |
| 164 | |
| 165 | seqNr = (ctr_responses-1) |
| 166 | msg = getEventHead() + getEventName("50MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) + getEventEnd() |
| 167 | fileMap[seqNr] = seqNr |
| 168 | |
| 169 | return buildOkResponse("["+msg+"]") |
| 170 | |
| 171 | def tc110(ftptype): |
| 172 | global ctr_responses |
| 173 | global ctr_unique_files |
| 174 | |
| 175 | ctr_responses = ctr_responses + 1 |
| 176 | |
| 177 | if (ctr_responses > 100): |
| 178 | return buildOkResponse("[]") |
| 179 | |
| 180 | seqNr = (ctr_responses-1) |
| 181 | msg = getEventHead() + getEventName("1MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) + getEventEnd() |
| 182 | fileMap[seqNr] = seqNr |
| 183 | |
| 184 | return buildOkResponse("["+msg+"]") |
| 185 | |
| 186 | def tc111(ftptype): |
| 187 | global ctr_responses |
| 188 | global ctr_unique_files |
| 189 | |
| 190 | ctr_responses = ctr_responses + 1 |
| 191 | |
| 192 | if (ctr_responses > 100): |
| 193 | return buildOkResponse("[]") |
| 194 | |
| 195 | msg = getEventHead() |
| 196 | |
| 197 | for i in range(100): |
| 198 | seqNr = i+(ctr_responses-1) |
| 199 | if i != 0: msg = msg + "," |
| 200 | msg = msg + getEventName("1MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) |
| 201 | fileMap[seqNr] = seqNr |
| 202 | |
| 203 | msg = msg + getEventEnd() |
| 204 | |
| 205 | return buildOkResponse("["+msg+"]") |
| 206 | |
| 207 | def tc112(ftptype): |
| 208 | global ctr_responses |
| 209 | global ctr_unique_files |
| 210 | |
| 211 | ctr_responses = ctr_responses + 1 |
| 212 | |
| 213 | if (ctr_responses > 100): |
| 214 | return buildOkResponse("[]") |
| 215 | |
| 216 | msg = getEventHead() |
| 217 | |
| 218 | for i in range(100): |
| 219 | seqNr = i+(ctr_responses-1) |
| 220 | if i != 0: msg = msg + "," |
| 221 | msg = msg + getEventName("5MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) |
| 222 | fileMap[seqNr] = seqNr |
| 223 | |
| 224 | msg = msg + getEventEnd() |
| 225 | |
| 226 | return buildOkResponse("["+msg+"]") |
| 227 | |
| 228 | def tc113(ftptype): |
| 229 | global ctr_responses |
| 230 | global ctr_unique_files |
| 231 | |
| 232 | ctr_responses = ctr_responses + 1 |
| 233 | |
| 234 | if (ctr_responses > 1): |
| 235 | return buildOkResponse("[]") |
| 236 | |
| 237 | msg = "" |
| 238 | |
| 239 | for evts in range(100): # build 100 evts |
| 240 | if (evts > 0): |
| 241 | msg = msg + "," |
| 242 | msg = msg + getEventHead() |
| 243 | for i in range(100): # build 100 files |
| 244 | seqNr = i+evts+100*(ctr_responses-1) |
| 245 | if i != 0: msg = msg + "," |
| 246 | msg = msg + getEventName("1MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) |
| 247 | fileMap[seqNr] = seqNr |
| 248 | |
| 249 | msg = msg + getEventEnd() |
| 250 | |
| 251 | return buildOkResponse("["+msg+"]") |
| 252 | |
| 253 | |
| 254 | def tc120(ftptype): |
| 255 | global ctr_responses |
| 256 | global ctr_unique_files |
| 257 | |
| 258 | ctr_responses = ctr_responses + 1 |
| 259 | |
| 260 | if (ctr_responses > 100): |
| 261 | return buildOkResponse("[]") |
| 262 | |
| 263 | if (ctr_responses % 10 == 2): |
| 264 | return # Return nothing |
| 265 | |
| 266 | if (ctr_responses % 10 == 3): |
| 267 | return buildOkResponse("") # Return empty message |
| 268 | |
| 269 | if (ctr_responses % 10 == 4): |
| 270 | return buildOkResponse(getEventHead()) # Return part of a json event |
| 271 | |
| 272 | if (ctr_responses % 10 == 5): |
| 273 | return buildEmptyResponse(404) # Return empty message with status code |
| 274 | |
| 275 | if (ctr_responses % 10 == 6): |
| 276 | sleep(60) |
| 277 | |
| 278 | |
| 279 | msg = getEventHead() |
| 280 | |
| 281 | for i in range(100): |
| 282 | seqNr = i+(ctr_responses-1) |
| 283 | if i != 0: msg = msg + "," |
| 284 | msg = msg + getEventName("1MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) |
| 285 | fileMap[seqNr] = seqNr |
| 286 | |
| 287 | msg = msg + getEventEnd() |
| 288 | |
| 289 | return buildOkResponse("["+msg+"]") |
| 290 | |
| 291 | def tc121(ftptype): |
| 292 | global ctr_responses |
| 293 | global ctr_unique_files |
| 294 | |
| 295 | ctr_responses = ctr_responses + 1 |
| 296 | |
| 297 | if (ctr_responses > 100): |
| 298 | return buildOkResponse("[]") |
| 299 | |
| 300 | msg = getEventHead() |
| 301 | |
| 302 | for i in range(100): |
| 303 | seqNr = i+(ctr_responses-1) |
| 304 | if (seqNr%10 == 0): # Every 10th file is "missing" |
| 305 | fn = "MissingFile_" + str(seqNr) + ".tar.gz" |
| 306 | else: |
| 307 | fn = "1MB_" + str(seqNr) + ".tar.gz" |
| 308 | fileMap[seqNr] = seqNr |
| 309 | |
| 310 | if i != 0: msg = msg + "," |
| 311 | msg = msg + getEventName(fn,ftptype,"onap","pano","localhost",1022) |
| 312 | |
| 313 | |
| 314 | msg = msg + getEventEnd() |
| 315 | |
| 316 | return buildOkResponse("["+msg+"]") |
| 317 | |
| 318 | def tc122(ftptype): |
| 319 | global ctr_responses |
| 320 | global ctr_unique_files |
| 321 | |
| 322 | ctr_responses = ctr_responses + 1 |
| 323 | |
| 324 | if (ctr_responses > 100): |
| 325 | return buildOkResponse("[]") |
| 326 | |
| 327 | msg = getEventHead() |
| 328 | |
| 329 | for i in range(100): |
| 330 | fn = "1MB_0.tar.gz" # All files identical names |
| 331 | if i != 0: msg = msg + "," |
| 332 | msg = msg + getEventName(fn,ftptype,"onap","pano","localhost",1022) |
| 333 | |
| 334 | fileMap[0] = 0 |
| 335 | msg = msg + getEventEnd() |
| 336 | |
| 337 | return buildOkResponse("["+msg+"]") |
| 338 | |
| 339 | |
| 340 | def tc1000(ftptype): |
| 341 | global ctr_responses |
| 342 | global ctr_unique_files |
| 343 | |
| 344 | ctr_responses = ctr_responses + 1 |
| 345 | |
| 346 | msg = getEventHead() |
| 347 | |
| 348 | for i in range(100): |
| 349 | seqNr = i+(ctr_responses-1) |
| 350 | if i != 0: msg = msg + "," |
| 351 | msg = msg + getEventName("1MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) |
| 352 | fileMap[seqNr] = seqNr |
| 353 | |
| 354 | msg = msg + getEventEnd() |
| 355 | |
| 356 | return buildOkResponse("["+msg+"]") |
| 357 | |
| 358 | def tc1001(ftptype): |
| 359 | global ctr_responses |
| 360 | global ctr_unique_files |
| 361 | |
| 362 | ctr_responses = ctr_responses + 1 |
| 363 | |
| 364 | msg = getEventHead() |
| 365 | |
| 366 | for i in range(100): |
| 367 | seqNr = i+(ctr_responses-1) |
| 368 | if i != 0: msg = msg + "," |
| 369 | msg = msg + getEventName("5MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) |
| 370 | fileMap[seqNr] = seqNr |
| 371 | |
| 372 | msg = msg + getEventEnd() |
| 373 | |
| 374 | return buildOkResponse("["+msg+"]") |
| 375 | |
| 376 | def tc510(ftptype): |
| 377 | global ctr_responses |
| 378 | global ctr_unique_files |
| 379 | |
| 380 | ctr_responses = ctr_responses + 1 |
| 381 | |
| 382 | if (ctr_responses > 5): |
| 383 | return buildOkResponse("[]") |
| 384 | |
| 385 | msg = "" |
| 386 | |
| 387 | for evts in range(700): # build events for 5 MEs |
| 388 | if (evts > 0): |
| 389 | msg = msg + "," |
| 390 | msg = msg + getEventHeadNodeName("PNF"+str(evts)) |
| 391 | seqNr = (ctr_responses-1) |
| 392 | msg = msg + getEventName("1MB_" + str(seqNr) + ".tar.gz",ftptype,"onap","pano","localhost",1022) |
| 393 | seqNr = seqNr + evts*1000000 #Create unique id for this node and file |
| 394 | fileMap[seqNr] = seqNr |
| 395 | msg = msg + getEventEnd() |
| 396 | |
| 397 | return buildOkResponse("["+msg+"]") |
| 398 | |
| 399 | #Mapping FTPS TCs |
| 400 | def tc200(ftptype): |
| 401 | return tc100(ftptype) |
| 402 | def tc201(ftptype): |
| 403 | return tc101(ftptype) |
| 404 | def tc202(ftptype): |
| 405 | return tc102(ftptype) |
| 406 | |
| 407 | def tc210(ftptype): |
| 408 | return tc110(ftptype) |
| 409 | def tc211(ftptype): |
| 410 | return tc111(ftptype) |
| 411 | def tc212(ftptype): |
| 412 | return tc112(ftptype) |
| 413 | def tc213(ftptype): |
| 414 | return tc113(ftptype) |
| 415 | |
| 416 | def tc220(ftptype): |
| 417 | return tc120(ftptype) |
| 418 | def tc221(ftptype): |
| 419 | return tc121(ftptype) |
| 420 | def tc222(ftptype): |
| 421 | return tc122(ftptype) |
| 422 | |
| 423 | def tc2000(ftptype): |
| 424 | return tc1000(ftptype) |
| 425 | def tc2001(ftptype): |
| 426 | return tc1001(ftptype) |
| 427 | |
| 428 | #### Functions to build json messages and respones #### |
| 429 | |
| 430 | # Function to build fixed beginning of an event |
| 431 | def getEventHead(): |
| 432 | return getEventHeadNodeName("oteNB5309") |
| 433 | |
| 434 | def getEventHeadNodeName(nodename): |
| 435 | headStr = """ |
| 436 | { |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 437 | "event": { |
| 438 | "commonEventHeader": { |
| 439 | "startEpochMicrosec": 8745745764578, |
| 440 | "eventId": "FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1", |
| 441 | "timeZoneOffset": "UTC+05.30", |
| 442 | "internalHeaderFields": { |
| 443 | "collectorTimeStamp": "Tue, 09 18 2018 10:56:52 UTC" |
| 444 | }, |
| 445 | "priority": "Normal", |
| 446 | "version": "4.0.1", |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 447 | "reportingEntityName": \"""" + nodename + """", |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 448 | "sequence": 0, |
| 449 | "domain": "notification", |
| 450 | "lastEpochMicrosec": 8745745764578, |
| 451 | "eventName": "Noti_RnNode-Ericsson_FileReady", |
| 452 | "vesEventListenerVersion": "7.0.1", |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 453 | "sourceName": \"""" + nodename + """" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 454 | }, |
| 455 | "notificationFields": { |
| 456 | "notificationFieldsVersion": "2.0", |
| 457 | "changeType": "FileReady", |
| 458 | "changeIdentifier": "PM_MEAS_FILES", |
| 459 | "arrayOfNamedHashMap": [ |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 460 | """ |
| 461 | return headStr |
| 462 | |
| 463 | # Function to build the variable part of an event |
| 464 | def getEventName(fn,type,user,passwd,ip,port): |
| 465 | nameStr = """{ |
| 466 | "name": \"""" + fn + """", |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 467 | "hashMap": { |
| 468 | "fileFormatType": "org.3GPP.32.435#measCollec", |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 469 | "location": \"""" + type + """://""" + user + """:""" + passwd + """@""" + ip + """:""" + str(port) + """/""" + fn + """", |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 470 | "fileFormatVersion": "V10", |
| 471 | "compression": "gzip" |
| 472 | } |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 473 | } """ |
| 474 | return nameStr |
| 475 | |
| 476 | # Function to build fixed end of an event |
| 477 | def getEventEnd(): |
| 478 | endStr = """ |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 479 | ] |
| 480 | } |
| 481 | } |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 482 | } |
| 483 | """ |
| 484 | return endStr |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 485 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 486 | # Function to build an OK reponse from a message string |
| 487 | def buildOkResponse(msg): |
| 488 | response = app.response_class( |
| 489 | response=str.encode(msg), |
| 490 | status=200, |
| 491 | mimetype='application/json') |
| 492 | return response |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 493 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 494 | # Function to build an empty message with status |
| 495 | def buildEmptyResponse(status_code): |
| 496 | response = app.response_class( |
| 497 | response=str.encode(""), |
| 498 | status=status_code, |
| 499 | mimetype='application/json') |
| 500 | return response |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 501 | |
| 502 | |
| 503 | if __name__ == "__main__": |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 504 | |
| 505 | #Counters |
| 506 | ctr_responses = 0 |
| 507 | ctr_requests = 0 |
| 508 | ctr_unique_files = 0 |
| 509 | |
| 510 | #Keeps all reponded file names |
| 511 | fileMap = {} |
| 512 | |
| 513 | tc_num = "Not set" |
| 514 | tc_help = "Not set" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 515 | |
| 516 | parser = argparse.ArgumentParser() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 517 | |
| 518 | #SFTP TCs with single ME |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 519 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 520 | '--tc100', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 521 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 522 | help='TC100 - One ME, SFTP, 1 1MB file, 1 event') |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 523 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 524 | '--tc101', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 525 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 526 | help='TC101 - One ME, SFTP, 1 5MB file, 1 event') |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 527 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 528 | '--tc102', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 529 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 530 | help='TC102 - One ME, SFTP, 1 50MB file, 1 event') |
| 531 | |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 532 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 533 | '--tc110', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 534 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 535 | help='TC110 - One ME, SFTP, 1MB files, 1 file per event, 100 events, 1 event per poll.') |
| 536 | parser.add_argument( |
| 537 | '--tc111', |
| 538 | action='store_true', |
| 539 | help='TC111 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll.') |
| 540 | parser.add_argument( |
| 541 | '--tc112', |
| 542 | action='store_true', |
| 543 | help='TC112 - One ME, SFTP, 5MB files, 100 files per event, 100 events, 1 event per poll.') |
| 544 | parser.add_argument( |
| 545 | '--tc113', |
| 546 | action='store_true', |
| 547 | help='TC113 - One ME, SFTP, 1MB files, 100 files per event, 100 events. All events in one poll.') |
| 548 | |
| 549 | parser.add_argument( |
| 550 | '--tc120', |
| 551 | action='store_true', |
| 552 | 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') |
| 553 | parser.add_argument( |
| 554 | '--tc121', |
| 555 | action='store_true', |
| 556 | help='TC121 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files') |
| 557 | parser.add_argument( |
| 558 | '--tc122', |
| 559 | action='store_true', |
| 560 | help='TC122 - One ME, SFTP, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ') |
| 561 | |
| 562 | parser.add_argument( |
| 563 | '--tc1000', |
| 564 | action='store_true', |
| 565 | help='TC1000 - One ME, SFTP, 1MB files, 100 files per event, endless number of events, 1 event per poll') |
| 566 | parser.add_argument( |
| 567 | '--tc1001', |
| 568 | action='store_true', |
| 569 | help='TC1001 - One ME, SFTP, 5MB files, 100 files per event, endless number of events, 1 event per poll') |
| 570 | |
| 571 | # SFTP TCs with multiple MEs |
| 572 | parser.add_argument( |
| 573 | '--tc510', |
| 574 | action='store_true', |
| 575 | help='TC510 - 5 MEs, SFTP, 1MB files, 1 file per event, 100 events, 1 event per poll.') |
| 576 | |
| 577 | |
| 578 | |
| 579 | # FTPS TCs with single ME |
| 580 | parser.add_argument( |
| 581 | '--tc200', |
| 582 | action='store_true', |
| 583 | help='TC200 - One ME, FTPS, 1 1MB file, 1 event') |
| 584 | parser.add_argument( |
| 585 | '--tc201', |
| 586 | action='store_true', |
| 587 | help='TC201 - One ME, FTPS, 1 5MB file, 1 event') |
| 588 | parser.add_argument( |
| 589 | '--tc202', |
| 590 | action='store_true', |
| 591 | help='TC202 - One ME, FTPS, 1 50MB file, 1 event') |
| 592 | |
| 593 | parser.add_argument( |
| 594 | '--tc210', |
| 595 | action='store_true', |
| 596 | help='TC210 - One ME, FTPS, 1MB files, 1 file per event, 100 events, 1 event per poll.') |
| 597 | parser.add_argument( |
| 598 | '--tc211', |
| 599 | action='store_true', |
| 600 | help='TC211 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll.') |
| 601 | parser.add_argument( |
| 602 | '--tc212', |
| 603 | action='store_true', |
| 604 | help='TC212 - One ME, FTPS, 5MB files, 100 files per event, 100 events, 1 event per poll.') |
| 605 | parser.add_argument( |
| 606 | '--tc213', |
| 607 | action='store_true', |
| 608 | help='TC213 - One ME, FTPS, 1MB files, 100 files per event, 100 events. All events in one poll.') |
| 609 | |
| 610 | parser.add_argument( |
| 611 | '--tc220', |
| 612 | action='store_true', |
| 613 | 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') |
| 614 | parser.add_argument( |
| 615 | '--tc221', |
| 616 | action='store_true', |
| 617 | help='TC221 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files') |
| 618 | parser.add_argument( |
| 619 | '--tc222', |
| 620 | action='store_true', |
| 621 | help='TC222 - One ME, FTPS, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ') |
| 622 | |
| 623 | parser.add_argument( |
| 624 | '--tc2000', |
| 625 | action='store_true', |
| 626 | help='TC2000 - One ME, FTPS, 1MB files, 100 files per event, endless number of events, 1 event per poll') |
| 627 | parser.add_argument( |
| 628 | '--tc2001', |
| 629 | action='store_true', |
| 630 | help='TC2001 - One ME, FTPS, 5MB files, 100 files per event, endless number of events, 1 event per poll') |
| 631 | |
| 632 | parser.add_argument( |
| 633 | '--tc610', |
| 634 | action='store_true', |
| 635 | help='TC510 - 5 MEs, FTPS, 1MB files, 1 file per event, 100 events, 1 event per poll.') |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 636 | |
| 637 | args = parser.parse_args() |
| 638 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 639 | |
| 640 | |
| 641 | if args.tc100: |
| 642 | tc_num = "TC# 100" |
| 643 | elif args.tc101: |
| 644 | tc_num = "TC# 101" |
| 645 | elif args.tc102: |
| 646 | tc_num = "TC# 102" |
| 647 | |
| 648 | elif args.tc110: |
| 649 | tc_num = "TC# 110" |
| 650 | elif args.tc111: |
| 651 | tc_num = "TC# 111" |
| 652 | elif args.tc112: |
| 653 | tc_num = "TC# 112" |
| 654 | elif args.tc113: |
| 655 | tc_num = "TC# 113" |
| 656 | |
| 657 | elif args.tc120: |
| 658 | tc_num = "TC# 120" |
| 659 | elif args.tc121: |
| 660 | tc_num = "TC# 121" |
| 661 | elif args.tc122: |
| 662 | tc_num = "TC# 122" |
| 663 | |
| 664 | elif args.tc1000: |
| 665 | tc_num = "TC# 1000" |
| 666 | elif args.tc1001: |
| 667 | tc_num = "TC# 1001" |
| 668 | |
| 669 | elif args.tc510: |
| 670 | tc_num = "TC# 510" |
| 671 | |
| 672 | elif args.tc200: |
| 673 | tc_num = "TC# 200" |
| 674 | elif args.tc201: |
| 675 | tc_num = "TC# 201" |
| 676 | elif args.tc202: |
| 677 | tc_num = "TC# 202" |
| 678 | |
| 679 | elif args.tc210: |
| 680 | tc_num = "TC# 210" |
| 681 | elif args.tc211: |
| 682 | tc_num = "TC# 211" |
| 683 | elif args.tc212: |
| 684 | tc_num = "TC# 212" |
| 685 | elif args.tc213: |
| 686 | tc_num = "TC# 213" |
| 687 | |
| 688 | elif args.tc220: |
| 689 | tc_num = "TC# 220" |
| 690 | elif args.tc221: |
| 691 | tc_num = "TC# 221" |
| 692 | elif args.tc222: |
| 693 | tc_num = "TC# 222" |
| 694 | |
| 695 | elif args.tc2000: |
| 696 | tc_num = "TC# 2000" |
| 697 | elif args.tc2001: |
| 698 | tc_num = "TC# 2001" |
| 699 | |
| 700 | elif args.tc610: |
| 701 | tc_num = "TC# 610" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 702 | |
| 703 | else: |
| 704 | print("No TC was defined") |
| 705 | print("use --help for usage info") |
| 706 | sys.exit() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 707 | |
| 708 | print(tc_num) |
| 709 | |
| 710 | app.run(port=HOST_PORT, host=HOST_IP) |