Commit 67714b6d authored by Georgios P. Katsikas's avatar Georgios P. Katsikas
Browse files

feat: initial stages of the 1st e2e P4 test

parent 6c3e4c4c
Loading
Loading
Loading
Loading
+71 −0
Changes for src/tests/p4-end-to-end/.gitlab-ci.yml: 71 added lines, 0 removed lines.
Original line number Diff line number Diff line
stages:
  - test_checkout
  - tfs_deploy
  - run_tests
  - cleanup

variables:
  TEST_NAME: 'p4-end-to-end'
  TFS_K8S_NAMESPACE: "tfs"     # has to be identical with the namespace in deploy_specs.sh
  TFS_DEPLOY_TIMEOUT: "300s"

  MININET_TESTING_DIR: "${CI_PROJECT_DIR}/mininet-testing"
  MININET_TESTING_BRANCH: develop
  REQ_COMPONENTS_FILE: "${CI_PROJECT_DIR}/requested-components.txt"

clone_mininet_testing:
  stage: test_checkout

  script:
    - git clone --quiet https://labs.etsi.org/rep/tfs/mdg-dataplane-emulation/mininet/mininet-testing.git "${MININET_TESTING_DIR}"
    - cd "${MININET_TESTING_DIR}"
    - git checkout --quiet "${MININET_TESTING_BRANCH}"
    - "${MININET_TESTING_DIR}/common/ci/collect-tfs-components.sh" > "${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}"
    - cat "${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}"
  artifacts:
    paths:
      - mininet-testing/
      - ${REQ_COMPONENTS_FILE}
    expire_in: 1 hour
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'

deploy_tfs_once:
  stage: deploy_tfs
  needs: ["clone_mininet_testing"]
  script:
    - export REQUESTED_COMPONENTS="$(cat ${REQ_COMPONENTS_FILE})"
    - source src/tests/${TEST_NAME}/deploy_specs.sh
    - bash scripts/ci_prepare_microk8s_storage_registry.sh
    - source scripts/ci_apply_deploy_specs_overrides.sh
    - ./deploy/crdb.sh
    - ./deploy/nats.sh
    - ./deploy/kafka.sh
    - ./deploy/tfs.sh
    - ./deploy/show.sh
    - kubectl --namespace "$TFS_K8S_NAMESPACE" wait --for=condition=Ready pods --all --timeout=300s
  
  rules:
      - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'

run_all_tests:
  stage: run_tests
  needs: ["deploy_tfs_once"]
  script:
    - echo "Test invoked"

cleanup:
  stage: cleanup
  when: always
  script:
    - kubectl delete namespaces ${TFS_K8S_NAMESPACE} || true
    - bash scripts/ci_cleanup_gitlab_runner.sh

  rules:
      - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
    artifacts:
        when: always
        reports:
          junit: ./src/tests/${TEST_NAME}/report_*.xml
        paths:
          - ./src/tests/${TEST_NAME}/logs/*
+139 −0
Changes for src/tests/p4-end-to-end/deploy_specs.sh: 139 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/bash
# controller/src/tests/p4-end-to-end/deploy_specs.sh
#
# TFS-ONCE deploy config for the p4-end-to-end test suite. Adapted from
# src/tests/ryu-openflow/deploy_specs.sh's own template and ordering, but
# TFS_COMPONENTS is computed dynamically as the UNION of every test's own
# (much simpler) deploy_specs.sh in the mininet-testing repo, rather than
# a human hand-toggling the commented blocks the reference file has.
#
# This is the ONE place that knows TFS's component dependency order
# (e.g. opticalcontroller/qkd_app must be inserted immediately before
# "service", not just appended) -- mininet-testing's own
# collect-tfs-components.sh deliberately does NOT reimplement this; it
# only computes the requested SET. Keeping the ordering logic here, once,
# is what stops the two repos' copies of "how TFS components depend on
# each other" from silently drifting apart.
#
# REQUESTED_COMPONENTS (space-separated) must already be exported before
# this file is sourced -- see .gitlab-ci.yml's deploy_tfs_once job, which
# runs mininet-testing/common/ci/collect-tfs-components.sh and exports
# its output as REQUESTED_COMPONENTS before sourcing this file.

: "${REQUESTED_COMPONENTS:?REQUESTED_COMPONENTS must be exported before sourcing this file (see collect-tfs-components.sh in mininet-testing MDG repo)}"

_has_component() {
    # $1: component name to test for membership in REQUESTED_COMPONENTS
    [[ " ${REQUESTED_COMPONENTS} " == *" $1 "* ]]
}

# ----- TeraFlowSDN ------------------------------------------------------------

export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"

# Base + optional component blocks, gated on REQUESTED_COMPONENTS instead
# of a human uncommenting lines -- same set of blocks, same order, as the
# ryu-openflow reference.
TFS_COMPONENTS=""
for c in context device pathcomp service slice nbi webui; do
    _has_component "$c" && TFS_COMPONENTS="${TFS_COMPONENTS} ${c}"
done

for c in kpi_manager kpi_value_writer kpi_value_api telemetry; do
    _has_component "$c" && TFS_COMPONENTS="${TFS_COMPONENTS} ${c}"
done

for c in analytics policy automation; do
    _has_component "$c" && TFS_COMPONENTS="${TFS_COMPONENTS} ${c}"
done

_has_component qos_profile   && TFS_COMPONENTS="${TFS_COMPONENTS} qos_profile"
_has_component bgpls_speaker && TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker"

# opticalcontroller must precede "service" -- same insertion trick as the
# reference, gated on the union instead of always-on-when-uncommented.
if _has_component opticalcontroller && [[ "$TFS_COMPONENTS" == *" service"* ]]; then
    BEFORE="${TFS_COMPONENTS% service*}"
    AFTER="${TFS_COMPONENTS#* service}"
    TFS_COMPONENTS="${BEFORE} opticalcontroller service ${AFTER}"
fi

_has_component ztp    && TFS_COMPONENTS="${TFS_COMPONENTS} ztp"

for c in dbscanserving opticalattackmitigator opticalattackdetector opticalattackmanager; do
    _has_component "$c" && TFS_COMPONENTS="${TFS_COMPONENTS} ${c}"
done

for c in l3_attackmitigator l3_centralizedattackdetector; do
    _has_component "$c" && TFS_COMPONENTS="${TFS_COMPONENTS} ${c}"
done

_has_component te               && TFS_COMPONENTS="${TFS_COMPONENTS} te"
_has_component forecaster       && TFS_COMPONENTS="${TFS_COMPONENTS} forecaster"
_has_component e2e_orchestrator && TFS_COMPONENTS="${TFS_COMPONENTS} e2e_orchestrator"
_has_component vnt_manager      && TFS_COMPONENTS="${TFS_COMPONENTS} vnt_manager"

if _has_component interdomain || _has_component dlt; then
    TFS_COMPONENTS="${TFS_COMPONENTS} interdomain dlt"
    export KEY_DIRECTORY_PATH="src/dlt/gateway/keys/priv_sk"
    export CERT_DIRECTORY_PATH="src/dlt/gateway/keys/cert.pem"
    export TLS_CERT_PATH="src/dlt/gateway/keys/ca.crt"
fi

# qkd_app must precede "service", same insertion trick as opticalcontroller.
if _has_component qkd_app && [[ "$TFS_COMPONENTS" == *" service"* ]]; then
    BEFORE="${TFS_COMPONENTS% service*}"
    AFTER="${TFS_COMPONENTS#* service}"
    TFS_COMPONENTS="${BEFORE} qkd_app service ${AFTER}"
fi

_has_component load_generator && TFS_COMPONENTS="${TFS_COMPONENTS} load_generator"

export TFS_COMPONENTS="$(echo ${TFS_COMPONENTS})"   # squeeze extra whitespace from the insertion tricks above
echo "p4-end-to-end: deploying TFS_COMPONENTS=\"${TFS_COMPONENTS}\""

export TFS_IMAGE_TAG="dev"
export TFS_K8S_NAMESPACE="tfs"
export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml"
export TFS_GRAFANA_PASSWORD="admin123+"
export TFS_SKIP_BUILD=""

# ----- CockroachDB / NATS / QuestDB / Observability / Kafka -------------------
# Unchanged from the ryu-openflow reference -- infrastructure defaults,
# not per-test decisions, so there's no union to compute here.

export CRDB_NAMESPACE="crdb"
export CRDB_EXT_PORT_SQL="26257"
export CRDB_EXT_PORT_HTTP="8081"
export CRDB_USERNAME="tfs"
export CRDB_PASSWORD="tfs123"
export CRDB_DEPLOY_MODE="single"
export CRDB_DROP_DATABASE_IF_EXISTS="YES"
export CRDB_REDEPLOY=""

export NATS_NAMESPACE="nats"
export NATS_EXT_PORT_CLIENT="4222"
export NATS_EXT_PORT_HTTP="8222"
export NATS_DEPLOY_MODE="single"
export NATS_REDEPLOY=""

export QDB_NAMESPACE="qdb"
export QDB_EXT_PORT_SQL="8812"
export QDB_EXT_PORT_ILP="9009"
export QDB_EXT_PORT_HTTP="9000"
export QDB_USERNAME="admin"
export QDB_PASSWORD="quest"
export QDB_TABLE_MONITORING_KPIS="tfs_monitoring_kpis"
export QDB_TABLE_SLICE_GROUPS="tfs_slice_groups"
export QDB_DROP_TABLES_IF_EXIST="YES"
export QDB_REDEPLOY=""

export KFK_NAMESPACE="kafka"
export KFK_SERVER_PORT="9092"
export KFK_DEPLOY_MODE="single"
export KFK_REDEPLOY=""

export TSDB_DEPLOY_MODE="single"

export PROM_EXT_PORT_HTTP="9090"
export GRAF_EXT_PORT_HTTP="3000"