Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright 2020-present Open Networking Foundation |
| 4 | # |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 5 | # SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0 |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 6 | |
| 7 | import unittest |
| 8 | import edge_monitoring_server as ems |
| 9 | import datetime |
| 10 | import pytz |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 11 | import json |
| 12 | import time |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 13 | from copy import deepcopy |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 14 | |
| 15 | |
| 16 | test_edge = { |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 17 | 'name': 'ace-menlo-rasp-pi', |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 18 | 'status': { |
| 19 | 'control_plane': 'connected', |
| 20 | 'user_plane': 'connected' |
| 21 | }, |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 22 | 'dongle_stats': { |
| 23 | 'SuccessfulFetch': True, |
| 24 | 'IMSI': '315021000000000', |
| 25 | 'CellGlobalID': '315010001F800', |
Jeremy Ronquillo | 1eaff6a | 2021-11-16 13:46:46 -0800 | [diff] [blame] | 26 | 'PhyCellID': '101', |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 27 | 'PLMNStatus': 'Success' |
| 28 | }, |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 29 | 'speedtest': { |
| 30 | 'ping': { |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 31 | 'dry_run': { |
| 32 | 'transmitted': 3, |
| 33 | 'received': 2, |
| 34 | 'median': 5.0, |
| 35 | 'min': 1.0, |
| 36 | 'avg': 5.0, |
| 37 | 'max': 9.0, |
| 38 | 'stddev': 1.0 |
| 39 | }, |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 40 | 'dns': { |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 41 | 'transmitted': 10, |
| 42 | 'received': 9, |
| 43 | 'median': 4.0, |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 44 | 'min': 2.0, |
| 45 | 'avg': 4.0, |
| 46 | 'max': 6.0, |
| 47 | 'stddev': 1.0 |
Jeremy Ronquillo | 6e352b7 | 2021-06-08 10:33:25 -0700 | [diff] [blame] | 48 | }, |
| 49 | 'iperf_server': { |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 50 | 'transmitted': 10, |
| 51 | 'received': 10, |
| 52 | 'median': 3.0, |
Jeremy Ronquillo | 6e352b7 | 2021-06-08 10:33:25 -0700 | [diff] [blame] | 53 | 'min': 1.0, |
| 54 | 'avg': 3.0, |
| 55 | 'max': 5.0, |
| 56 | 'stddev': 1.0 |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 57 | }, |
| 58 | 'management_server': { |
| 59 | 'transmitted': 10, |
| 60 | 'received': 8, |
| 61 | 'median': 6.0, |
| 62 | 'min': 2.0, |
| 63 | 'avg': 6.0, |
| 64 | 'max': 10.0, |
| 65 | 'stddev': 1.0 |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 66 | } |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 67 | }, |
| 68 | 'iperf': { |
| 69 | 'cluster': { |
| 70 | 'downlink': 100.0, |
| 71 | 'uplink': 10.0 |
| 72 | } |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 73 | } |
| 74 | }, |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 75 | 'signal_quality': { |
| 76 | 'rsrq': 30, |
| 77 | 'rsrp': 80 |
| 78 | }, |
| 79 | 'last_update': time.time() |
| 80 | } |
| 81 | |
| 82 | test_edge_status_only = { |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 83 | 'name': 'ace-menlo-rasp-pi', |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 84 | 'status': { |
| 85 | 'control_plane': 'connected', |
| 86 | 'user_plane': 'connected' |
| 87 | }, |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 88 | 'last_update': time.time() |
| 89 | } |
| 90 | |
| 91 | test_edge_no_speedtest = { |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 92 | 'name': 'ace-menlo-rasp-pi', |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 93 | 'status': { |
| 94 | 'control_plane': 'connected', |
| 95 | 'user_plane': 'connected' |
| 96 | }, |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 97 | 'signal_quality': { |
| 98 | 'rsrq': 30, |
| 99 | 'rsrp': 80 |
| 100 | }, |
| 101 | 'last_update': time.time() |
| 102 | } |
| 103 | |
| 104 | test_edge_no_signal_quality = { |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 105 | 'name': 'ace-menlo-rasp-pi', |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 106 | 'status': { |
| 107 | 'control_plane': 'connected', |
| 108 | 'user_plane': 'connected' |
| 109 | }, |
| 110 | 'speedtest': { |
| 111 | 'ping': { |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 112 | 'dry_run': { |
| 113 | 'transmitted': 3, |
| 114 | 'received': 2, |
| 115 | 'median': 5.0, |
| 116 | 'min': 1.0, |
| 117 | 'avg': 5.0, |
| 118 | 'max': 9.0, |
| 119 | 'stddev': 1.0 |
| 120 | }, |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 121 | 'dns': { |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 122 | 'transmitted': 10, |
| 123 | 'received': 9, |
| 124 | 'median': 4.0, |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 125 | 'min': 2.0, |
| 126 | 'avg': 4.0, |
| 127 | 'max': 6.0, |
| 128 | 'stddev': 1.0 |
Jeremy Ronquillo | 6e352b7 | 2021-06-08 10:33:25 -0700 | [diff] [blame] | 129 | }, |
| 130 | 'iperf_server': { |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 131 | 'transmitted': 10, |
| 132 | 'received': 10, |
| 133 | 'median': 3.0, |
Jeremy Ronquillo | 6e352b7 | 2021-06-08 10:33:25 -0700 | [diff] [blame] | 134 | 'min': 1.0, |
| 135 | 'avg': 3.0, |
| 136 | 'max': 5.0, |
| 137 | 'stddev': 1.0 |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 138 | }, |
| 139 | 'management_server': { |
| 140 | 'transmitted': 10, |
| 141 | 'received': 8, |
| 142 | 'median': 6.0, |
| 143 | 'min': 2.0, |
| 144 | 'avg': 6.0, |
| 145 | 'max': 10.0, |
| 146 | 'stddev': 1.0 |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 147 | } |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 148 | }, |
| 149 | 'iperf': { |
| 150 | 'cluster': { |
| 151 | 'downlink': 100.0, |
| 152 | 'uplink': 10.0 |
| 153 | } |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 154 | } |
| 155 | }, |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 156 | 'last_update': time.time() |
| 157 | } |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 158 | |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 159 | test_edge_no_iperf = { |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 160 | 'name': 'ace-menlo-rasp-pi', |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 161 | 'status': { |
| 162 | 'control_plane': 'connected', |
| 163 | 'user_plane': 'connected' |
| 164 | }, |
| 165 | 'speedtest': { |
| 166 | 'ping': { |
| 167 | 'dns': { |
| 168 | 'min': 2.0, |
| 169 | 'avg': 4.0, |
| 170 | 'max': 6.0, |
| 171 | 'stddev': 1.0 |
| 172 | } |
| 173 | } |
| 174 | }, |
| 175 | 'signal_quality': { |
| 176 | 'rsrq': 30, |
| 177 | 'rsrp': 80 |
| 178 | }, |
| 179 | 'last_update': time.time() |
| 180 | } |
| 181 | |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 182 | test_edge_pre_0_7_0 = { |
| 183 | 'name': 'ace-menlo-rasp-pi', |
| 184 | 'status': { |
| 185 | 'control_plane': 'connected', |
| 186 | 'user_plane': 'connected' |
| 187 | }, |
| 188 | 'speedtest': { |
| 189 | 'ping': { |
| 190 | 'dns': { |
| 191 | 'min': 2.0, |
| 192 | 'avg': 4.0, |
| 193 | 'max': 6.0, |
| 194 | 'stddev': 1.0 |
| 195 | }, |
| 196 | 'iperf_server': { |
| 197 | 'min': 1.0, |
| 198 | 'avg': 3.0, |
| 199 | 'max': 5.0, |
| 200 | 'stddev': 1.0 |
| 201 | } |
| 202 | }, |
| 203 | 'iperf': { |
| 204 | 'cluster': { |
| 205 | 'downlink': 100.0, |
| 206 | 'uplink': 10.0 |
| 207 | } |
| 208 | } |
| 209 | }, |
| 210 | 'signal_quality': { |
| 211 | 'rsrq': 30, |
| 212 | 'rsrp': 80 |
| 213 | }, |
| 214 | 'last_update': time.time() |
| 215 | } |
| 216 | |
| 217 | test_edge_dns_iperf = { |
| 218 | 'name': 'ace-menlo-rasp-pi', |
| 219 | 'status': { |
| 220 | 'control_plane': 'connected', |
| 221 | 'user_plane': 'connected' |
| 222 | }, |
| 223 | 'speedtest': { |
| 224 | 'ping': { |
| 225 | 'dns': { |
| 226 | 'transmitted': 10, |
| 227 | 'received': 9, |
| 228 | 'median': 4.0, |
| 229 | 'min': 2.0, |
| 230 | 'avg': 4.0, |
| 231 | 'max': 6.0, |
| 232 | 'stddev': 1.0 |
| 233 | }, |
| 234 | 'iperf_server': { |
| 235 | 'transmitted': 10, |
| 236 | 'received': 10, |
| 237 | 'median': 3.0, |
| 238 | 'min': 1.0, |
| 239 | 'avg': 3.0, |
| 240 | 'max': 5.0, |
| 241 | 'stddev': 1.0 |
| 242 | } |
| 243 | }, |
| 244 | 'iperf': { |
| 245 | 'cluster': { |
| 246 | 'downlink': 100.0, |
| 247 | 'uplink': 10.0 |
| 248 | } |
| 249 | } |
| 250 | }, |
| 251 | 'signal_quality': { |
| 252 | 'rsrq': 30, |
| 253 | 'rsrp': 80 |
| 254 | }, |
| 255 | 'last_update': time.time() |
| 256 | } |
| 257 | |
| 258 | test_edge_basic_ping_stats = { |
| 259 | 'name': 'ace-menlo-rasp-pi', |
| 260 | 'status': { |
| 261 | 'control_plane': 'connected', |
| 262 | 'user_plane': 'connected' |
| 263 | }, |
| 264 | 'speedtest': { |
| 265 | 'ping': { |
| 266 | 'dry_run': { |
| 267 | 'min': 1.0, |
| 268 | 'avg': 5.0, |
| 269 | 'max': 9.0, |
| 270 | 'stddev': 1.0 |
| 271 | }, |
| 272 | 'dns': { |
| 273 | 'min': 2.0, |
| 274 | 'avg': 4.0, |
| 275 | 'max': 6.0, |
| 276 | 'stddev': 1.0 |
| 277 | }, |
| 278 | 'iperf_server': { |
| 279 | 'min': 1.0, |
| 280 | 'avg': 3.0, |
| 281 | 'max': 5.0, |
| 282 | 'stddev': 1.0 |
| 283 | }, |
| 284 | 'management_server': { |
| 285 | 'min': 2.0, |
| 286 | 'avg': 6.0, |
| 287 | 'max': 10.0, |
| 288 | 'stddev': 1.0 |
| 289 | } |
| 290 | }, |
| 291 | 'iperf': { |
| 292 | 'cluster': { |
| 293 | 'downlink': 100.0, |
| 294 | 'uplink': 10.0 |
| 295 | } |
| 296 | } |
| 297 | }, |
| 298 | 'signal_quality': { |
| 299 | 'rsrq': 30, |
| 300 | 'rsrp': 80 |
| 301 | }, |
| 302 | 'last_update': time.time() |
| 303 | } |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 304 | |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 305 | test_edge_no_dongle_stats = { |
| 306 | 'name': 'ace-menlo-rasp-pi', |
| 307 | 'status': { |
| 308 | 'control_plane': 'connected', |
| 309 | 'user_plane': 'connected' |
| 310 | }, |
| 311 | 'speedtest': { |
| 312 | 'ping': { |
| 313 | 'dry_run': { |
| 314 | 'transmitted': 3, |
| 315 | 'received': 2, |
| 316 | 'median': 5.0, |
| 317 | 'min': 1.0, |
| 318 | 'avg': 5.0, |
| 319 | 'max': 9.0, |
| 320 | 'stddev': 1.0 |
| 321 | }, |
| 322 | 'dns': { |
| 323 | 'transmitted': 10, |
| 324 | 'received': 9, |
| 325 | 'median': 4.0, |
| 326 | 'min': 2.0, |
| 327 | 'avg': 4.0, |
| 328 | 'max': 6.0, |
| 329 | 'stddev': 1.0 |
| 330 | }, |
| 331 | 'iperf_server': { |
| 332 | 'transmitted': 10, |
| 333 | 'received': 10, |
| 334 | 'median': 3.0, |
| 335 | 'min': 1.0, |
| 336 | 'avg': 3.0, |
| 337 | 'max': 5.0, |
| 338 | 'stddev': 1.0 |
| 339 | }, |
| 340 | 'management_server': { |
| 341 | 'transmitted': 10, |
| 342 | 'received': 8, |
| 343 | 'median': 6.0, |
| 344 | 'min': 2.0, |
| 345 | 'avg': 6.0, |
| 346 | 'max': 10.0, |
| 347 | 'stddev': 1.0 |
| 348 | } |
| 349 | }, |
| 350 | 'iperf': { |
| 351 | 'cluster': { |
| 352 | 'downlink': 100.0, |
| 353 | 'uplink': 10.0 |
| 354 | } |
| 355 | } |
| 356 | }, |
| 357 | 'signal_quality': { |
| 358 | 'rsrq': 30, |
| 359 | 'rsrp': 80 |
| 360 | }, |
| 361 | 'last_update': time.time() |
| 362 | } |
| 363 | |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 364 | class MyEvent: |
Andy Bavier | c41cf0c | 2020-09-02 14:49:21 -0700 | [diff] [blame] | 365 | def __init__ (self, location = "", description = "", summary = "", start = None, end = None, all_day = False): |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 366 | self.location = location |
| 367 | self.description = description |
| 368 | self.summary = summary |
| 369 | self.start = start |
| 370 | self.end = end |
Andy Bavier | c41cf0c | 2020-09-02 14:49:21 -0700 | [diff] [blame] | 371 | self.all_day = all_day |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 372 | |
| 373 | class MyEventNoLoc: |
| 374 | def __init__ (self, description = "", summary = ""): |
| 375 | self.description = description |
| 376 | self.summary = summary |
| 377 | |
| 378 | |
| 379 | class TestEdgeMonitoringServer(unittest.TestCase): |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 380 | def setUp(self): |
| 381 | self.app = ems.app.test_client() |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 382 | self.emulated_time = time.mktime(time.strptime("2021-04-05 00:00:00", "%Y-%m-%d %H:%M:%S")) |
| 383 | self.time_method = time.time |
| 384 | time.time = self._get_time |
| 385 | |
| 386 | def tearDown(self): |
| 387 | time.time = self.time_method |
| 388 | |
| 389 | def _get_time(self): |
| 390 | return self.emulated_time |
| 391 | |
| 392 | def _assert_status_metrics_exist(self, data): |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 393 | self.assertTrue('aetheredge_status_control_plane{name="ace-menlo-rasp-pi"} 2.0' in data) |
| 394 | self.assertTrue('aetheredge_status_user_plane{name="ace-menlo-rasp-pi"} 2.0' in data) |
| 395 | self.assertTrue('aetheredge_last_update{name="ace-menlo-rasp-pi"}' in data) |
| 396 | self.assertTrue('aetheredge_connect_test_ok{name="ace-menlo-rasp-pi"} 1.0' in data) |
| 397 | self.assertTrue('aetheredge_ping_test_ok{name="ace-menlo-rasp-pi"} 1.0' in data) |
| 398 | self.assertTrue('aetheredge_e2e_tests_ok{name="ace-menlo-rasp-pi"} 1.0' in data) |
| 399 | self.assertTrue('aetheredge_e2e_tests_down{name="ace-menlo-rasp-pi"} 0.0' in data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 400 | |
| 401 | def _assert_speedtest_metrics_exist(self, data): |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 402 | self.assertTrue('aetheredge_ping_dry_run_test_transmitted{name="ace-menlo-rasp-pi"} 3' in data) |
| 403 | self.assertTrue('aetheredge_ping_dry_run_test_received{name="ace-menlo-rasp-pi"} 2' in data) |
| 404 | self.assertTrue('aetheredge_ping_dry_run_test_median{name="ace-menlo-rasp-pi"} 5.0' in data) |
| 405 | self.assertTrue('aetheredge_ping_dry_run_test_min{name="ace-menlo-rasp-pi"} 1.0' in data) |
| 406 | self.assertTrue('aetheredge_ping_dry_run_test_avg{name="ace-menlo-rasp-pi"} 5.0' in data) |
| 407 | self.assertTrue('aetheredge_ping_dry_run_test_max{name="ace-menlo-rasp-pi"} 9.0' in data) |
| 408 | self.assertTrue('aetheredge_ping_dry_run_test_stddev{name="ace-menlo-rasp-pi"} 1.0' in data) |
| 409 | |
| 410 | self.assertTrue('aetheredge_ping_dns_test_transmitted{name="ace-menlo-rasp-pi"} 10' in data) |
| 411 | self.assertTrue('aetheredge_ping_dns_test_received{name="ace-menlo-rasp-pi"} 9' in data) |
| 412 | self.assertTrue('aetheredge_ping_dns_test_median{name="ace-menlo-rasp-pi"} 4.0' in data) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 413 | self.assertTrue('aetheredge_ping_dns_test_min{name="ace-menlo-rasp-pi"} 2.0' in data) |
| 414 | self.assertTrue('aetheredge_ping_dns_test_avg{name="ace-menlo-rasp-pi"} 4.0' in data) |
| 415 | self.assertTrue('aetheredge_ping_dns_test_max{name="ace-menlo-rasp-pi"} 6.0' in data) |
| 416 | self.assertTrue('aetheredge_ping_dns_test_stddev{name="ace-menlo-rasp-pi"} 1.0' in data) |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 417 | |
| 418 | self.assertTrue('aetheredge_ping_iperf_server_test_transmitted{name="ace-menlo-rasp-pi"} 10' in data) |
| 419 | self.assertTrue('aetheredge_ping_iperf_server_test_received{name="ace-menlo-rasp-pi"} 10' in data) |
| 420 | self.assertTrue('aetheredge_ping_iperf_server_test_median{name="ace-menlo-rasp-pi"} 3.0' in data) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 421 | self.assertTrue('aetheredge_ping_iperf_server_test_min{name="ace-menlo-rasp-pi"} 1.0' in data) |
| 422 | self.assertTrue('aetheredge_ping_iperf_server_test_avg{name="ace-menlo-rasp-pi"} 3.0' in data) |
| 423 | self.assertTrue('aetheredge_ping_iperf_server_test_max{name="ace-menlo-rasp-pi"} 5.0' in data) |
| 424 | self.assertTrue('aetheredge_ping_iperf_server_test_stddev{name="ace-menlo-rasp-pi"} 1.0' in data) |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 425 | |
| 426 | self.assertTrue('aetheredge_ping_management_server_test_transmitted{name="ace-menlo-rasp-pi"} 10' in data) |
| 427 | self.assertTrue('aetheredge_ping_management_server_test_received{name="ace-menlo-rasp-pi"} 8' in data) |
| 428 | self.assertTrue('aetheredge_ping_management_server_test_median{name="ace-menlo-rasp-pi"} 6.0' in data) |
| 429 | self.assertTrue('aetheredge_ping_management_server_test_min{name="ace-menlo-rasp-pi"} 2.0' in data) |
| 430 | self.assertTrue('aetheredge_ping_management_server_test_avg{name="ace-menlo-rasp-pi"} 6.0' in data) |
| 431 | self.assertTrue('aetheredge_ping_management_server_test_max{name="ace-menlo-rasp-pi"} 10.0' in data) |
| 432 | self.assertTrue('aetheredge_ping_management_server_test_stddev{name="ace-menlo-rasp-pi"} 1.0' in data) |
| 433 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 434 | self.assertTrue('aetheredge_iperf_cluster_downlink_test{name="ace-menlo-rasp-pi"} 100.0' in data) |
| 435 | self.assertTrue('aetheredge_iperf_cluster_uplink_test{name="ace-menlo-rasp-pi"} 10.0' in data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 436 | |
| 437 | def _assert_signal_quality_metrics_exist(self, data): |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 438 | self.assertTrue('aetheredge_signal_quality_rsrq{name="ace-menlo-rasp-pi"} 30' in data) |
| 439 | self.assertTrue('aetheredge_signal_quality_rsrp{name="ace-menlo-rasp-pi"} 80' in data) |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 440 | |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 441 | def _assert_dongle_stats_metrics_exist(self, data): |
| 442 | self.assertTrue('aetheredge_dongle_stats_imsi{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | 1eaff6a | 2021-11-16 13:46:46 -0800 | [diff] [blame] | 443 | self.assertTrue('aetheredge_dongle_stats_cellglobalid{name="ace-menlo-rasp-pi"} 8.67518969411584e+014' in data) |
| 444 | self.assertTrue('aetheredge_dongle_stats_plmnstatus{name="ace-menlo-rasp-pi"} 3' in data) |
| 445 | self.assertTrue('aetheredge_dongle_stats_phycellid{name="ace-menlo-rasp-pi"} 101' in data) |
| 446 | |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 447 | |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 448 | def test_match_location(self): |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 449 | event = MyEvent(location = "ace-menlo-rasp-pi-production") |
| 450 | self.assertTrue(ems.is_my_event(event, "ace-menlo-rasp-pi")) |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 451 | event = MyEvent(location = "(Compute)-MP-1-Aether Production") |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 452 | self.assertTrue(ems.is_my_event(event, "ace-menlo-rasp-pi")) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 453 | |
| 454 | def test_match_description(self): |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 455 | event = MyEvent(description = "ace-menlo-rasp-pi-production") |
| 456 | self.assertTrue(ems.is_my_event(event, "ace-menlo-rasp-pi")) |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 457 | event = MyEvent(description = "(Compute)-MP-1-Aether Production") |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 458 | self.assertTrue(ems.is_my_event(event, "ace-menlo-rasp-pi")) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 459 | |
| 460 | def test_match_summary(self): |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 461 | event = MyEvent(summary = "ace-menlo-rasp-pi-production") |
| 462 | self.assertTrue(ems.is_my_event(event, "ace-menlo-rasp-pi")) |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 463 | event = MyEvent(summary = "(Compute)-MP-1-Aether Production") |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 464 | self.assertTrue(ems.is_my_event(event, "ace-menlo-rasp-pi")) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 465 | |
| 466 | def test_no_match(self): |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 467 | event = MyEvent(summary = "ace-menlo-rasp-pi-production, (Compute)-MP-1-Aether Production") |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 468 | self.assertFalse(ems.is_my_event(event, "ace-intel")) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 469 | self.assertFalse(ems.is_my_event(event, "(Compute)-MP-1-Aether Staging")) |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 470 | self.assertFalse(ems.is_my_event(event, "ace-menlo")) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 471 | |
| 472 | def test_missing_field(self): |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 473 | event = MyEventNoLoc(description = "(Compute)-MP-1-Aether Production") |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 474 | self.assertTrue(ems.is_my_event(event, "ace-menlo-rasp-pi")) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 475 | |
| 476 | def test_in_window(self): |
| 477 | events = [] |
| 478 | now = datetime.datetime.now(pytz.utc) |
| 479 | events.append(MyEvent(location = "(Compute)-MP-1-Aether Production", |
| 480 | start = now - datetime.timedelta(hours=1), |
| 481 | end = now + datetime.timedelta(hours=1))) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 482 | self.assertTrue(ems.in_maintenance_window(events, "ace-menlo-rasp-pi", now)) |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 483 | self.assertFalse(ems.in_maintenance_window(events, "ace-tucson", now)) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 484 | |
| 485 | def test_not_in_window(self): |
| 486 | events = [] |
| 487 | now = datetime.datetime.now(pytz.utc) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 488 | events.append(MyEvent(location = "ace-menlo-rasp-pi-production", |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 489 | start = now + datetime.timedelta(hours=1), |
| 490 | end = now + datetime.timedelta(hours=2))) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 491 | self.assertFalse(ems.in_maintenance_window(events, "ace-menlo-rasp-pi", now)) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 492 | |
| 493 | def test_no_events(self): |
| 494 | events = [] |
| 495 | now = datetime.datetime.now(pytz.utc) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 496 | self.assertFalse(ems.in_maintenance_window(events, "ace-menlo-rasp-pi", now)) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 497 | |
Andy Bavier | c41cf0c | 2020-09-02 14:49:21 -0700 | [diff] [blame] | 498 | def test_all_day_events(self): |
| 499 | events = [] |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 500 | events.append(MyEvent(location = "ace-menlo-rasp-pi-production", |
Andy Bavier | c41cf0c | 2020-09-02 14:49:21 -0700 | [diff] [blame] | 501 | start = datetime.datetime(2020, 9, 2, 0, 0), |
| 502 | end = datetime.datetime(2020, 9, 3, 0, 0), |
| 503 | all_day = True)) |
| 504 | |
| 505 | ems.process_all_day_events(events) |
| 506 | |
| 507 | now = datetime.datetime(2020, 9, 2, 12, 0, tzinfo=pytz.utc) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 508 | self.assertTrue(ems.in_maintenance_window(events, "ace-menlo-rasp-pi", now)) |
Andy Bavier | c41cf0c | 2020-09-02 14:49:21 -0700 | [diff] [blame] | 509 | |
| 510 | now = datetime.datetime(2020, 9, 3, 12, 0, tzinfo=pytz.utc) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 511 | self.assertFalse(ems.in_maintenance_window(events, "ace-menlo-rasp-pi", now)) |
Andy Bavier | c41cf0c | 2020-09-02 14:49:21 -0700 | [diff] [blame] | 512 | |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 513 | def test_get_edges(self): |
| 514 | response = self.app.get('/edges') |
| 515 | data = json.loads(response.get_data(as_text=True)) |
| 516 | self.assertEqual(len(data['edges']), 1) |
Andy Bavier | 8a5c987 | 2020-10-21 13:17:53 -0700 | [diff] [blame] | 517 | self.assertEqual(data['edges'][0]['name'], 'ace-example') |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 518 | |
Andy Bavier | f872e9a | 2021-03-22 12:06:25 -0700 | [diff] [blame] | 519 | def test_create_and_delete_edge_legacy(self): |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 520 | response = self.app.post('/edges', json=test_edge) |
| 521 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 522 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 523 | |
| 524 | response = self.app.get('/edges') |
| 525 | data = json.loads(response.get_data(as_text=True)) |
| 526 | self.assertEqual(len(data['edges']), 2) |
| 527 | |
Andy Bavier | e47157d | 2020-12-11 14:13:12 -0700 | [diff] [blame] | 528 | response = self.app.get('/edges/metrics') |
| 529 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 530 | # print(data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 531 | |
| 532 | self._assert_status_metrics_exist(data) |
| 533 | self._assert_speedtest_metrics_exist(data) |
| 534 | self._assert_signal_quality_metrics_exist(data) |
Andy Bavier | e47157d | 2020-12-11 14:13:12 -0700 | [diff] [blame] | 535 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 536 | response = self.app.delete('/edges/ace-menlo-rasp-pi') |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 537 | data = json.loads(response.get_data(as_text=True)) |
| 538 | self.assertEqual(data['result'], True) |
Andy Bavier | e47157d | 2020-12-11 14:13:12 -0700 | [diff] [blame] | 539 | |
| 540 | response = self.app.get('/edges/metrics') |
| 541 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 542 | # print(data) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 543 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Hyunsun Moon | 5f237ec | 2020-09-29 14:45:52 -0700 | [diff] [blame] | 544 | |
| 545 | response = self.app.get('/edges') |
| 546 | data = json.loads(response.get_data(as_text=True)) |
| 547 | self.assertEqual(len(data['edges']), 1) |
Andy Bavier | c41cf0c | 2020-09-02 14:49:21 -0700 | [diff] [blame] | 548 | |
Andy Bavier | f872e9a | 2021-03-22 12:06:25 -0700 | [diff] [blame] | 549 | def test_create_and_delete_edge(self): |
| 550 | response = self.app.post('/testresults', json=test_edge) |
| 551 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 552 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
Andy Bavier | f872e9a | 2021-03-22 12:06:25 -0700 | [diff] [blame] | 553 | |
| 554 | response = self.app.get('/edges') |
| 555 | data = json.loads(response.get_data(as_text=True)) |
| 556 | self.assertEqual(len(data['edges']), 2) |
| 557 | |
| 558 | response = self.app.get('/edges/metrics') |
| 559 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 560 | # print(data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 561 | |
| 562 | self._assert_status_metrics_exist(data) |
| 563 | self._assert_speedtest_metrics_exist(data) |
| 564 | self._assert_signal_quality_metrics_exist(data) |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 565 | self._assert_dongle_stats_metrics_exist(data) |
Andy Bavier | f872e9a | 2021-03-22 12:06:25 -0700 | [diff] [blame] | 566 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 567 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
Andy Bavier | f872e9a | 2021-03-22 12:06:25 -0700 | [diff] [blame] | 568 | data = json.loads(response.get_data(as_text=True)) |
| 569 | self.assertEqual(data['result'], True) |
| 570 | |
| 571 | response = self.app.get('/edges/metrics') |
| 572 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 573 | # print(data) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 574 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Andy Bavier | f872e9a | 2021-03-22 12:06:25 -0700 | [diff] [blame] | 575 | |
| 576 | response = self.app.get('/edges') |
| 577 | data = json.loads(response.get_data(as_text=True)) |
| 578 | self.assertEqual(len(data['edges']), 1) |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 579 | |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 580 | def test_create_and_delete_edge_speed_test(self): |
| 581 | response = self.app.post('/testresults', json=test_edge) |
| 582 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 583 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 584 | |
| 585 | response = self.app.get('/edges/metrics') |
| 586 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 587 | # print(data) |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 588 | |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 589 | self._assert_speedtest_metrics_exist(data) |
| 590 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 591 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 592 | data = json.loads(response.get_data(as_text=True)) |
| 593 | self.assertEqual(data['result'], True) |
| 594 | |
| 595 | def test_backwards_compatible_status_only(self): |
| 596 | response = self.app.post('/testresults', json=test_edge_status_only) |
| 597 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 598 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 599 | |
| 600 | response = self.app.get('/edges/metrics') |
| 601 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 602 | # print(data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 603 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 604 | self.assertFalse('aetheredge_signal_quality_rsrq{name="ace-menlo-rasp-pi"}' in data) |
| 605 | self.assertFalse('aetheredge_signal_quality_rsrp{name="ace-menlo-rasp-pi"}' in data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 606 | |
| 607 | self._assert_status_metrics_exist(data) |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 608 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 609 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 610 | data = json.loads(response.get_data(as_text=True)) |
| 611 | self.assertEqual(data['result'], True) |
| 612 | |
| 613 | def test_backwards_compatible_no_speedtest(self): |
| 614 | response = self.app.post('/testresults', json=test_edge_no_speedtest) |
| 615 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 616 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 617 | |
| 618 | response = self.app.get('/edges/metrics') |
| 619 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 620 | # print(data) |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 621 | |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 622 | self.assertFalse('aetheredge_ping_dry_run_test_transmitted{name="ace-menlo-rasp-pi"}' in data) |
| 623 | self.assertFalse('aetheredge_ping_dry_run_test_received{name="ace-menlo-rasp-pi"}' in data) |
| 624 | self.assertFalse('aetheredge_ping_dry_run_test_median{name="ace-menlo-rasp-pi"}' in data) |
| 625 | self.assertFalse('aetheredge_ping_dry_run_test_min{name="ace-menlo-rasp-pi"}' in data) |
| 626 | self.assertFalse('aetheredge_ping_dry_run_test_avg{name="ace-menlo-rasp-pi"}' in data) |
| 627 | self.assertFalse('aetheredge_ping_dry_run_test_max{name="ace-menlo-rasp-pi"}' in data) |
| 628 | self.assertFalse('aetheredge_ping_dry_run_test_stddev{name="ace-menlo-rasp-pi"}' in data) |
| 629 | |
| 630 | self.assertFalse('aetheredge_ping_dns_test_transmitted{name="ace-menlo-rasp-pi"}' in data) |
| 631 | self.assertFalse('aetheredge_ping_dns_test_received{name="ace-menlo-rasp-pi"}' in data) |
| 632 | self.assertFalse('aetheredge_ping_dns_test_median{name="ace-menlo-rasp-pi"}' in data) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 633 | self.assertFalse('aetheredge_ping_dns_test_min{name="ace-menlo-rasp-pi"}' in data) |
| 634 | self.assertFalse('aetheredge_ping_dns_test_avg{name="ace-menlo-rasp-pi"}' in data) |
| 635 | self.assertFalse('aetheredge_ping_dns_test_max{name="ace-menlo-rasp-pi"}' in data) |
| 636 | self.assertFalse('aetheredge_ping_dns_test_stddev{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 637 | |
| 638 | self.assertFalse('aetheredge_ping_iperf_server_test_transmitted{name="ace-menlo-rasp-pi"}' in data) |
| 639 | self.assertFalse('aetheredge_ping_iperf_server_test_received{name="ace-menlo-rasp-pi"}' in data) |
| 640 | self.assertFalse('aetheredge_ping_iperf_server_test_median{name="ace-menlo-rasp-pi"}' in data) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 641 | self.assertFalse('aetheredge_ping_iperf_server_test_min{name="ace-menlo-rasp-pi"}' in data) |
| 642 | self.assertFalse('aetheredge_ping_iperf_server_test_avg{name="ace-menlo-rasp-pi"}' in data) |
| 643 | self.assertFalse('aetheredge_ping_iperf_server_test_max{name="ace-menlo-rasp-pi"}' in data) |
| 644 | self.assertFalse('aetheredge_ping_iperf_server_test_stddev{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 645 | |
| 646 | self.assertFalse('aetheredge_ping_management_server_test_transmitted{name="ace-menlo-rasp-pi"}' in data) |
| 647 | self.assertFalse('aetheredge_ping_management_server_test_received{name="ace-menlo-rasp-pi"}' in data) |
| 648 | self.assertFalse('aetheredge_ping_management_server_test_median{name="ace-menlo-rasp-pi"}' in data) |
| 649 | self.assertFalse('aetheredge_ping_management_server_test_min{name="ace-menlo-rasp-pi"}' in data) |
| 650 | self.assertFalse('aetheredge_ping_management_server_test_avg{name="ace-menlo-rasp-pi"}' in data) |
| 651 | self.assertFalse('aetheredge_ping_management_server_test_max{name="ace-menlo-rasp-pi"}' in data) |
| 652 | self.assertFalse('aetheredge_ping_management_server_test_stddev{name="ace-menlo-rasp-pi"}' in data) |
| 653 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 654 | self.assertFalse('aetheredge_iperf_cluster_downlink_test{name="ace-menlo-rasp-pi"}' in data) |
| 655 | self.assertFalse('aetheredge_iperf_cluster_uplink_test{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 656 | |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 657 | self._assert_status_metrics_exist(data) |
| 658 | self._assert_signal_quality_metrics_exist(data) |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 659 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 660 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
Jeremy Ronquillo | f420025 | 2021-02-13 16:11:04 -0800 | [diff] [blame] | 661 | data = json.loads(response.get_data(as_text=True)) |
| 662 | self.assertEqual(data['result'], True) |
| 663 | |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 664 | def test_backwards_compatible_no_signal_quality(self): |
| 665 | response = self.app.post('/testresults', json=test_edge_no_signal_quality) |
| 666 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 667 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 668 | |
| 669 | response = self.app.get('/edges/metrics') |
| 670 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 671 | # print(data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 672 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 673 | self.assertFalse('aetheredge_signal_quality_rsrq{name="ace-menlo-rasp-pi"}' in data) |
| 674 | self.assertFalse('aetheredge_signal_quality_rsrp{name="ace-menlo-rasp-pi"}' in data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 675 | |
| 676 | self._assert_status_metrics_exist(data) |
| 677 | self._assert_speedtest_metrics_exist(data) |
| 678 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 679 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 680 | data = json.loads(response.get_data(as_text=True)) |
| 681 | self.assertEqual(data['result'], True) |
| 682 | |
| 683 | def test_timeout_stale_result(self): |
| 684 | response = self.app.post('/testresults', json=test_edge) |
| 685 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 686 | # print(json.dumps(data, indent=2)) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 687 | |
| 688 | self.assertEqual(data['edge']['status']['control_plane'], 'connected') |
| 689 | self.assertEqual(data['edge']['status']['user_plane'], 'connected') |
| 690 | self.assertEqual(data['edge']['speedtest']['ping']['dns']['avg'], 4.0) |
Jeremy Ronquillo | 6e352b7 | 2021-06-08 10:33:25 -0700 | [diff] [blame] | 691 | self.assertEqual(data['edge']['speedtest']['ping']['iperf_server']['avg'], 3.0) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 692 | self.assertTrue('signal_quality' in data['edge']) |
| 693 | |
| 694 | self.emulated_time += (ems.NO_RESULT_THRESHOLD + 1) |
| 695 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 696 | response = self.app.get('/edges/ace-menlo-rasp-pi') |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 697 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 698 | # print(json.dumps(data, indent=2)) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 699 | |
| 700 | self.assertEqual(data['edge']['status']['control_plane'], 'no result') |
| 701 | self.assertEqual(data['edge']['status']['user_plane'], 'no result') |
| 702 | self.assertEqual(data['edge']['speedtest']['ping']['dns']['avg'], 0.0) |
Jeremy Ronquillo | 6e352b7 | 2021-06-08 10:33:25 -0700 | [diff] [blame] | 703 | self.assertEqual(data['edge']['speedtest']['ping']['iperf_server']['avg'], 0.0) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 704 | self.assertFalse('signal_quality' in data['edge']) |
| 705 | |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 706 | def test_backwards_compatible_no_iperf(self): |
| 707 | response = self.app.post('/testresults', json=test_edge_no_iperf) |
| 708 | data = json.loads(response.get_data(as_text=True)) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 709 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 710 | |
| 711 | response = self.app.get('/edges/metrics') |
| 712 | data = response.get_data(as_text=True) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 713 | # print(data) |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 714 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 715 | self.assertFalse('aetheredge_iperf_cluster_downlink{name="ace-menlo-rasp-pi"}' in data) |
| 716 | self.assertFalse('aetheredge_iperf_cluster_uplink{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 717 | self.assertFalse('aetheredge_ping_iperf_server_test_transmitted{name="ace-menlo-rasp-pi"}' in data) |
| 718 | self.assertFalse('aetheredge_ping_iperf_server_test_received{name="ace-menlo-rasp-pi"}' in data) |
| 719 | self.assertFalse('aetheredge_ping_iperf_server_test_median{name="ace-menlo-rasp-pi"}' in data) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 720 | self.assertFalse('aetheredge_ping_iperf_server_test_min{name="ace-menlo-rasp-pi"}' in data) |
| 721 | self.assertFalse('aetheredge_ping_iperf_server_test_avg{name="ace-menlo-rasp-pi"}' in data) |
| 722 | self.assertFalse('aetheredge_ping_iperf_server_test_max{name="ace-menlo-rasp-pi"}' in data) |
| 723 | self.assertFalse('aetheredge_ping_iperf_server_test_stddev{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 724 | |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 725 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
Jeremy Ronquillo | c743462 | 2021-04-08 21:06:00 -0700 | [diff] [blame] | 726 | data = json.loads(response.get_data(as_text=True)) |
| 727 | self.assertEqual(data['result'], True) |
| 728 | |
Jeremy Ronquillo | e0a8b42 | 2021-11-02 12:49:15 -0700 | [diff] [blame] | 729 | def test_backwards_compatible_pre_0_7_0(self): |
| 730 | response = self.app.post('/testresults', json=test_edge_pre_0_7_0) |
| 731 | data = json.loads(response.get_data(as_text=True)) |
| 732 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
| 733 | |
| 734 | response = self.app.get('/edges/metrics') |
| 735 | data = response.get_data(as_text=True) |
| 736 | # print(data) |
| 737 | |
| 738 | self.assertFalse('aetheredge_ping_dry_run_test_transmitted{name="ace-menlo-rasp-pi"}' in data) |
| 739 | self.assertFalse('aetheredge_ping_dry_run_test_received{name="ace-menlo-rasp-pi"}' in data) |
| 740 | self.assertFalse('aetheredge_ping_dry_run_test_median{name="ace-menlo-rasp-pi"}' in data) |
| 741 | self.assertFalse('aetheredge_ping_dry_run_test_min{name="ace-menlo-rasp-pi"}' in data) |
| 742 | self.assertFalse('aetheredge_ping_dry_run_test_avg{name="ace-menlo-rasp-pi"}' in data) |
| 743 | self.assertFalse('aetheredge_ping_dry_run_test_max{name="ace-menlo-rasp-pi"}' in data) |
| 744 | self.assertFalse('aetheredge_ping_dry_run_test_stddev{name="ace-menlo-rasp-pi"}' in data) |
| 745 | |
| 746 | self.assertFalse('aetheredge_ping_management_server_test_transmitted{name="ace-menlo-rasp-pi"}' in data) |
| 747 | self.assertFalse('aetheredge_ping_management_server_test_received{name="ace-menlo-rasp-pi"}' in data) |
| 748 | self.assertFalse('aetheredge_ping_management_server_test_median{name="ace-menlo-rasp-pi"}' in data) |
| 749 | self.assertFalse('aetheredge_ping_management_server_test_min{name="ace-menlo-rasp-pi"}' in data) |
| 750 | self.assertFalse('aetheredge_ping_management_server_test_avg{name="ace-menlo-rasp-pi"}' in data) |
| 751 | self.assertFalse('aetheredge_ping_management_server_test_max{name="ace-menlo-rasp-pi"}' in data) |
| 752 | self.assertFalse('aetheredge_ping_management_server_test_stddev{name="ace-menlo-rasp-pi"}' in data) |
| 753 | |
| 754 | self.assertFalse('aetheredge_ping_dns_test_transmitted{name="ace-menlo-rasp-pi"} 10' in data) |
| 755 | self.assertFalse('aetheredge_ping_dns_test_received{name="ace-menlo-rasp-pi"} 9' in data) |
| 756 | self.assertFalse('aetheredge_ping_dns_test_median{name="ace-menlo-rasp-pi"} 4.0' in data) |
| 757 | |
| 758 | self.assertFalse('aetheredge_ping_iperf_server_test_transmitted{name="ace-menlo-rasp-pi"} 10' in data) |
| 759 | self.assertFalse('aetheredge_ping_iperf_server_test_received{name="ace-menlo-rasp-pi"} 10' in data) |
| 760 | self.assertFalse('aetheredge_ping_iperf_server_test_median{name="ace-menlo-rasp-pi"} 3.0' in data) |
| 761 | |
| 762 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
| 763 | data = json.loads(response.get_data(as_text=True)) |
| 764 | self.assertEqual(data['result'], True) |
| 765 | |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 766 | def test_backwards_compatible_no_dongle_stats(self): |
| 767 | response = self.app.post('/testresults', json=test_edge_no_dongle_stats) |
| 768 | data = json.loads(response.get_data(as_text=True)) |
| 769 | self.assertEqual(data['edge']['name'], 'ace-menlo-rasp-pi') |
| 770 | |
| 771 | response = self.app.get('/edges/metrics') |
| 772 | data = response.get_data(as_text=True) |
| 773 | |
Jeremy Ronquillo | cd711a2 | 2021-11-18 10:37:56 -0800 | [diff] [blame] | 774 | self.assertFalse('aetheredge_dongle_stats_imsi{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | 1eaff6a | 2021-11-16 13:46:46 -0800 | [diff] [blame] | 775 | self.assertFalse('aetheredge_dongle_stats_cellglobalid{name="ace-menlo-rasp-pi"}' in data) |
| 776 | self.assertFalse('aetheredge_dongle_stats_plmnstatus{name="ace-menlo-rasp-pi"}' in data) |
| 777 | self.assertFalse('aetheredge_dongle_stats_phycellid{name="ace-menlo-rasp-pi"}' in data) |
Jeremy Ronquillo | c45955a | 2021-11-09 12:04:57 -0800 | [diff] [blame] | 778 | |
| 779 | response = self.app.delete('/testresults/ace-menlo-rasp-pi') |
| 780 | data = json.loads(response.get_data(as_text=True)) |
| 781 | self.assertEqual(data['result'], True) |
| 782 | |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 783 | def test_handle_invalid_schema(self): |
| 784 | response = self.app.post('/testresults', json="") |
| 785 | self.assertEqual(response.status_code, 400) |
| 786 | |
| 787 | no_name = deepcopy(test_edge) |
| 788 | del no_name['name'] |
| 789 | response = self.app.post('/testresults', json=no_name) |
| 790 | self.assertEqual(response.status_code, 400) |
| 791 | response = self.app.get('/edges/metrics') |
| 792 | data = response.get_data(as_text=True) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 793 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 794 | |
| 795 | no_status = deepcopy(test_edge) |
| 796 | del no_status['status'] |
| 797 | response = self.app.post('/testresults', json=no_status) |
| 798 | self.assertEqual(response.status_code, 400) |
| 799 | response = self.app.get('/edges/metrics') |
| 800 | data = response.get_data(as_text=True) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 801 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 802 | |
| 803 | bad_status = deepcopy(test_edge) |
| 804 | bad_status['status']['control_plane'] = 1 |
| 805 | response = self.app.post('/testresults', json=bad_status) |
| 806 | self.assertEqual(response.status_code, 400) |
| 807 | response = self.app.get('/edges/metrics') |
| 808 | data = response.get_data(as_text=True) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 809 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 810 | |
| 811 | bad_ping_result = deepcopy(test_edge) |
| 812 | bad_ping_result['speedtest']['ping']['dns']['min'] = "foo" |
| 813 | response = self.app.post('/testresults', json=bad_ping_result) |
| 814 | self.assertEqual(response.status_code, 400) |
| 815 | response = self.app.get('/edges/metrics') |
| 816 | data = response.get_data(as_text=True) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 817 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 818 | |
| 819 | bad_iperf_result = deepcopy(test_edge) |
| 820 | bad_iperf_result['speedtest']['iperf']['cluster']['uplink'] = "foo" |
| 821 | response = self.app.post('/testresults', json=bad_iperf_result) |
| 822 | self.assertEqual(response.status_code, 400) |
| 823 | response = self.app.get('/edges/metrics') |
| 824 | data = response.get_data(as_text=True) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 825 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Andy Bavier | 2d60fc5 | 2021-05-04 16:13:39 -0700 | [diff] [blame] | 826 | |
| 827 | bad_signal_quality = deepcopy(test_edge) |
| 828 | del bad_signal_quality['signal_quality']['rsrq'] |
| 829 | response = self.app.post('/testresults', json=bad_signal_quality) |
| 830 | self.assertEqual(response.status_code, 400) |
| 831 | response = self.app.get('/edges/metrics') |
| 832 | data = response.get_data(as_text=True) |
Andy Bavier | e459122 | 2021-07-07 12:44:19 -0700 | [diff] [blame] | 833 | self.assertFalse('ace-menlo-rasp-pi' in data) |
Hyunsun Moon | 200eba5 | 2021-04-05 21:31:54 -0700 | [diff] [blame] | 834 | |
Andy Bavier | 614af14 | 2020-08-07 14:49:56 -0700 | [diff] [blame] | 835 | if __name__ == '__main__': |
Andy Bavier | 55dc587 | 2021-05-05 11:31:42 -0700 | [diff] [blame] | 836 | import xmlrunner |
| 837 | with open('results.xml', 'wb') as output: |
Jeremy Ronquillo | 6e352b7 | 2021-06-08 10:33:25 -0700 | [diff] [blame] | 838 | unittest.main(testRunner=xmlrunner.XMLTestRunner(verbosity=2, output=output)) |