Commit 25ffc78c authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Add pluggable KPI types and implement testing framework for KPI descriptors

- Introduced new KPI sample types: PRE-FEC BER and Received Power.
- Created testing scripts for KPI descriptor creation and validation.
- Updated TODO list with tasks related to optical integration and KPI management.
parent 805d1f1b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -75,4 +75,8 @@ enum KpiSampleType {

    KPISAMPLETYPE_INT_IS_DROP        = 2201;
    KPISAMPLETYPE_INT_DROP_REASON    = 2202;

    // PLUGGABLES
    KPISAMPLETYPE_PRE_FEC_BER              = 2301;
    KPISAMPLETYPE_RECEIVED_POWER_PLUGGABLE = 2302;
}
+26 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


PROJECTDIR=`pwd`
cd $PROJECTDIR/src


# RCFILE=$PROJECTDIR/coverage/.coveragerc
CRDB_SQL_ADDRESS=$(kubectl get service cockroachdb-public --namespace crdb -o 'jsonpath={.spec.clusterIP}')
export CRDB_URI="cockroachdb://tfs:tfs123@${CRDB_SQL_ADDRESS}:26257/tfs_kpi_mgmt?sslmode=require"

python3 -m pytest --log-level=DEBUG --log-cli-level=DEBUG --verbose \
    tests/ecoc26_pluggables/descriptors/kpi_manager/create_kpi_descriptor.py::test_SetKpiDescriptor_PRE_FEC_BER
+37 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import uuid
from common.proto import kpi_manager_pb2
from common.proto.kpi_sample_types_pb2 import KpiSampleType


def create_kpi_descriptor_PRE_FEC_BER_request():
    _create_kpi_request                                    = kpi_manager_pb2.KpiDescriptor()
    # _create_kpi_request.kpi_id.kpi_id.uuid                 = str(uuid.uuid4())
    _create_kpi_request.kpi_id.kpi_id.uuid                 = "6e22f180-ba28-4641-b190-2287bf448888"
    _create_kpi_request.kpi_description                    = "Pluggable KPI PRE-FEC BER descriptor for testing purposes"
    _create_kpi_request.kpi_sample_type                    = KpiSampleType.KPISAMPLETYPE_PRE_FEC_BER
    _create_kpi_request.device_id.device_uuid.uuid         = str(uuid.uuid4())  # Add Device UUID here
    return _create_kpi_request

def create_kpi_descriptor_RECEIVED_POWER_request():
    _create_kpi_request                                    = kpi_manager_pb2.KpiDescriptor()
    # _create_kpi_request.kpi_id.kpi_id.uuid                 = str(uuid.uuid4())
    _create_kpi_request.kpi_id.kpi_id.uuid                 = "6e22f180-ba28-4641-b190-2287bf448888"
    _create_kpi_request.kpi_description                    = "Pluggable KPI Received power descriptor for testing purposes"
    _create_kpi_request.kpi_sample_type                    = KpiSampleType.KPISAMPLETYPE_RECEIVED_POWER_PLUGGABLE
    _create_kpi_request.device_id.device_uuid.uuid         = str(uuid.uuid4())  # Add Device UUID here
    return _create_kpi_request
+92 −0
Original line number Diff line number Diff line
import logging
import os, pytest
from typing import Union

from common.Constants import ServiceNameEnum
from common.Settings import ( 
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_service_port_grpc)
from common.tests.MockServicerImpl_Context import MockServicerImpl_Context
from common.proto.context_pb2_grpc import add_ContextServiceServicer_to_server
from common.tools.service.GenericGrpcService import GenericGrpcService

from kpi_manager.service.KpiManagerService import KpiManagerService
from kpi_manager.client.KpiManagerClient import KpiManagerClient
from tests.ecoc26_pluggables.descriptors.Kpi_messages import create_kpi_descriptor_PRE_FEC_BER_request, create_kpi_descriptor_RECEIVED_POWER_request
from common.proto.kpi_manager_pb2 import KpiId


LOGGER = logging.getLogger(__name__)


###########################
# DUMMY KPI SERVICE AND CLIENT FOR TESTING
###########################

LOCAL_HOST = '127.0.0.1'

KPIMANAGER_SERVICE_PORT = get_service_port_grpc(ServiceNameEnum.KPIMANAGER)  # type: ignore
os.environ[get_env_var_name(ServiceNameEnum.KPIMANAGER, ENVVAR_SUFIX_SERVICE_HOST     )] = str(LOCAL_HOST)
os.environ[get_env_var_name(ServiceNameEnum.KPIMANAGER, ENVVAR_SUFIX_SERVICE_PORT_GRPC)] = str(KPIMANAGER_SERVICE_PORT)

LOGGER = logging.getLogger(__name__)

class MockContextService(GenericGrpcService):
    def __init__(self, bind_port: Union[str, int]) -> None:
        super().__init__(bind_port, LOCAL_HOST, enable_health_servicer=False, cls_name='MockService')

    # pylint: disable=attribute-defined-outside-init
    def install_servicers(self):
        self.context_servicer = MockServicerImpl_Context()
        add_ContextServiceServicer_to_server(self.context_servicer, self.server)

@pytest.fixture(scope='session')
def kpi_manager_service():
    LOGGER.info('Initializing KpiManagerService...')
    _service = KpiManagerService()
    _service.start()

    # yield the server, when test finishes, execution will resume to stop it
    LOGGER.info('Yielding KpiManagerService...')
    yield _service

    LOGGER.info('Terminating KpiManagerService...')
    _service.stop()

    LOGGER.info('Terminated KpiManagerService...')


@pytest.fixture(scope='session')
def kpi_manager_client(kpi_manager_service : KpiManagerService): # pylint: disable=redefined-outer-name,unused-argument
    LOGGER.info('Initializing KpiManagerClient...')
    _client = KpiManagerClient()

    # yield the server, when test finishes, execution will resume to stop it
    LOGGER.info('Yielding KpiManagerClient...')
    yield _client

    LOGGER.info('Closing KpiManagerClient...')
    _client.close()

    LOGGER.info('Closed KpiManagerClient...')

##################################################
# Prepare Environment, should be the first test
##################################################


def test_SetKpiDescriptor_PRE_FEC_BER(kpi_manager_client):
    LOGGER.info(" >>> test_SetKpiDescriptor: START <<< ")
    response = kpi_manager_client.SetKpiDescriptor(
        create_kpi_descriptor_PRE_FEC_BER_request()
    )
    LOGGER.info("Response gRPC message object: {:}".format(response))
    assert isinstance(response, KpiId)

def test_SetKpiDescriptor_RECEIVED_POWER(kpi_manager_client):
    LOGGER.info(" >>> test_SetKpiDescriptor: START <<< ")
    response = kpi_manager_client.SetKpiDescriptor(
        create_kpi_descriptor_RECEIVED_POWER_request()
    )
    LOGGER.info("Response gRPC message object: {:}".format(response))
    assert isinstance(response, KpiId)
+38 −0
Original line number Diff line number Diff line

- Others
    1. VPN setup --> DONE 
    2. Routers --> IP and Ports Port: 2023
    3. SSH access --> okay
    4. XML example files : Activate and deactivating. 
    5. gNMI server on the device
    6. NETCONF collector for the TFS (Capabilites, GET method)

- SBI
    1. Topology --> 2 router (a hub and 4 leaves) --> DONE.
    2. XML Template Confirmation (Variables to enter in template) --> Provided by Margita
    3. Running XML for leaves and hubs --> pending...
    4. Do a manual test, if possible. (hub or leave or both) --> pending...

- Optical Integration with Closed-loop Operations
    1. Is Telemetry and KPI service running? --> DONE
    2. KPI Manager
        - Define KPI messages
        - Create KPI messages
        - Verify the KPI Descriptor creation
    3. Telemtery Service
        - Define Collector messages
        - Create Collector
        - Start Collector
    4. Run telemetry service
        - Create a Telemetry service definition
        - Run Telemtery service
        - Confirm the streaming of telemetry data
    5. Automation Service
        - Create Automation JSON input config file (threshold values)
        - Run Automation service
        - Confirm it detects the failure and triggers the action
    6. Optical Controller Service
        - Define an action (Forward the Notification to Orch. via NBI)
        - Attach action with Automation service
        - test to confirm it forwards the notification