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

GitLab CI/CD pipeline - OFC'24:

- Fixed deployment of dataplane node agents
- Added testsfor bidir and unidir services to Dockerfile
- Updated descriptors in functional tests
- Separated functional tests for bidir and unidir services
- Removed unneeded KPI-related test methods
parent 3e6e31fd
Loading
Loading
Loading
Loading
+41 −1
Original line number Diff line number Diff line
@@ -45,16 +45,55 @@ end2end_test ofc24:
  #  - build ofc24
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker rm -f na-t1 na-t2 na-r1 na-r2
    - docker network rm na-br

  script:
    # Download Docker image to run the test
    - docker pull "${CI_REGISTRY_IMAGE}/${TEST_NAME}:latest"
    - docker pull asgamb1/oc23bgp.img:latest
    - docker pull asgamb1/flexscale-node.img:latest

    # Check MicroK8s is ready
    - microk8s status --wait-ready
    - kubectl get pods --all-namespaces

    # Deploy Optical Device Node Agents
    - ./src/tests/${TEST_NAME}/deploy-node-agents.sh
    - >
      docker network create -d bridge --subnet=172.254.253.0/24 --gateway=172.254.253.254 \
      --ip-range=172.254.253.0/24 na-br
    - >
      docker run -dit --init --name na-t1 --network=na-br --ip 172.254.253.101 \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-tp.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_t1.xml:/confd/examples.confd/OC23/platform.xml" \
      asgamb1/oc23bgp.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh
    - >
      docker run -dit --init --name na-t2 --network=na-br --ip 172.254.253.102 \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-tp.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_t2.xml:/confd/examples.confd/OC23/platform.xml" \
      asgamb1/oc23bgp.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh
    - >
      docker run -dit --init --name na-r1 --network=na-br --ip 172.254.253.201 \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-mg-on.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_r1.xml:/confd/examples.confd/OC23/platform.xml" \
      asgamb1/flexscale-node.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh
    - >
      docker run -dit --init --name na-r2 --network=na-br --ip 172.254.253.202 \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-mg-on.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
      --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_r2.xml:/confd/examples.confd/OC23/platform.xml" \
      asgamb1/flexscale-node.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh


    # Wait for initialization of Optical Device Node Agents
    - sleep 3
    - docker ps -a
    - while ! docker logs na-t1 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
    - while ! docker logs na-t2 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
    - while ! docker logs na-r1 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
    - while ! docker logs na-r2 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
    - sleep 3
    - docker ps -a


    # Configure TeraFlowSDN deployment
    # Uncomment if DEBUG log level is needed for the components
@@ -89,6 +128,7 @@ end2end_test ofc24:
      --volume "$PWD/tfs_runtime_env_vars.sh:/var/teraflow/tfs_runtime_env_vars.sh"
      --volume "$PWD/src/tests/${TEST_NAME}:/opt/results"
      $CI_REGISTRY_IMAGE/${TEST_NAME}:latest

  after_script:
    # Dump TeraFlowSDN component logs
    - source src/tests/${TEST_NAME}/deploy_specs.sh
+6 −4
Original line number Diff line number Diff line
@@ -93,8 +93,10 @@ RUN tee ./run_tests.sh <<EOF
source /var/teraflow/tfs_runtime_env_vars.sh
export PYTHONPATH=/var/teraflow
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_bootstrap.py             --junitxml=/opt/results/report_bootstrap.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_create_service.py --junitxml=/opt/results/report_create_service.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_delete_service.py --junitxml=/opt/results/report_delete_service.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_create_service_unidir.py --junitxml=/opt/results/report_create_service_unidir.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_delete_service_unidir.py --junitxml=/opt/results/report_delete_service_unidir.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_create_service_bidir.py  --junitxml=/opt/results/report_create_service_bidir.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_delete_service_bidir.py  --junitxml=/opt/results/report_delete_service_bidir.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc24/tests/test_functional_cleanup.py               --junitxml=/opt/results/report_cleanup.xml
EOF
RUN chmod ug+x ./run_tests.sh
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ from tests.Fixtures import context_client, device_client # pylint: disable=unuse
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)

DESCRIPTOR_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'descriptors_topology.json')
DESCRIPTOR_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'descriptors', 'topology.json')
ADMIN_CONTEXT_ID = ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))

def test_scenario_bootstrap(
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ from tests.Fixtures import context_client, device_client # pylint: disable=un
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)

DESCRIPTOR_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'descriptors_topology.json')
DESCRIPTOR_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'descriptors', 'topology.json')
ADMIN_CONTEXT_ID = ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))

def test_scenario_cleanup(
+4 −38
Original line number Diff line number Diff line
@@ -12,15 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging, os, random
import logging, os
from common.Constants import DEFAULT_CONTEXT_NAME
from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum
from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.proto.context_pb2 import ContextId, ServiceTypeEnum
from common.tools.descriptor.Loader import DescriptorLoader
from common.tools.grpc.Tools import grpc_message_to_json_string
from common.tools.object_factory.Context import json_context_id
from context.client.ContextClient import ContextClient
from monitoring.client.MonitoringClient import MonitoringClient
from tests.Fixtures import context_client, monitoring_client                    # pylint: disable=unused-import
from tests.tools.mock_osm.MockOSM import MockOSM
from .Fixtures import osm_wim                                                   # pylint: disable=unused-import
@@ -29,10 +27,10 @@ from .Objects import WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)

DESCRIPTOR_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'descriptors_emulated.json')
DESCRIPTOR_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'descriptors', 'service-bidir.json')
ADMIN_CONTEXT_ID = ContextId(**json_context_id(DEFAULT_CONTEXT_NAME))

def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name
def test_service_creation_bidir(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name
    # Load descriptors and validate the base scenario
    descriptor_loader = DescriptorLoader(descriptors_file=DESCRIPTOR_FILE, context_client=context_client)
    descriptor_loader.validate()
@@ -68,35 +66,3 @@ def test_service_creation(context_client : ContextClient, osm_wim : MockOSM): #
        else:
            str_service = grpc_message_to_json_string(service)
            raise Exception('Unexpected ServiceType: {:s}'.format(str_service))


def test_scenario_kpi_values_created(
    monitoring_client: MonitoringClient,    # pylint: disable=redefined-outer-name
) -> None:
    """
    This test validates that KPI values have been inserted into the monitoring database.
    We short k KPI descriptors to test.
    """
    response = monitoring_client.GetKpiDescriptorList(Empty())
    kpi_descriptors = random.choices(response.kpi_descriptor_list, k=2)

    for kpi_descriptor in kpi_descriptors:
        MSG = 'KPI(kpi_uuid={:s}, device_uuid={:s}, endpoint_uuid={:s}, service_uuid={:s}, kpi_sample_type={:s})...'
        LOGGER.info(MSG.format(
            str(kpi_descriptor.kpi_id.kpi_id.uuid), str(kpi_descriptor.device_id.device_uuid.uuid),
            str(kpi_descriptor.endpoint_id.endpoint_uuid.uuid), str(kpi_descriptor.service_id.service_uuid.uuid),
            str(KpiSampleType.Name(kpi_descriptor.kpi_sample_type))))
        response = monitoring_client.GetInstantKpi(kpi_descriptor.kpi_id)
        kpi_uuid = response.kpi_id.kpi_id.uuid
        assert kpi_uuid == kpi_descriptor.kpi_id.kpi_id.uuid
        kpi_value_type = response.kpi_value.WhichOneof('value')
        if kpi_value_type is None:
            MSG = '  KPI({:s}): No instant value found'
            LOGGER.warning(MSG.format(str(kpi_uuid)))
        else:
            kpi_timestamp = response.timestamp.timestamp
            assert kpi_timestamp > 0
            assert kpi_value_type == 'floatVal'
            kpi_value = getattr(response.kpi_value, kpi_value_type)
            MSG = '  KPI({:s}): timestamp={:s} value_type={:s} value={:s}'
            LOGGER.info(MSG.format(str(kpi_uuid), str(kpi_timestamp), str(kpi_value_type), str(kpi_value)))
Loading