Commit d2dc573e authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/load-gen-add-device-endpoint-selectors' into 'develop'

Load Generator: filter candidate src/dst devices and endpoints

See merge request !96
parents 51a32b58 ff7c68fe
Loading
Loading
Loading
Loading
+13 −11
Original line number Original line Diff line number Diff line
@@ -48,17 +48,19 @@ message ScalarOrRange {
message Parameters {
message Parameters {
  uint64 num_requests = 1;  // if == 0, generate infinite requests
  uint64 num_requests = 1;  // if == 0, generate infinite requests
  repeated RequestTypeEnum request_types = 2;
  repeated RequestTypeEnum request_types = 2;
  float offered_load = 3;
  string device_regex = 3;      // Only devices and endpoints matching the regex expression will be considered as
  float holding_time = 4;
  string endpoint_regex = 4;    // source-destination candidates for the requests generated.
  float inter_arrival_time = 5;
  float offered_load = 5;
  repeated ScalarOrRange availability = 6;    // one from the list is selected
  float holding_time = 6;
  repeated ScalarOrRange capacity_gbps = 7;   // one from the list is selected
  float inter_arrival_time = 7;
  repeated ScalarOrRange e2e_latency_ms = 8;  // one from the list is selected
  repeated ScalarOrRange availability = 8;    // One from the list is selected to populate the constraint
  uint32 max_workers = 9;
  repeated ScalarOrRange capacity_gbps = 9;   // One from the list is selected to populate the constraint
  bool do_teardown = 10;
  repeated ScalarOrRange e2e_latency_ms = 10; // One from the list is selected to populate the constraint
  bool dry_mode = 11;
  uint32 max_workers = 11;
  bool record_to_dlt = 12;
  bool do_teardown = 12;
  string dlt_domain_id = 13;
  bool dry_mode = 13;
  bool record_to_dlt = 14;
  string dlt_domain_id = 15;
}
}


message Status {
message Status {
+2 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,8 @@ def main():
            RequestType.SLICE_L2NM,
            RequestType.SLICE_L2NM,
            RequestType.SLICE_L3NM,
            RequestType.SLICE_L3NM,
        ],
        ],
        device_regex=r'.+',
        endpoint_regex=r'.+',
        offered_load  = 50,
        offered_load  = 50,
        holding_time  = 10,
        holding_time  = 10,
        availability_ranges   = [[0.0, 99.9999]],
        availability_ranges   = [[0.0, 99.9999]],
+21 −4
Original line number Original line Diff line number Diff line
@@ -20,16 +20,27 @@ from load_generator.tools.ListScalarRange import Type_ListScalarRange


class Parameters:
class Parameters:
    def __init__(
    def __init__(
        self, num_requests : int, request_types : List[str], offered_load : Optional[float] = None,
        self,
        inter_arrival_time : Optional[float] = None, holding_time : Optional[float] = None,
        num_requests : int,
        request_types : List[str],
        device_regex : Optional[str] = None,
        endpoint_regex : Optional[str] = None,
        offered_load : Optional[float] = None,
        inter_arrival_time : Optional[float] = None,
        holding_time : Optional[float] = None,
        availability_ranges : Type_ListScalarRange = DEFAULT_AVAILABILITY_RANGES,
        availability_ranges : Type_ListScalarRange = DEFAULT_AVAILABILITY_RANGES,
        capacity_gbps_ranges : Type_ListScalarRange = DEFAULT_CAPACITY_GBPS_RANGES,
        capacity_gbps_ranges : Type_ListScalarRange = DEFAULT_CAPACITY_GBPS_RANGES,
        e2e_latency_ms_ranges : Type_ListScalarRange = DEFAULT_E2E_LATENCY_MS_RANGES,
        e2e_latency_ms_ranges : Type_ListScalarRange = DEFAULT_E2E_LATENCY_MS_RANGES,
        max_workers : int = DEFAULT_MAX_WORKERS, do_teardown : bool = True, dry_mode : bool = False,
        max_workers : int = DEFAULT_MAX_WORKERS,
        record_to_dlt : bool = False, dlt_domain_id : Optional[str] = None
        do_teardown : bool = True,
        dry_mode : bool = False,
        record_to_dlt : bool = False,
        dlt_domain_id : Optional[str] = None
    ) -> None:
    ) -> None:
        self._num_requests = num_requests
        self._num_requests = num_requests
        self._request_types = request_types
        self._request_types = request_types
        self._device_regex = r'.*' if (device_regex is None or len(device_regex) == 0) else device_regex
        self._endpoint_regex = r'.*' if (endpoint_regex is None or len(endpoint_regex) == 0) else endpoint_regex
        self._offered_load = offered_load
        self._offered_load = offered_load
        self._inter_arrival_time = inter_arrival_time
        self._inter_arrival_time = inter_arrival_time
        self._holding_time = holding_time
        self._holding_time = holding_time
@@ -62,6 +73,12 @@ class Parameters:
    @property
    @property
    def request_types(self): return self._request_types
    def request_types(self): return self._request_types


    @property
    def device_regex(self): return self._device_regex

    @property
    def endpoint_regex(self): return self._endpoint_regex

    @property
    @property
    def offered_load(self): return self._offered_load
    def offered_load(self): return self._offered_load


+11 −6
Original line number Original line Diff line number Diff line
@@ -83,13 +83,21 @@ class RequestGenerator:
            if self._parameters.record_to_dlt:
            if self._parameters.record_to_dlt:
                dlt_domain_id = TopologyId(**json_topology_id('dlt-perf-eval'))
                dlt_domain_id = TopologyId(**json_topology_id('dlt-perf-eval'))


            re_device = re.compile(r'^{:s}$'.format(self._parameters.device_regex))
            re_endpoint = re.compile(r'^{:s}$'.format(self._parameters.endpoint_regex))

            devices = context_client.ListDevices(Empty())
            devices = context_client.ListDevices(Empty())
            for device in devices.devices:
            for device in devices.devices:
                if self._parameters.record_to_dlt:
                    record_device_to_dlt(dlt_connector_client, dlt_domain_id, device.device_id)

                if re_device.match(device.name) is None: continue
                device_uuid = device.device_id.device_uuid.uuid
                device_uuid = device.device_id.device_uuid.uuid
                self._device_data[device_uuid] = grpc_message_to_json(device)
                self._device_data[device_uuid] = grpc_message_to_json(device)


                _endpoints = self._available_device_endpoints.setdefault(device_uuid, set())
                _endpoints = self._available_device_endpoints.setdefault(device_uuid, set())
                for endpoint in device.device_endpoints:
                for endpoint in device.device_endpoints:
                    if re_endpoint.match(endpoint.name) is None: continue
                    endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid
                    endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid
                    endpoints = self._device_endpoint_data.setdefault(device_uuid, dict())
                    endpoints = self._device_endpoint_data.setdefault(device_uuid, dict())
                    endpoints[endpoint_uuid] = grpc_message_to_json(endpoint)
                    endpoints[endpoint_uuid] = grpc_message_to_json(endpoint)
@@ -99,11 +107,11 @@ class RequestGenerator:
                    self._endpoint_ids_to_types.setdefault((device_uuid, endpoint_uuid), endpoint_type)
                    self._endpoint_ids_to_types.setdefault((device_uuid, endpoint_uuid), endpoint_type)
                    self._endpoint_types_to_ids.setdefault(endpoint_type, set()).add((device_uuid, endpoint_uuid))
                    self._endpoint_types_to_ids.setdefault(endpoint_type, set()).add((device_uuid, endpoint_uuid))


                if self._parameters.record_to_dlt:
                    record_device_to_dlt(dlt_connector_client, dlt_domain_id, device.device_id)

            links = context_client.ListLinks(Empty())
            links = context_client.ListLinks(Empty())
            for link in links.links:
            for link in links.links:
                if self._parameters.record_to_dlt:
                    record_link_to_dlt(dlt_connector_client, dlt_domain_id, link.link_id)

                for endpoint_id in link.link_endpoint_ids:
                for endpoint_id in link.link_endpoint_ids:
                    device_uuid = endpoint_id.device_id.device_uuid.uuid
                    device_uuid = endpoint_id.device_id.device_uuid.uuid
                    endpoint_uuid = endpoint_id.endpoint_uuid.uuid
                    endpoint_uuid = endpoint_id.endpoint_uuid.uuid
@@ -120,9 +128,6 @@ class RequestGenerator:
                    if endpoint_key not in endpoints_for_type: continue
                    if endpoint_key not in endpoints_for_type: continue
                    endpoints_for_type.discard(endpoint_key)
                    endpoints_for_type.discard(endpoint_key)


                    if self._parameters.record_to_dlt:
                        record_link_to_dlt(dlt_connector_client, dlt_domain_id, link.link_id)

    def dump_state(self) -> None:
    def dump_state(self) -> None:
        with self._lock:
        with self._lock:
            _endpoints = {
            _endpoints = {
+4 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,8 @@ class LoadGeneratorServiceServicerImpl(LoadGeneratorServiceServicer):
        self._parameters = LoadGen_Parameters(
        self._parameters = LoadGen_Parameters(
            num_requests          = request.num_requests,
            num_requests          = request.num_requests,
            request_types         = [REQUEST_TYPE_MAP[rt] for rt in request.request_types],
            request_types         = [REQUEST_TYPE_MAP[rt] for rt in request.request_types],
            device_regex          = request.device_regex,
            endpoint_regex        = request.endpoint_regex,
            offered_load          = request.offered_load if request.offered_load > 1.e-12 else None,
            offered_load          = request.offered_load if request.offered_load > 1.e-12 else None,
            holding_time          = request.holding_time if request.holding_time > 1.e-12 else None,
            holding_time          = request.holding_time if request.holding_time > 1.e-12 else None,
            inter_arrival_time    = request.inter_arrival_time if request.inter_arrival_time > 1.e-12 else None,
            inter_arrival_time    = request.inter_arrival_time if request.inter_arrival_time > 1.e-12 else None,
@@ -79,6 +81,8 @@ class LoadGeneratorServiceServicerImpl(LoadGeneratorServiceServicer):


        stat_pars = status.parameters                               # pylint: disable=no-member
        stat_pars = status.parameters                               # pylint: disable=no-member
        stat_pars.num_requests       = params.num_requests          # pylint: disable=no-member
        stat_pars.num_requests       = params.num_requests          # pylint: disable=no-member
        stat_pars.device_regex       = params.device_regex          # pylint: disable=no-member
        stat_pars.endpoint_regex     = params.endpoint_regex        # pylint: disable=no-member
        stat_pars.offered_load       = params.offered_load          # pylint: disable=no-member
        stat_pars.offered_load       = params.offered_load          # pylint: disable=no-member
        stat_pars.holding_time       = params.holding_time          # pylint: disable=no-member
        stat_pars.holding_time       = params.holding_time          # pylint: disable=no-member
        stat_pars.inter_arrival_time = params.inter_arrival_time    # pylint: disable=no-member
        stat_pars.inter_arrival_time = params.inter_arrival_time    # pylint: disable=no-member
Loading