Commit 6a467aa2 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

feat(pluggables): ECOC26-Add environment variable handling for collector...

feat(pluggables): ECOC26-Add environment variable handling for collector duration and interval; update ZSM test job to monitor leaf metrics
parent a420c390
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os, uuid, random
import os, uuid
from uuid import UUID
from common.DeviceTypes import DeviceTypeEnum
from common.proto import kpi_manager_pb2
@@ -50,6 +50,18 @@ def _tfs_uuid(str_uuid_or_name: str) -> str:
    except (TypeError, ValueError, AttributeError):
        return str(uuid.uuid5(_TFS_NAMESPACE_UUID, str_uuid_or_name))

def _get_positive_float_env(env_name, default_value):
    raw_value = os.environ.get(env_name)
    if raw_value is None:
        return default_value
    try:
        value = float(raw_value)
    except ValueError as exc:
        raise ValueError("{:s} must be a float, got {!r}".format(env_name, raw_value)) from exc
    if value <= 0:
        raise ValueError("{:s} must be > 0, got {:s}".format(env_name, str(value)))
    return value

ROUTER_HUB_DEVICE_UUID  = _tfs_uuid(ROUTER_HUB_DEVICE_ID)
ROUTER_LEAF_DEVICE_UUID = _tfs_uuid(ROUTER_LEAF_DEVICE_ID)

@@ -138,8 +150,10 @@ def _create_collector_request(collector_uuid, kpi_uuid):
    _create_collector_request                                = telemetry_frontend_pb2.Collector()
    _create_collector_request.collector_id.collector_id.uuid = collector_uuid
    _create_collector_request.kpi_id.kpi_id.uuid             = kpi_uuid
    _create_collector_request.duration_s                     = float(random.randint(80, 90))
    _create_collector_request.interval_s                     = float(random.randint(6,8))
    _create_collector_request.duration_s                     = _get_positive_float_env(
        "ECOC26_COLLECTOR_DURATION_S", 180.0)
    _create_collector_request.interval_s                     = _get_positive_float_env(
        "ECOC26_COLLECTOR_INTERVAL_S", 5.0)
    _create_collector_request.coll_meta_info.device_driver   = DeviceDriverEnum.DEVICEDRIVER_NETCONF_OC_PLUGGABLE
    _create_collector_request.coll_meta_info.device_type     = DeviceTypeEnum.PACKET_ROUTER.value
    return _create_collector_request
+22 −5
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ spec:
            - --log-level=DEBUG
            - --log-cli-level=DEBUG
            - --verbose
            - src/tests/ecoc26_pluggables/tests/test_zsm_failure_notification.py
            - src/tests/ecoc26_pluggables/tests/test_zsm_failure_notify_leaf.py
          env:
            # PYTHONPATH resolution order:
            #   1. /var/teraflow              → compiled common.proto stubs,
@@ -64,6 +64,14 @@ spec:
            #   3. /home/cttc/tfs-ctrl        → src.tests.ecoc26_pluggables.*
            - name: PYTHONPATH
              value: "/var/teraflow:/home/cttc/tfs-ctrl/src:/home/cttc/tfs-ctrl"
            # Select the leaf metric to monitor: RECEIVED_POWER or PRE_FEC_BER.
            - name: ECOC26_ZSM_MONITOR_METRIC
              value: "PRE_FEC_BER"
            # Collector timing used by all ECOC26 pluggable KPI collectors.
            - name: ECOC26_COLLECTOR_DURATION_S
              value: "180"
            - name: ECOC26_COLLECTOR_INTERVAL_S
              value: "5"
            # Use the real data-plane topology descriptor
            - name: TFS_TOPOLOGY_DESCRIPTOR
              value: "ecoc26_topo_devices_actual_data_plane.json"
@@ -77,12 +85,21 @@ spec:
              value: "channel-5"
            - name: ECOC26_LEAF_OPTICAL_CHANNEL
              value: "channel-5"
            # Expected real received-power ranges. These checks ensure the hub
            # and leaf collectors are both producing samples, not just KPI IDs.
            # Expected real received-power ranges. This leaf-only test consumes
            # the leaf value; the hub value is kept for the original hub+leaf flow.
            - name: ECOC26_HUB_RECEIVED_POWER_RANGE
              value: "-80,-30"
              value: "-24, 0"
            - name: ECOC26_LEAF_RECEIVED_POWER_RANGE
              value: "-30,0"
              value: "-24, 0"
            # Analyzer alarm threshold range for the leaf aggregated
            # received-power KPI.
            - name: ECOC26_LEAF_RECEIVED_POWER_ALARM_RANGE
              value: "-24, 0"
            # Valid and alarm threshold ranges for PRE-FEC BER if selected.
            - name: ECOC26_LEAF_PRE_FEC_BER_RANGE
              value: "0.001, 0.0165"
            - name: ECOC26_LEAF_PRE_FEC_BER_ALARM_RANGE
              value: "0.001, 0.0165"
          volumeMounts:
            - name: tfs-source
              mountPath: /home/cttc/tfs-ctrl