Loading src/tests/p4-end-to-end/scripts/1-tests-clone.sh +11 −21 Changes for src/tests/p4-end-to-end/scripts/1-tests-clone.sh: 11 added lines, 21 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test bash 1-tests-clone.sh set -Eeuo pipefail : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" TFS_REPO_URL="https://labs.etsi.org/rep/tfs" TFS_CTRL_REPO_URL=${TFS_REPO_URL}"/controller" TFS_DP_MDG_REPO_URL=${TFS_REPO_URL}"/mdg-dataplane-emulation/mininet" MININET_TESTING_URL="${MININET_TESTING_URL:-${TFS_DP_MDG_REPO_URL}/mininet-testing.git}" MININET_TESTING_REF="${MININET_TESTING_REF:-${MININET_TESTING_BRANCH:-develop}}" MININET_TESTING_DIR="${MININET_TESTING_DIR:-${CI_PROJECT_DIR}/mininet-testing}" REQ_COMPONENTS_FILE="${REQ_COMPONENTS_FILE:-${CI_PROJECT_DIR}/requested-components.txt}" fail() { printf '$0: ERROR: %s\n' "$*" >&2; exit 1; } source "common.sh" # Some preconditions for the clone stage, which are expected to be set by the GitLab CI environment [[ -n "$MININET_TESTING_URL" ]] || fail 'MININET_TESTING_URL must not be empty' [[ -n "$MININET_TESTING_REF" ]] || fail 'MININET_TESTING_REF must not be empty' [[ "$MININET_TESTING_DIR" == /* ]] || MININET_TESTING_DIR="${CI_PROJECT_DIR}/${MININET_TESTING_DIR}" [[ "$REQ_COMPONENTS_FILE" == /* ]] || REQ_COMPONENTS_FILE="${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}" # Fail if the destination directory already exists, as it is expected to be created by this stage if [[ -e "$MININET_TESTING_DIR" ]]; then fail "destination already exists: $MININET_TESTING_DIR" fi # Create the parent directories for the destination directory and the requested components file, if they do not already exist mkdir -p "$(dirname "$MININET_TESTING_DIR")" "$(dirname "$REQ_COMPONENTS_FILE")" printf 'Cloning Mininet test suite\n' printf '\tRepository: %s\n' "$MININET_TESTING_URL" printf '\t Ref: %s\n' "$MININET_TESTING_REF" printf '\t Directory: %s\n' "$MININET_TESTING_DIR" git clone --quiet --no-checkout "$MININET_TESTING_URL" "$MININET_TESTING_DIR" || \ # Clone the Mininet test suite git clone -b "$MININET_TESTING_REF" --quiet "$MININET_TESTING_URL" "$MININET_TESTING_DIR" || \ fail "could not clone $MININET_TESTING_URL" git -C "$MININET_TESTING_DIR" fetch --quiet origin "$MININET_TESTING_REF" || \ fail "could not fetch ref '$MININET_TESTING_REF' from $MININET_TESTING_URL" # git -C "$MININET_TESTING_DIR" checkout --quiet --detach FETCH_HEAD || \ # fail "could not check out ref '$MININET_TESTING_REF'" # commit="$(git -C "$MININET_TESTING_DIR" rev-parse HEAD)" || fail 'could not read checked-out commit' # printf 'Selected ref: %s\nResulting commit: %s\n' "$MININET_TESTING_REF" "$commit" # Collect the TFS components requested by the test suite, and save them to a single env. file collector="${MININET_TESTING_DIR}/common/ci/collect-tfs-components.sh" [[ -f "$collector" ]] || fail "component collector not found: $collector" (cd "$MININET_TESTING_DIR" && bash "$collector") > "$REQ_COMPONENTS_FILE" || fail 'component collection failed' printf 'Requested components saved to: %s\n' "$REQ_COMPONENTS_FILE" (cd "$MININET_TESTING_DIR" && bash "$collector") > "$REQ_COMPONENTS_FILE" || fail 'TFS component collection failed' printf 'Requested TFS components saved to: %s\n' "$REQ_COMPONENTS_FILE" cat "$REQ_COMPONENTS_FILE" exit 0 src/tests/p4-end-to-end/scripts/2-tfs-deploy.sh +9 −7 Changes for src/tests/p4-end-to-end/scripts/2-tfs-deploy.sh: 9 added lines, 7 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test TEST_NAME=p4-end-to-end bash 2-tfs-deploy.sh set -Eeuo pipefail : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" : "${TEST_NAME:?TEST_NAME must identify a controller test under src/tests}" # TEST_NAME="${TEST_NAME:-"p4-end-to-end"}" TFS_K8S_NAMESPACE="${TFS_K8S_NAMESPACE:-tfs}" TFS_DEPLOY_TIMEOUT="${TFS_DEPLOY_TIMEOUT:-300s}" REQ_COMPONENTS_FILE="${REQ_COMPONENTS_FILE:-${CI_PROJECT_DIR}/requested-components.txt}" [[ "$REQ_COMPONENTS_FILE" == /* ]] || REQ_COMPONENTS_FILE="${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}" source "common.sh" fail() { printf '$0: ERROR: %s\n' "$*" >&2; exit 1; } # State created by the previous clone stage, and is passed into this process explicitly via the workspace file [[ "$REQ_COMPONENTS_FILE" == /* ]] || REQ_COMPONENTS_FILE="${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}" # Fail if the requested components file is missing, as it is required for deployment [[ -f "$REQ_COMPONENTS_FILE" ]] || fail "requested components file not found: $REQ_COMPONENTS_FILE" # A single env. file that aggregates TFS components collected from the tests folder cd "$CI_PROJECT_DIR" [[ -f "src/tests/${TEST_NAME}/deploy_specs.sh" ]] || fail "deploy specs not found: src/tests/${TEST_NAME}/deploy_specs.sh" # Pass the clone stage's output into this process explicitly via the workspace file. # Pass the clone stage's output into this process explicitly via the workspace file REQUESTED_COMPONENTS="$(<"$REQ_COMPONENTS_FILE")" export REQUESTED_COMPONENTS TFS_K8S_NAMESPACE TFS_DEPLOY_TIMEOUT # Deploy TFS components requested by the test suite, and wait for all pods to be ready source "src/tests/${TEST_NAME}/deploy_specs.sh" bash scripts/ci_prepare_microk8s_storage_registry.sh source scripts/ci_apply_deploy_specs_overrides.sh Loading src/tests/p4-end-to-end/scripts/3-tests-run.sh +8 −4 Changes for src/tests/p4-end-to-end/scripts/3-tests-run.sh: 8 added lines, 4 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test bash 3-tests-run.sh set -Eeuo pipefail : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" MININET_TESTING_DIR="${MININET_TESTING_DIR:-${CI_PROJECT_DIR}/mininet-testing}" [[ "$MININET_TESTING_DIR" == /* ]] || MININET_TESTING_DIR="${CI_PROJECT_DIR}/${MININET_TESTING_DIR}" TESTS_DIR="${MININET_TESTING_DIR}/tests" source "common.sh" fail() { printf '$0: ERROR: %s\n' "$*" >&2; exit 1; } # The workspace of this stage [[ "$MININET_TESTING_DIR" == /* ]] || MININET_TESTING_DIR="${CI_PROJECT_DIR}/${MININET_TESTING_DIR}" # A tests/ directory is expected to exist under the Mininet test suite, and contain one or more test scenarios [[ -d "$TESTS_DIR" ]] || fail "test suite directory not found: $TESTS_DIR" # Identify the test scenarios under the tests/ directory shopt -s nullglob scenarios=("$TESTS_DIR"/*) shopt -u nullglob ((${#scenarios[@]} > 0)) || fail "no test scenarios found under $TESTS_DIR" # Run each test scenario in turn, and fail if any of them fails for scenario in "${scenarios[@]}"; do [[ -d "$scenario" ]] || continue test_script="${scenario}/test.sh" Loading src/tests/p4-end-to-end/scripts/4-cleanup.sh +7 −1 Changes for src/tests/p4-end-to-end/scripts/4-cleanup.sh: 7 added lines, 1 removed line. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test bash 4-cleanup.sh set -Eeuo pipefail TFS_K8S_NAMESPACE="${TFS_K8S_NAMESPACE:-tfs}" : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" source "common.sh" # Delete the TFS namespace, if it exists, and ignore any errors printf 'Cleaning up namespace: %s\n' "$TFS_K8S_NAMESPACE" if command -v kubectl >/dev/null 2>&1; then kubectl delete namespace "$TFS_K8S_NAMESPACE" --wait=false || true Loading @@ -10,6 +15,7 @@ else printf '$0: kubectl is unavailable; skipping namespace deletion\n' >&2 fi # Cleanup the controller runner, if it exists if [[ -n "${CI_PROJECT_DIR:-}" && -f "${CI_PROJECT_DIR}/scripts/ci_cleanup_gitlab_runner.sh" ]]; then bash "${CI_PROJECT_DIR}/scripts/ci_cleanup_gitlab_runner.sh" else Loading src/tests/p4-end-to-end/scripts/common.sh +19 −0 Changes for src/tests/p4-end-to-end/scripts/common.sh: 19 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash CI_PROJECT_DIR=${CI_PROJECT_DIR:-"/home/ubuntu/test"} TFS_REPO_URL="https://labs.etsi.org/rep/tfs" TFS_CTRL_REPO_URL=${TFS_REPO_URL}"/controller" TFS_DP_MDG_REPO_URL=${TFS_REPO_URL}"/mdg-dataplane-emulation/mininet" MININET_TESTING_URL="${MININET_TESTING_URL:-${TFS_DP_MDG_REPO_URL}/mininet-testing.git}" MININET_TESTING_REF="${MININET_TESTING_REF:-${MININET_TESTING_BRANCH:-develop}}" MININET_TESTING_DIR="${MININET_TESTING_DIR:-${CI_PROJECT_DIR}/mininet-testing}" REQ_COMPONENTS_FILE="${REQ_COMPONENTS_FILE:-${CI_PROJECT_DIR}/requested-components.txt}" TFS_K8S_NAMESPACE="${TFS_K8S_NAMESPACE:-tfs}" TFS_DEPLOY_TIMEOUT="${TFS_DEPLOY_TIMEOUT:-300s}" TESTS_DIR="${MININET_TESTING_DIR}/tests" fail() { printf 'ERROR: %s\n' "$*" >&2; exit 1; } Loading
src/tests/p4-end-to-end/scripts/1-tests-clone.sh +11 −21 Changes for src/tests/p4-end-to-end/scripts/1-tests-clone.sh: 11 added lines, 21 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test bash 1-tests-clone.sh set -Eeuo pipefail : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" TFS_REPO_URL="https://labs.etsi.org/rep/tfs" TFS_CTRL_REPO_URL=${TFS_REPO_URL}"/controller" TFS_DP_MDG_REPO_URL=${TFS_REPO_URL}"/mdg-dataplane-emulation/mininet" MININET_TESTING_URL="${MININET_TESTING_URL:-${TFS_DP_MDG_REPO_URL}/mininet-testing.git}" MININET_TESTING_REF="${MININET_TESTING_REF:-${MININET_TESTING_BRANCH:-develop}}" MININET_TESTING_DIR="${MININET_TESTING_DIR:-${CI_PROJECT_DIR}/mininet-testing}" REQ_COMPONENTS_FILE="${REQ_COMPONENTS_FILE:-${CI_PROJECT_DIR}/requested-components.txt}" fail() { printf '$0: ERROR: %s\n' "$*" >&2; exit 1; } source "common.sh" # Some preconditions for the clone stage, which are expected to be set by the GitLab CI environment [[ -n "$MININET_TESTING_URL" ]] || fail 'MININET_TESTING_URL must not be empty' [[ -n "$MININET_TESTING_REF" ]] || fail 'MININET_TESTING_REF must not be empty' [[ "$MININET_TESTING_DIR" == /* ]] || MININET_TESTING_DIR="${CI_PROJECT_DIR}/${MININET_TESTING_DIR}" [[ "$REQ_COMPONENTS_FILE" == /* ]] || REQ_COMPONENTS_FILE="${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}" # Fail if the destination directory already exists, as it is expected to be created by this stage if [[ -e "$MININET_TESTING_DIR" ]]; then fail "destination already exists: $MININET_TESTING_DIR" fi # Create the parent directories for the destination directory and the requested components file, if they do not already exist mkdir -p "$(dirname "$MININET_TESTING_DIR")" "$(dirname "$REQ_COMPONENTS_FILE")" printf 'Cloning Mininet test suite\n' printf '\tRepository: %s\n' "$MININET_TESTING_URL" printf '\t Ref: %s\n' "$MININET_TESTING_REF" printf '\t Directory: %s\n' "$MININET_TESTING_DIR" git clone --quiet --no-checkout "$MININET_TESTING_URL" "$MININET_TESTING_DIR" || \ # Clone the Mininet test suite git clone -b "$MININET_TESTING_REF" --quiet "$MININET_TESTING_URL" "$MININET_TESTING_DIR" || \ fail "could not clone $MININET_TESTING_URL" git -C "$MININET_TESTING_DIR" fetch --quiet origin "$MININET_TESTING_REF" || \ fail "could not fetch ref '$MININET_TESTING_REF' from $MININET_TESTING_URL" # git -C "$MININET_TESTING_DIR" checkout --quiet --detach FETCH_HEAD || \ # fail "could not check out ref '$MININET_TESTING_REF'" # commit="$(git -C "$MININET_TESTING_DIR" rev-parse HEAD)" || fail 'could not read checked-out commit' # printf 'Selected ref: %s\nResulting commit: %s\n' "$MININET_TESTING_REF" "$commit" # Collect the TFS components requested by the test suite, and save them to a single env. file collector="${MININET_TESTING_DIR}/common/ci/collect-tfs-components.sh" [[ -f "$collector" ]] || fail "component collector not found: $collector" (cd "$MININET_TESTING_DIR" && bash "$collector") > "$REQ_COMPONENTS_FILE" || fail 'component collection failed' printf 'Requested components saved to: %s\n' "$REQ_COMPONENTS_FILE" (cd "$MININET_TESTING_DIR" && bash "$collector") > "$REQ_COMPONENTS_FILE" || fail 'TFS component collection failed' printf 'Requested TFS components saved to: %s\n' "$REQ_COMPONENTS_FILE" cat "$REQ_COMPONENTS_FILE" exit 0
src/tests/p4-end-to-end/scripts/2-tfs-deploy.sh +9 −7 Changes for src/tests/p4-end-to-end/scripts/2-tfs-deploy.sh: 9 added lines, 7 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test TEST_NAME=p4-end-to-end bash 2-tfs-deploy.sh set -Eeuo pipefail : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" : "${TEST_NAME:?TEST_NAME must identify a controller test under src/tests}" # TEST_NAME="${TEST_NAME:-"p4-end-to-end"}" TFS_K8S_NAMESPACE="${TFS_K8S_NAMESPACE:-tfs}" TFS_DEPLOY_TIMEOUT="${TFS_DEPLOY_TIMEOUT:-300s}" REQ_COMPONENTS_FILE="${REQ_COMPONENTS_FILE:-${CI_PROJECT_DIR}/requested-components.txt}" [[ "$REQ_COMPONENTS_FILE" == /* ]] || REQ_COMPONENTS_FILE="${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}" source "common.sh" fail() { printf '$0: ERROR: %s\n' "$*" >&2; exit 1; } # State created by the previous clone stage, and is passed into this process explicitly via the workspace file [[ "$REQ_COMPONENTS_FILE" == /* ]] || REQ_COMPONENTS_FILE="${CI_PROJECT_DIR}/${REQ_COMPONENTS_FILE}" # Fail if the requested components file is missing, as it is required for deployment [[ -f "$REQ_COMPONENTS_FILE" ]] || fail "requested components file not found: $REQ_COMPONENTS_FILE" # A single env. file that aggregates TFS components collected from the tests folder cd "$CI_PROJECT_DIR" [[ -f "src/tests/${TEST_NAME}/deploy_specs.sh" ]] || fail "deploy specs not found: src/tests/${TEST_NAME}/deploy_specs.sh" # Pass the clone stage's output into this process explicitly via the workspace file. # Pass the clone stage's output into this process explicitly via the workspace file REQUESTED_COMPONENTS="$(<"$REQ_COMPONENTS_FILE")" export REQUESTED_COMPONENTS TFS_K8S_NAMESPACE TFS_DEPLOY_TIMEOUT # Deploy TFS components requested by the test suite, and wait for all pods to be ready source "src/tests/${TEST_NAME}/deploy_specs.sh" bash scripts/ci_prepare_microk8s_storage_registry.sh source scripts/ci_apply_deploy_specs_overrides.sh Loading
src/tests/p4-end-to-end/scripts/3-tests-run.sh +8 −4 Changes for src/tests/p4-end-to-end/scripts/3-tests-run.sh: 8 added lines, 4 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test bash 3-tests-run.sh set -Eeuo pipefail : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" MININET_TESTING_DIR="${MININET_TESTING_DIR:-${CI_PROJECT_DIR}/mininet-testing}" [[ "$MININET_TESTING_DIR" == /* ]] || MININET_TESTING_DIR="${CI_PROJECT_DIR}/${MININET_TESTING_DIR}" TESTS_DIR="${MININET_TESTING_DIR}/tests" source "common.sh" fail() { printf '$0: ERROR: %s\n' "$*" >&2; exit 1; } # The workspace of this stage [[ "$MININET_TESTING_DIR" == /* ]] || MININET_TESTING_DIR="${CI_PROJECT_DIR}/${MININET_TESTING_DIR}" # A tests/ directory is expected to exist under the Mininet test suite, and contain one or more test scenarios [[ -d "$TESTS_DIR" ]] || fail "test suite directory not found: $TESTS_DIR" # Identify the test scenarios under the tests/ directory shopt -s nullglob scenarios=("$TESTS_DIR"/*) shopt -u nullglob ((${#scenarios[@]} > 0)) || fail "no test scenarios found under $TESTS_DIR" # Run each test scenario in turn, and fail if any of them fails for scenario in "${scenarios[@]}"; do [[ -d "$scenario" ]] || continue test_script="${scenario}/test.sh" Loading
src/tests/p4-end-to-end/scripts/4-cleanup.sh +7 −1 Changes for src/tests/p4-end-to-end/scripts/4-cleanup.sh: 7 added lines, 1 removed line. Original line number Diff line number Diff line #!/usr/bin/env bash # --> Example: CI_PROJECT_DIR=/home/ubuntu/test bash 4-cleanup.sh set -Eeuo pipefail TFS_K8S_NAMESPACE="${TFS_K8S_NAMESPACE:-tfs}" : "${CI_PROJECT_DIR:?CI_PROJECT_DIR must be set by GitLab CI}" source "common.sh" # Delete the TFS namespace, if it exists, and ignore any errors printf 'Cleaning up namespace: %s\n' "$TFS_K8S_NAMESPACE" if command -v kubectl >/dev/null 2>&1; then kubectl delete namespace "$TFS_K8S_NAMESPACE" --wait=false || true Loading @@ -10,6 +15,7 @@ else printf '$0: kubectl is unavailable; skipping namespace deletion\n' >&2 fi # Cleanup the controller runner, if it exists if [[ -n "${CI_PROJECT_DIR:-}" && -f "${CI_PROJECT_DIR}/scripts/ci_cleanup_gitlab_runner.sh" ]]; then bash "${CI_PROJECT_DIR}/scripts/ci_cleanup_gitlab_runner.sh" else Loading
src/tests/p4-end-to-end/scripts/common.sh +19 −0 Changes for src/tests/p4-end-to-end/scripts/common.sh: 19 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/env bash CI_PROJECT_DIR=${CI_PROJECT_DIR:-"/home/ubuntu/test"} TFS_REPO_URL="https://labs.etsi.org/rep/tfs" TFS_CTRL_REPO_URL=${TFS_REPO_URL}"/controller" TFS_DP_MDG_REPO_URL=${TFS_REPO_URL}"/mdg-dataplane-emulation/mininet" MININET_TESTING_URL="${MININET_TESTING_URL:-${TFS_DP_MDG_REPO_URL}/mininet-testing.git}" MININET_TESTING_REF="${MININET_TESTING_REF:-${MININET_TESTING_BRANCH:-develop}}" MININET_TESTING_DIR="${MININET_TESTING_DIR:-${CI_PROJECT_DIR}/mininet-testing}" REQ_COMPONENTS_FILE="${REQ_COMPONENTS_FILE:-${CI_PROJECT_DIR}/requested-components.txt}" TFS_K8S_NAMESPACE="${TFS_K8S_NAMESPACE:-tfs}" TFS_DEPLOY_TIMEOUT="${TFS_DEPLOY_TIMEOUT:-300s}" TESTS_DIR="${MININET_TESTING_DIR}/tests" fail() { printf 'ERROR: %s\n' "$*" >&2; exit 1; }