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 |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 6 | import time |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 7 | import sys |
| 8 | import json |
| 9 | from flask import Flask |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 10 | |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 11 | app = Flask(__name__) |
| 12 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 13 | #Server info |
| 14 | HOST_IP = "0.0.0.0" |
| 15 | HOST_PORT = 2222 |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 16 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 17 | SFTP_PORT = 1022 |
| 18 | FTPS_PORT = 21 |
| 19 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 20 | #Test function to check server running |
| 21 | @app.route('/', |
| 22 | methods=['GET']) |
| 23 | def index(): |
| 24 | return 'Hello world' |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 25 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 26 | #Returns number of polls |
| 27 | @app.route('/ctr_requests', |
| 28 | methods=['GET']) |
| 29 | def counter_requests(): |
| 30 | global ctr_requests |
| 31 | return str(ctr_requests) |
| 32 | |
| 33 | #Returns number of replies |
| 34 | @app.route('/ctr_responses', |
| 35 | methods=['GET']) |
| 36 | def counter_responses(): |
| 37 | global ctr_responses |
| 38 | return str(ctr_responses) |
| 39 | |
| 40 | #Returns number of unique files |
| 41 | @app.route('/ctr_unique_files', |
| 42 | methods=['GET']) |
| 43 | def counter_uniquefiles(): |
| 44 | global fileMap |
| 45 | return str(len(fileMap)) |
| 46 | |
| 47 | #Returns tc info |
| 48 | @app.route('/tc_info', |
| 49 | methods=['GET']) |
| 50 | def testcase_info(): |
| 51 | global tc_num |
| 52 | return tc_num |
| 53 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 54 | #Returns number of events |
| 55 | @app.route('/ctr_events', |
| 56 | methods=['GET']) |
| 57 | def counter_events(): |
| 58 | global ctr_events |
| 59 | return str(ctr_events) |
| 60 | |
| 61 | #Returns number of events |
| 62 | @app.route('/execution_time', |
| 63 | methods=['GET']) |
| 64 | def exe_time(): |
| 65 | global startTime |
| 66 | |
| 67 | stopTime = time.time() |
| 68 | minutes, seconds = divmod(stopTime-startTime, 60) |
| 69 | return "{:0>2}:{:0>2}".format(int(minutes),int(seconds)) |
| 70 | |
| 71 | #Returns number of unique PNFs |
| 72 | @app.route('/ctr_unique_PNFs', |
| 73 | methods=['GET']) |
| 74 | def counter_uniquePNFs(): |
| 75 | global pnfMap |
| 76 | return str(len(pnfMap)) |
| 77 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 78 | #Messages polling function |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 79 | @app.route( |
| 80 | "/events/unauthenticated.VES_NOTIFICATION_OUTPUT/OpenDcae-c12/C12", |
| 81 | methods=['GET']) |
| 82 | def MR_reply(): |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 83 | global ctr_requests |
| 84 | global args |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 85 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 86 | ctr_requests = ctr_requests + 1 |
| 87 | print("MR: poll request#: " + str(ctr_requests)) |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 88 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 89 | if args.tc100: |
| 90 | return tc100("sftp") |
| 91 | elif args.tc101: |
| 92 | return tc101("sftp") |
| 93 | elif args.tc102: |
| 94 | return tc102("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 95 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 96 | elif args.tc110: |
| 97 | return tc110("sftp") |
| 98 | elif args.tc111: |
| 99 | return tc111("sftp") |
| 100 | elif args.tc112: |
| 101 | return tc112("sftp") |
| 102 | elif args.tc113: |
| 103 | return tc113("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 104 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 105 | elif args.tc120: |
| 106 | return tc120("sftp") |
| 107 | elif args.tc121: |
| 108 | return tc121("sftp") |
| 109 | elif args.tc122: |
| 110 | return tc122("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 111 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 112 | elif args.tc1000: |
| 113 | return tc1000("sftp") |
| 114 | elif args.tc1001: |
| 115 | return tc1001("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 116 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 117 | elif args.tc510: |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 118 | return tc510("sftp") |
| 119 | elif args.tc511: |
| 120 | return tc511("sftp") |
| 121 | |
| 122 | elif args.tc710: |
| 123 | return tc710("sftp") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 124 | |
| 125 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 126 | elif args.tc200: |
| 127 | return tc200("ftps") |
| 128 | elif args.tc201: |
| 129 | return tc201("ftps") |
| 130 | elif args.tc202: |
| 131 | return tc202("ftps") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 132 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 133 | elif args.tc210: |
| 134 | return tc210("ftps") |
| 135 | elif args.tc211: |
| 136 | return tc211("ftps") |
| 137 | elif args.tc212: |
| 138 | return tc212("ftps") |
| 139 | elif args.tc213: |
| 140 | return tc213("ftps") |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 141 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 142 | elif args.tc220: |
| 143 | return tc220("ftps") |
| 144 | elif args.tc221: |
| 145 | return tc221("ftps") |
| 146 | elif args.tc222: |
| 147 | return tc222("ftps") |
| 148 | |
| 149 | elif args.tc2000: |
| 150 | return tc2000("ftps") |
| 151 | elif args.tc2001: |
| 152 | return tc2001("ftps") |
| 153 | |
| 154 | elif args.tc610: |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 155 | return tc510("ftps") |
| 156 | elif args.tc611: |
| 157 | return tc511("ftps") |
| 158 | |
| 159 | elif args.tc810: |
| 160 | return tc710("ftps") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 161 | |
| 162 | |
| 163 | #### Test case functions |
| 164 | |
| 165 | |
| 166 | def tc100(ftptype): |
| 167 | global ctr_responses |
| 168 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 169 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 170 | |
| 171 | ctr_responses = ctr_responses + 1 |
| 172 | |
| 173 | if (ctr_responses > 1): |
| 174 | return buildOkResponse("[]") |
| 175 | |
| 176 | seqNr = (ctr_responses-1) |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 177 | nodeName = createNodeName(0) |
| 178 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 179 | msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 180 | fileMap[seqNr] = seqNr |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 181 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 182 | return buildOkResponse("["+msg+"]") |
| 183 | |
| 184 | def tc101(ftptype): |
| 185 | global ctr_responses |
| 186 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 187 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 188 | |
| 189 | ctr_responses = ctr_responses + 1 |
| 190 | |
| 191 | if (ctr_responses > 1): |
| 192 | return buildOkResponse("[]") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 193 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 194 | seqNr = (ctr_responses-1) |
| 195 | nodeName = createNodeName(0) |
| 196 | fileName = createFileName(nodeName, seqNr, "5MB") |
| 197 | msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd() |
| 198 | fileMap[seqNr] = seqNr |
| 199 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 200 | return buildOkResponse("["+msg+"]") |
| 201 | |
| 202 | def tc102(ftptype): |
| 203 | global ctr_responses |
| 204 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 205 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 206 | |
| 207 | ctr_responses = ctr_responses + 1 |
| 208 | |
| 209 | if (ctr_responses > 1): |
| 210 | return buildOkResponse("[]") |
| 211 | |
| 212 | seqNr = (ctr_responses-1) |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 213 | nodeName = createNodeName(0) |
| 214 | fileName = createFileName(nodeName, seqNr, "50MB") |
| 215 | msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 216 | fileMap[seqNr] = seqNr |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 217 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 218 | return buildOkResponse("["+msg+"]") |
| 219 | |
| 220 | def tc110(ftptype): |
| 221 | global ctr_responses |
| 222 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 223 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 224 | |
| 225 | ctr_responses = ctr_responses + 1 |
| 226 | |
| 227 | if (ctr_responses > 100): |
| 228 | return buildOkResponse("[]") |
| 229 | |
| 230 | seqNr = (ctr_responses-1) |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 231 | nodeName = createNodeName(0) |
| 232 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 233 | msg = getEventHead(nodeName) + getEventName(fileName,ftptype,"onap","pano") + getEventEnd() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 234 | fileMap[seqNr] = seqNr |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 235 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 236 | return buildOkResponse("["+msg+"]") |
| 237 | |
| 238 | def tc111(ftptype): |
| 239 | global ctr_responses |
| 240 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 241 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 242 | |
| 243 | ctr_responses = ctr_responses + 1 |
| 244 | |
| 245 | if (ctr_responses > 100): |
| 246 | return buildOkResponse("[]") |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 247 | |
| 248 | nodeName = createNodeName(0) |
| 249 | msg = getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 250 | |
| 251 | for i in range(100): |
| 252 | seqNr = i+(ctr_responses-1) |
| 253 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 254 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 255 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 256 | fileMap[seqNr] = seqNr |
| 257 | |
| 258 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 259 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 260 | |
| 261 | return buildOkResponse("["+msg+"]") |
| 262 | |
| 263 | def tc112(ftptype): |
| 264 | global ctr_responses |
| 265 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 266 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 267 | |
| 268 | ctr_responses = ctr_responses + 1 |
| 269 | |
| 270 | if (ctr_responses > 100): |
| 271 | return buildOkResponse("[]") |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 272 | |
| 273 | nodeName = createNodeName(0) |
| 274 | msg = getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 275 | |
| 276 | for i in range(100): |
| 277 | seqNr = i+(ctr_responses-1) |
| 278 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 279 | fileName = createFileName(nodeName, seqNr, "5MB") |
| 280 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 281 | fileMap[seqNr] = seqNr |
| 282 | |
| 283 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 284 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 285 | |
| 286 | return buildOkResponse("["+msg+"]") |
| 287 | |
| 288 | def tc113(ftptype): |
| 289 | global ctr_responses |
| 290 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 291 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 292 | |
| 293 | ctr_responses = ctr_responses + 1 |
| 294 | |
| 295 | if (ctr_responses > 1): |
| 296 | return buildOkResponse("[]") |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 297 | |
| 298 | nodeName = createNodeName(0) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 299 | msg = "" |
| 300 | |
| 301 | for evts in range(100): # build 100 evts |
| 302 | if (evts > 0): |
| 303 | msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 304 | msg = msg + getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 305 | for i in range(100): # build 100 files |
| 306 | seqNr = i+evts+100*(ctr_responses-1) |
| 307 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 308 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 309 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 310 | fileMap[seqNr] = seqNr |
| 311 | |
| 312 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 313 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 314 | |
| 315 | return buildOkResponse("["+msg+"]") |
| 316 | |
| 317 | |
| 318 | def tc120(ftptype): |
| 319 | global ctr_responses |
| 320 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 321 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 322 | |
| 323 | ctr_responses = ctr_responses + 1 |
| 324 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 325 | nodeName = createNodeName(0) |
| 326 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 327 | if (ctr_responses > 100): |
| 328 | return buildOkResponse("[]") |
| 329 | |
| 330 | if (ctr_responses % 10 == 2): |
| 331 | return # Return nothing |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 332 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 333 | if (ctr_responses % 10 == 3): |
| 334 | return buildOkResponse("") # Return empty message |
| 335 | |
| 336 | if (ctr_responses % 10 == 4): |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 337 | return buildOkResponse(getEventHead(nodeName)) # Return part of a json event |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 338 | |
| 339 | if (ctr_responses % 10 == 5): |
| 340 | return buildEmptyResponse(404) # Return empty message with status code |
| 341 | |
| 342 | if (ctr_responses % 10 == 6): |
| 343 | sleep(60) |
| 344 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 345 | |
| 346 | msg = getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 347 | |
| 348 | for i in range(100): |
| 349 | seqNr = i+(ctr_responses-1) |
| 350 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 351 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 352 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 353 | fileMap[seqNr] = seqNr |
| 354 | |
| 355 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 356 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 357 | |
| 358 | return buildOkResponse("["+msg+"]") |
| 359 | |
| 360 | def tc121(ftptype): |
| 361 | global ctr_responses |
| 362 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 363 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 364 | |
| 365 | ctr_responses = ctr_responses + 1 |
| 366 | |
| 367 | if (ctr_responses > 100): |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 368 | return buildOkResponse("[]") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 369 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 370 | nodeName = createNodeName(0) |
| 371 | msg = getEventHead(nodeName) |
| 372 | |
| 373 | fileName = "" |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 374 | for i in range(100): |
| 375 | seqNr = i+(ctr_responses-1) |
| 376 | if (seqNr%10 == 0): # Every 10th file is "missing" |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 377 | fileName = createMissingFileName(nodeName, seqNr, "1MB") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 378 | else: |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 379 | fileName = createFileName(nodeName, seqNr, "1MB") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 380 | fileMap[seqNr] = seqNr |
| 381 | |
| 382 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 383 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 384 | |
| 385 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 386 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 387 | |
| 388 | return buildOkResponse("["+msg+"]") |
| 389 | |
| 390 | def tc122(ftptype): |
| 391 | global ctr_responses |
| 392 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 393 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 394 | |
| 395 | ctr_responses = ctr_responses + 1 |
| 396 | |
| 397 | if (ctr_responses > 100): |
| 398 | return buildOkResponse("[]") |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 399 | |
| 400 | nodeName = createNodeName(0) |
| 401 | msg = getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 402 | |
| 403 | for i in range(100): |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 404 | fileName = createFileName(nodeName, 0, "1MB") # All files identical names |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 405 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 406 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 407 | |
| 408 | fileMap[0] = 0 |
| 409 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 410 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 411 | |
| 412 | return buildOkResponse("["+msg+"]") |
| 413 | |
| 414 | |
| 415 | def tc1000(ftptype): |
| 416 | global ctr_responses |
| 417 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 418 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 419 | |
| 420 | ctr_responses = ctr_responses + 1 |
| 421 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 422 | nodeName = createNodeName(0) |
| 423 | msg = getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 424 | |
| 425 | for i in range(100): |
| 426 | seqNr = i+(ctr_responses-1) |
| 427 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 428 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 429 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 430 | fileMap[seqNr] = seqNr |
| 431 | |
| 432 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 433 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 434 | |
| 435 | return buildOkResponse("["+msg+"]") |
| 436 | |
| 437 | def tc1001(ftptype): |
| 438 | global ctr_responses |
| 439 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 440 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 441 | |
| 442 | ctr_responses = ctr_responses + 1 |
| 443 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 444 | nodeName = createNodeName(0) |
| 445 | msg = getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 446 | |
| 447 | for i in range(100): |
| 448 | seqNr = i+(ctr_responses-1) |
| 449 | if i != 0: msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 450 | fileName = createFileName(nodeName, seqNr, "5MB") |
| 451 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 452 | fileMap[seqNr] = seqNr |
| 453 | |
| 454 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 455 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 456 | |
| 457 | return buildOkResponse("["+msg+"]") |
| 458 | |
| 459 | def tc510(ftptype): |
| 460 | global ctr_responses |
| 461 | global ctr_unique_files |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 462 | global ctr_events |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 463 | |
| 464 | ctr_responses = ctr_responses + 1 |
| 465 | |
| 466 | if (ctr_responses > 5): |
| 467 | return buildOkResponse("[]") |
| 468 | |
| 469 | msg = "" |
| 470 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 471 | for pnfs in range(700): # build events for 700 MEs |
| 472 | if (pnfs > 0): |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 473 | msg = msg + "," |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 474 | nodeName = createNodeName(pnfs) |
| 475 | msg = msg + getEventHead(nodeName) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 476 | seqNr = (ctr_responses-1) |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 477 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 478 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
| 479 | seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 480 | fileMap[seqNr] = seqNr |
| 481 | msg = msg + getEventEnd() |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 482 | ctr_events = ctr_events+1 |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 483 | |
| 484 | return buildOkResponse("["+msg+"]") |
| 485 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 486 | def tc511(ftptype): |
| 487 | global ctr_responses |
| 488 | global ctr_unique_files |
| 489 | global ctr_events |
| 490 | |
| 491 | ctr_responses = ctr_responses + 1 |
| 492 | |
| 493 | if (ctr_responses > 5): |
| 494 | return buildOkResponse("[]") |
| 495 | |
| 496 | msg = "" |
| 497 | |
| 498 | for pnfs in range(700): # build events for 700 MEs |
| 499 | if (pnfs > 0): |
| 500 | msg = msg + "," |
| 501 | nodeName = createNodeName(pnfs) |
| 502 | msg = msg + getEventHead(nodeName) |
| 503 | seqNr = (ctr_responses-1) |
| 504 | fileName = createFileName(nodeName, seqNr, "1KB") |
| 505 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
| 506 | seqNr = seqNr + pnfs*1000000 #Create unique id for this node and file |
| 507 | fileMap[seqNr] = seqNr |
| 508 | msg = msg + getEventEnd() |
| 509 | ctr_events = ctr_events+1 |
| 510 | |
| 511 | return buildOkResponse("["+msg+"]") |
| 512 | |
| 513 | def tc710(ftptype): |
| 514 | global ctr_responses |
| 515 | global ctr_unique_files |
| 516 | global ctr_events |
| 517 | |
| 518 | ctr_responses = ctr_responses + 1 |
| 519 | |
| 520 | if (ctr_responses > 100): |
| 521 | return buildOkResponse("[]") |
| 522 | |
| 523 | msg = "" |
| 524 | |
| 525 | batch = (ctr_responses-1)%20; |
| 526 | |
| 527 | for pnfs in range(35): # build events for 35 PNFs at a time. 20 batches -> 700 |
| 528 | if (pnfs > 0): |
| 529 | msg = msg + "," |
| 530 | nodeName = createNodeName(pnfs + batch*35) |
| 531 | msg = msg + getEventHead(nodeName) |
| 532 | |
| 533 | for i in range(100): # 100 files per event |
| 534 | seqNr = i + int((ctr_responses-1)/20); |
| 535 | if i != 0: msg = msg + "," |
| 536 | fileName = createFileName(nodeName, seqNr, "1MB") |
| 537 | msg = msg + getEventName(fileName,ftptype,"onap","pano") |
| 538 | seqNr = seqNr + (pnfs+batch*35)*1000000 #Create unique id for this node and file |
| 539 | fileMap[seqNr] = seqNr |
| 540 | |
| 541 | msg = msg + getEventEnd() |
| 542 | ctr_events = ctr_events+1 |
| 543 | |
| 544 | return buildOkResponse("["+msg+"]") |
| 545 | |
| 546 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 547 | #Mapping FTPS TCs |
| 548 | def tc200(ftptype): |
| 549 | return tc100(ftptype) |
| 550 | def tc201(ftptype): |
| 551 | return tc101(ftptype) |
| 552 | def tc202(ftptype): |
| 553 | return tc102(ftptype) |
| 554 | |
| 555 | def tc210(ftptype): |
| 556 | return tc110(ftptype) |
| 557 | def tc211(ftptype): |
| 558 | return tc111(ftptype) |
| 559 | def tc212(ftptype): |
| 560 | return tc112(ftptype) |
| 561 | def tc213(ftptype): |
| 562 | return tc113(ftptype) |
| 563 | |
| 564 | def tc220(ftptype): |
| 565 | return tc120(ftptype) |
| 566 | def tc221(ftptype): |
| 567 | return tc121(ftptype) |
| 568 | def tc222(ftptype): |
| 569 | return tc122(ftptype) |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 570 | |
| 571 | def tc610(ftptype): |
| 572 | return tc510(ftptype) |
| 573 | def tc611(ftptype): |
| 574 | return tc511(ftptype) |
| 575 | |
| 576 | def tc810(ftptype): |
| 577 | return tc710(ftptype) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 578 | |
| 579 | def tc2000(ftptype): |
| 580 | return tc1000(ftptype) |
| 581 | def tc2001(ftptype): |
| 582 | return tc1001(ftptype) |
| 583 | |
| 584 | #### Functions to build json messages and respones #### |
| 585 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 586 | def createNodeName(index): |
| 587 | return "PNF"+str(index); |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 588 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 589 | def createFileName(nodeName, index, size): |
| 590 | return "A20000626.2315+0200-2330+0200_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz"; |
| 591 | |
| 592 | def createMissingFileName(nodeName, index, size): |
| 593 | return "AMissingFile_" + nodeName + "-" + str(index) + "-" +size + ".tar.gz"; |
| 594 | |
| 595 | |
| 596 | # Function to build fixed beginning of an event |
| 597 | |
| 598 | def getEventHead(nodename): |
| 599 | global pnfMap |
| 600 | pnfMap.add(nodename) |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 601 | headStr = """ |
| 602 | { |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 603 | "event": { |
| 604 | "commonEventHeader": { |
| 605 | "startEpochMicrosec": 8745745764578, |
| 606 | "eventId": "FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1", |
| 607 | "timeZoneOffset": "UTC+05.30", |
| 608 | "internalHeaderFields": { |
| 609 | "collectorTimeStamp": "Tue, 09 18 2018 10:56:52 UTC" |
| 610 | }, |
| 611 | "priority": "Normal", |
| 612 | "version": "4.0.1", |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 613 | "reportingEntityName": \"""" + nodename + """", |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 614 | "sequence": 0, |
| 615 | "domain": "notification", |
| 616 | "lastEpochMicrosec": 8745745764578, |
| 617 | "eventName": "Noti_RnNode-Ericsson_FileReady", |
| 618 | "vesEventListenerVersion": "7.0.1", |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 619 | "sourceName": \"""" + nodename + """" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 620 | }, |
| 621 | "notificationFields": { |
| 622 | "notificationFieldsVersion": "2.0", |
| 623 | "changeType": "FileReady", |
| 624 | "changeIdentifier": "PM_MEAS_FILES", |
| 625 | "arrayOfNamedHashMap": [ |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 626 | """ |
| 627 | return headStr |
| 628 | |
| 629 | # Function to build the variable part of an event |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 630 | def getEventName(fn,type,user,passwd): |
| 631 | port = SFTP_PORT |
| 632 | ip = sftp_ip |
| 633 | if (type == "ftps"): |
| 634 | port = FTPS_PORT |
| 635 | ip = ftps_ip |
| 636 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 637 | nameStr = """{ |
| 638 | "name": \"""" + fn + """", |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 639 | "hashMap": { |
| 640 | "fileFormatType": "org.3GPP.32.435#measCollec", |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 641 | "location": \"""" + type + """://""" + user + """:""" + passwd + """@""" + ip + """:""" + str(port) + """/""" + fn + """", |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 642 | "fileFormatVersion": "V10", |
| 643 | "compression": "gzip" |
| 644 | } |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 645 | } """ |
| 646 | return nameStr |
| 647 | |
| 648 | # Function to build fixed end of an event |
| 649 | def getEventEnd(): |
| 650 | endStr = """ |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 651 | ] |
| 652 | } |
| 653 | } |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 654 | } |
| 655 | """ |
| 656 | return endStr |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 657 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 658 | # Function to build an OK reponse from a message string |
| 659 | def buildOkResponse(msg): |
| 660 | response = app.response_class( |
| 661 | response=str.encode(msg), |
| 662 | status=200, |
| 663 | mimetype='application/json') |
| 664 | return response |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 665 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 666 | # Function to build an empty message with status |
| 667 | def buildEmptyResponse(status_code): |
| 668 | response = app.response_class( |
| 669 | response=str.encode(""), |
| 670 | status=status_code, |
| 671 | mimetype='application/json') |
| 672 | return response |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 673 | |
| 674 | |
| 675 | if __name__ == "__main__": |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 676 | |
| 677 | # IP addresses to use for ftp servers, using localhost if not env var is set |
| 678 | sftp_ip = os.environ.get('SFTP_SIM_IP', 'localhost') |
| 679 | ftps_ip = os.environ.get('FTPS_SIM_IP', 'localhost') |
| 680 | |
| 681 | |
| 682 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 683 | #Counters |
| 684 | ctr_responses = 0 |
| 685 | ctr_requests = 0 |
| 686 | ctr_unique_files = 0 |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 687 | ctr_events = 0 |
| 688 | startTime = time.time() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 689 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 690 | #Keeps all responded file names |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 691 | fileMap = {} |
| 692 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 693 | #Keeps all responded PNF names |
| 694 | pnfMap = set() |
| 695 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 696 | tc_num = "Not set" |
| 697 | tc_help = "Not set" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 698 | |
| 699 | parser = argparse.ArgumentParser() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 700 | |
| 701 | #SFTP TCs with single ME |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 702 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 703 | '--tc100', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 704 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 705 | help='TC100 - One ME, SFTP, 1 1MB file, 1 event') |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 706 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 707 | '--tc101', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 708 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 709 | help='TC101 - One ME, SFTP, 1 5MB file, 1 event') |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 710 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 711 | '--tc102', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 712 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 713 | help='TC102 - One ME, SFTP, 1 50MB file, 1 event') |
| 714 | |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 715 | parser.add_argument( |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 716 | '--tc110', |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 717 | action='store_true', |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 718 | help='TC110 - One ME, SFTP, 1MB files, 1 file per event, 100 events, 1 event per poll.') |
| 719 | parser.add_argument( |
| 720 | '--tc111', |
| 721 | action='store_true', |
| 722 | help='TC111 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll.') |
| 723 | parser.add_argument( |
| 724 | '--tc112', |
| 725 | action='store_true', |
| 726 | help='TC112 - One ME, SFTP, 5MB files, 100 files per event, 100 events, 1 event per poll.') |
| 727 | parser.add_argument( |
| 728 | '--tc113', |
| 729 | action='store_true', |
| 730 | help='TC113 - One ME, SFTP, 1MB files, 100 files per event, 100 events. All events in one poll.') |
| 731 | |
| 732 | parser.add_argument( |
| 733 | '--tc120', |
| 734 | action='store_true', |
| 735 | 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') |
| 736 | parser.add_argument( |
| 737 | '--tc121', |
| 738 | action='store_true', |
| 739 | help='TC121 - One ME, SFTP, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files') |
| 740 | parser.add_argument( |
| 741 | '--tc122', |
| 742 | action='store_true', |
| 743 | help='TC122 - One ME, SFTP, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ') |
| 744 | |
| 745 | parser.add_argument( |
| 746 | '--tc1000', |
| 747 | action='store_true', |
| 748 | help='TC1000 - One ME, SFTP, 1MB files, 100 files per event, endless number of events, 1 event per poll') |
| 749 | parser.add_argument( |
| 750 | '--tc1001', |
| 751 | action='store_true', |
| 752 | help='TC1001 - One ME, SFTP, 5MB files, 100 files per event, endless number of events, 1 event per poll') |
| 753 | |
| 754 | # SFTP TCs with multiple MEs |
| 755 | parser.add_argument( |
| 756 | '--tc510', |
| 757 | action='store_true', |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 758 | help='TC510 - 700 MEs, SFTP, 1MB files, 1 file per event, 3500 events, 700 event per poll.') |
| 759 | |
| 760 | parser.add_argument( |
| 761 | '--tc511', |
| 762 | action='store_true', |
| 763 | help='TC511 - 700 MEs, SFTP, 1KB files, 1 file per event, 3500 events, 700 event per poll.') |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 764 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 765 | parser.add_argument( |
| 766 | '--tc710', |
| 767 | action='store_true', |
| 768 | help='TC710 - 700 MEs, SFTP, 1MB files, 100 files per event, 3500 events, 35 event per poll.') |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 769 | |
| 770 | # FTPS TCs with single ME |
| 771 | parser.add_argument( |
| 772 | '--tc200', |
| 773 | action='store_true', |
| 774 | help='TC200 - One ME, FTPS, 1 1MB file, 1 event') |
| 775 | parser.add_argument( |
| 776 | '--tc201', |
| 777 | action='store_true', |
| 778 | help='TC201 - One ME, FTPS, 1 5MB file, 1 event') |
| 779 | parser.add_argument( |
| 780 | '--tc202', |
| 781 | action='store_true', |
| 782 | help='TC202 - One ME, FTPS, 1 50MB file, 1 event') |
| 783 | |
| 784 | parser.add_argument( |
| 785 | '--tc210', |
| 786 | action='store_true', |
| 787 | help='TC210 - One ME, FTPS, 1MB files, 1 file per event, 100 events, 1 event per poll.') |
| 788 | parser.add_argument( |
| 789 | '--tc211', |
| 790 | action='store_true', |
| 791 | help='TC211 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll.') |
| 792 | parser.add_argument( |
| 793 | '--tc212', |
| 794 | action='store_true', |
| 795 | help='TC212 - One ME, FTPS, 5MB files, 100 files per event, 100 events, 1 event per poll.') |
| 796 | parser.add_argument( |
| 797 | '--tc213', |
| 798 | action='store_true', |
| 799 | help='TC213 - One ME, FTPS, 1MB files, 100 files per event, 100 events. All events in one poll.') |
| 800 | |
| 801 | parser.add_argument( |
| 802 | '--tc220', |
| 803 | action='store_true', |
| 804 | 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') |
| 805 | parser.add_argument( |
| 806 | '--tc221', |
| 807 | action='store_true', |
| 808 | help='TC221 - One ME, FTPS, 1MB files, 100 files per event, 100 events, 1 event per poll. 10% missing files') |
| 809 | parser.add_argument( |
| 810 | '--tc222', |
| 811 | action='store_true', |
| 812 | help='TC222 - One ME, FTPS, 1MB files, 100 files per event, 100 events. 1 event per poll. All files with identical name. ') |
| 813 | |
| 814 | parser.add_argument( |
| 815 | '--tc2000', |
| 816 | action='store_true', |
| 817 | help='TC2000 - One ME, FTPS, 1MB files, 100 files per event, endless number of events, 1 event per poll') |
| 818 | parser.add_argument( |
| 819 | '--tc2001', |
| 820 | action='store_true', |
| 821 | help='TC2001 - One ME, FTPS, 5MB files, 100 files per event, endless number of events, 1 event per poll') |
| 822 | |
| 823 | parser.add_argument( |
| 824 | '--tc610', |
| 825 | action='store_true', |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 826 | help='TC610 - 700 MEs, FTPS, 1MB files, 1 file per event, 3500 events, 700 event per poll.') |
| 827 | |
| 828 | parser.add_argument( |
| 829 | '--tc611', |
| 830 | action='store_true', |
| 831 | help='TC611 - 700 MEs, FTPS, 1KB files, 1 file per event, 3500 events, 700 event per poll.') |
| 832 | |
| 833 | parser.add_argument( |
| 834 | '--tc810', |
| 835 | action='store_true', |
| 836 | help='TC810 - 700 MEs, FTPS, 1MB files, 100 files per event, 3500 events, 35 event per poll.') |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 837 | |
| 838 | args = parser.parse_args() |
| 839 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 840 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 841 | |
| 842 | if args.tc100: |
| 843 | tc_num = "TC# 100" |
| 844 | elif args.tc101: |
| 845 | tc_num = "TC# 101" |
| 846 | elif args.tc102: |
| 847 | tc_num = "TC# 102" |
| 848 | |
| 849 | elif args.tc110: |
| 850 | tc_num = "TC# 110" |
| 851 | elif args.tc111: |
| 852 | tc_num = "TC# 111" |
| 853 | elif args.tc112: |
| 854 | tc_num = "TC# 112" |
| 855 | elif args.tc113: |
| 856 | tc_num = "TC# 113" |
| 857 | |
| 858 | elif args.tc120: |
| 859 | tc_num = "TC# 120" |
| 860 | elif args.tc121: |
| 861 | tc_num = "TC# 121" |
| 862 | elif args.tc122: |
| 863 | tc_num = "TC# 122" |
| 864 | |
| 865 | elif args.tc1000: |
| 866 | tc_num = "TC# 1000" |
| 867 | elif args.tc1001: |
| 868 | tc_num = "TC# 1001" |
| 869 | |
| 870 | elif args.tc510: |
| 871 | tc_num = "TC# 510" |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 872 | elif args.tc511: |
| 873 | tc_num = "TC# 511" |
| 874 | |
| 875 | elif args.tc710: |
| 876 | tc_num = "TC# 710" |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 877 | |
| 878 | elif args.tc200: |
| 879 | tc_num = "TC# 200" |
| 880 | elif args.tc201: |
| 881 | tc_num = "TC# 201" |
| 882 | elif args.tc202: |
| 883 | tc_num = "TC# 202" |
| 884 | |
| 885 | elif args.tc210: |
| 886 | tc_num = "TC# 210" |
| 887 | elif args.tc211: |
| 888 | tc_num = "TC# 211" |
| 889 | elif args.tc212: |
| 890 | tc_num = "TC# 212" |
| 891 | elif args.tc213: |
| 892 | tc_num = "TC# 213" |
| 893 | |
| 894 | elif args.tc220: |
| 895 | tc_num = "TC# 220" |
| 896 | elif args.tc221: |
| 897 | tc_num = "TC# 221" |
| 898 | elif args.tc222: |
| 899 | tc_num = "TC# 222" |
| 900 | |
| 901 | elif args.tc2000: |
| 902 | tc_num = "TC# 2000" |
| 903 | elif args.tc2001: |
| 904 | tc_num = "TC# 2001" |
| 905 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 906 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 907 | elif args.tc610: |
| 908 | tc_num = "TC# 610" |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 909 | elif args.tc611: |
| 910 | tc_num = "TC# 611" |
| 911 | |
| 912 | elif args.tc810: |
| 913 | tc_num = "TC# 810" |
TamasBakai | 9b78033 | 2019-02-15 08:38:16 +0000 | [diff] [blame] | 914 | |
| 915 | else: |
| 916 | print("No TC was defined") |
| 917 | print("use --help for usage info") |
| 918 | sys.exit() |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 919 | |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 920 | print("TC num: " + tc_num) |
| 921 | |
| 922 | |
| 923 | print("Using " + sftp_ip + " for sftp server address in file urls.") |
| 924 | print("Using " + ftps_ip + " for ftps server address in file urls.") |
| 925 | |
BjornMagnussonXA | f8b34f0 | 2019-03-22 09:48:38 +0000 | [diff] [blame] | 926 | app.run(port=HOST_PORT, host=HOST_IP) |
BjornMagnussonXA | f4e1836 | 2019-04-10 13:04:08 +0000 | [diff] [blame^] | 927 | |