|
| 1 | +# |
| 2 | +# Copyright 2021-2024 Software Radio Systems Limited |
| 3 | +# |
| 4 | +# By using this file, you agree to the terms and conditions set |
| 5 | +# forth in the LICENSE file which can be found at the top level of |
| 6 | +# the distribution. |
| 7 | +# |
| 8 | + |
| 9 | +""" |
| 10 | +Ping / Reestablishment Tests |
| 11 | +""" |
| 12 | +import logging |
| 13 | +import time |
| 14 | +from typing import Optional, Sequence, Tuple, Union |
| 15 | + |
| 16 | +from pytest import mark |
| 17 | +from retina.client.manager import RetinaTestManager |
| 18 | +from retina.launcher.artifacts import RetinaTestData |
| 19 | +from retina.launcher.utils import configure_artifacts, param |
| 20 | +from retina.protocol.fivegc_pb2_grpc import FiveGCStub |
| 21 | +from retina.protocol.gnb_pb2_grpc import GNBStub |
| 22 | +from retina.protocol.ue_pb2_grpc import UEStub |
| 23 | + |
| 24 | +from .steps.configuration import configure_test_parameters |
| 25 | +from .steps.stub import ping_start, ping_wait_until_finish, start_network, stop, ue_reestablishment, ue_start_and_attach |
| 26 | + |
| 27 | + |
| 28 | +@mark.parametrize( |
| 29 | + "band, common_scs, bandwidth, always_download_artifacts", |
| 30 | + ( |
| 31 | + param(3, 15, 50, True, id="band:%s-scs:%s-bandwidth:%s-artifacts:%s"), |
| 32 | + param(41, 30, 50, False, id="band:%s-scs:%s-bandwidth:%s-artifacts:%s"), |
| 33 | + ), |
| 34 | +) |
| 35 | +@mark.zmq |
| 36 | +@mark.flaky(reruns=3, only_rerun=["failed to start"]) |
| 37 | +# pylint: disable=too-many-arguments |
| 38 | +def test_zmq_reestablishment( |
| 39 | + retina_manager: RetinaTestManager, |
| 40 | + retina_data: RetinaTestData, |
| 41 | + ue_32: Tuple[UEStub, ...], |
| 42 | + fivegc: FiveGCStub, |
| 43 | + gnb: GNBStub, |
| 44 | + band: int, |
| 45 | + common_scs: int, |
| 46 | + bandwidth: int, |
| 47 | + always_download_artifacts: bool, |
| 48 | +): |
| 49 | + """ |
| 50 | + ZMQ Attach / reestablishment |
| 51 | + """ |
| 52 | + |
| 53 | + test_duration_sec = 15 * 60 |
| 54 | + reestablishment_interval = 3 # seconds |
| 55 | + reestablishment_count = int(test_duration_sec / reestablishment_interval) |
| 56 | + |
| 57 | + _ping_and_reestablishment_multi_ues( |
| 58 | + retina_manager=retina_manager, |
| 59 | + retina_data=retina_data, |
| 60 | + ue_array=ue_32, |
| 61 | + gnb=gnb, |
| 62 | + fivegc=fivegc, |
| 63 | + band=band, |
| 64 | + common_scs=common_scs, |
| 65 | + bandwidth=bandwidth, |
| 66 | + sample_rate=None, # default from testbed |
| 67 | + global_timing_advance=0, |
| 68 | + time_alignment_calibration=0, |
| 69 | + always_download_artifacts=always_download_artifacts, |
| 70 | + reestablishment_count=reestablishment_count, |
| 71 | + reestablishment_interval=reestablishment_interval, |
| 72 | + ping_count=test_duration_sec, |
| 73 | + warning_as_errors=True, |
| 74 | + ) |
| 75 | + |
| 76 | + |
| 77 | +# pylint: disable=too-many-arguments,too-many-locals |
| 78 | +def _ping_and_reestablishment_multi_ues( |
| 79 | + retina_manager: RetinaTestManager, |
| 80 | + retina_data: RetinaTestData, |
| 81 | + ue_array: Sequence[UEStub], |
| 82 | + fivegc: FiveGCStub, |
| 83 | + gnb: GNBStub, |
| 84 | + band: int, |
| 85 | + common_scs: int, |
| 86 | + bandwidth: int, |
| 87 | + sample_rate: Optional[int], |
| 88 | + global_timing_advance: int, |
| 89 | + time_alignment_calibration: Union[int, str], |
| 90 | + always_download_artifacts: bool, |
| 91 | + ping_count: int, |
| 92 | + warning_as_errors: bool = True, |
| 93 | + reestablishment_count: int = 1, |
| 94 | + reestablishment_interval: int = 3, |
| 95 | +): |
| 96 | + logging.info("Reestablishment / Ping Test") |
| 97 | + |
| 98 | + configure_test_parameters( |
| 99 | + retina_manager=retina_manager, |
| 100 | + retina_data=retina_data, |
| 101 | + band=band, |
| 102 | + common_scs=common_scs, |
| 103 | + bandwidth=bandwidth, |
| 104 | + sample_rate=sample_rate, |
| 105 | + global_timing_advance=global_timing_advance, |
| 106 | + time_alignment_calibration=time_alignment_calibration, |
| 107 | + pcap=False, |
| 108 | + ) |
| 109 | + |
| 110 | + configure_artifacts( |
| 111 | + retina_data=retina_data, |
| 112 | + always_download_artifacts=always_download_artifacts, |
| 113 | + ) |
| 114 | + |
| 115 | + start_network(ue_array, gnb, fivegc) |
| 116 | + |
| 117 | + ue_attach_info_dict = ue_start_and_attach(ue_array, gnb, fivegc) |
| 118 | + ping_task_array = ping_start(ue_attach_info_dict, fivegc, ping_count) |
| 119 | + |
| 120 | + for _ in range(reestablishment_count): |
| 121 | + ue_reestablishment(ue_array) |
| 122 | + time.sleep(reestablishment_interval) |
| 123 | + |
| 124 | + ping_wait_until_finish(ping_task_array) |
| 125 | + |
| 126 | + stop(ue_array, gnb, fivegc, retina_data, warning_as_errors=warning_as_errors) |
0 commit comments