blob: 72803ace1b5781f9865ddbe875bba472f6d6f5c0 [file] [log] [blame]
Eric Ball6f17fcb2026-03-04 18:00:51 -08001---
2# SPDX-License-Identifier: Apache-2.0
3# SPDX-FileCopyrightText: 2026 Open Networking Foundation Contributors
4
5name: "bbsim-tests"
6description: "VOLTHA BBSim E2E Tests - Simulates OLT/ONUs using bbsim and runs robot framework tests"
7
8inputs:
9 branch:
10 description: "Branch to test (master, voltha-2.15, etc.)"
11 required: true
12 type: string
13 test-targets:
14 description: "YAML string defining test targets to run"
15 required: true
16 type: string
17 gerrit-project:
18 description: "Gerrit project name if building a patch"
19 required: false
20 type: string
21 default: ""
22 gerrit-refspec:
23 description: "Gerrit refspec if building a patch"
24 required: false
25 type: string
26 default: ""
27 voltha-system-tests-change:
28 description: "Gerrit change number for voltha-system-tests"
29 required: false
30 type: string
31 default: ""
32 voltha-helm-charts-change:
33 description: "Gerrit change number for voltha-helm-charts"
34 required: false
35 type: string
36 default: ""
37 extra-helm-flags:
38 description: "Additional Helm flags for deployment"
39 required: false
40 type: string
41 default: ""
42 log-level:
43 description: "Log level for VOLTHA components (DEBUG, INFO, WARN, ERROR)"
44 required: false
45 type: string
46 default: "WARN"
47 timeout:
48 description: "Timeout in minutes for the entire action"
49 required: false
50 type: string
51 default: "240"
52 cluster-name:
53 description: "Name of the kind cluster"
54 required: false
55 type: string
56 default: "kind-ci"
57 docker-registry:
58 description: "Docker registry to use"
59 required: false
60 type: string
61 default: "linuxfoundation.jfrog.io/voltha-docker"
62 olts:
63 description: "Number of OLTs to simulate"
64 required: false
65 type: string
66 default: "1"
67 with-monitoring:
68 description: "Enable monitoring with prometheus"
69 required: false
70 type: boolean
71 default: false
72 enable-mac-learning:
73 description: "Enable MAC learning in VOLTHA"
74 required: false
75 type: boolean
76 default: false
77 extra-robot-args:
78 description: "Additional arguments for Robot Framework"
79 required: false
80 type: string
81 default: ""
82
83outputs:
84 test-results:
85 description: "Path to test results"
86 value: ${{ steps.test-execution.outputs.results-path }}
87
88runs:
89 using: "composite"
90 steps:
91 # -----------------------------------------------------------------------
92 # Setup environment variables
93 # -----------------------------------------------------------------------
94 - name: Setup environment
95 shell: bash
96 run: |
97 echo "KUBECONFIG=$HOME/.kube/kind-${{ inputs.cluster-name }}" >> $GITHUB_ENV
98 echo "VOLTCONFIG=$HOME/.volt/config" >> $GITHUB_ENV
99 echo "PATH=$PATH:$GITHUB_WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >> $GITHUB_ENV
100 echo "DIAGS_PROFILE=VOLTHA_PROFILE" >> $GITHUB_ENV
101 echo "SSHPASS=karaf" >> $GITHUB_ENV
102 mkdir -p $GITHUB_WORKSPACE/bin
103
104 # -----------------------------------------------------------------------
105 # Install dependencies
106 # -----------------------------------------------------------------------
107 - name: Install system dependencies
108 shell: bash
109 run: |
110 echo "Installing system dependencies..."
111 sudo apt-get update
112 sudo apt-get install -y \
113 curl \
114 wget \
115 git \
116 make \
117 jq \
118 sshpass \
119 python3 \
120 python3-pip \
121 python3-venv \
122 rsync
123
124 # -----------------------------------------------------------------------
125 # Install kubectl
126 # -----------------------------------------------------------------------
127 - name: Install kubectl
128 shell: bash
129 run: |
130 echo "Installing kubectl..."
131 if [ ! -f "$GITHUB_WORKSPACE/bin/kubectl" ]; then
132 KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
133 curl -Lo "$GITHUB_WORKSPACE/bin/kubectl" \
134 "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
135 chmod +x "$GITHUB_WORKSPACE/bin/kubectl"
136 fi
137 kubectl version --client
138
139 # -----------------------------------------------------------------------
140 # Install Helm
141 # -----------------------------------------------------------------------
142 - name: Install Helm
143 shell: bash
144 run: |
145 echo "Installing Helm..."
146 if ! command -v helm &> /dev/null; then
147 curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
148 fi
149 helm version
150
151 # -----------------------------------------------------------------------
152 # Install kind
153 # -----------------------------------------------------------------------
154 - name: Install kind
155 shell: bash
156 run: |
157 echo "Installing kind..."
158 if [ ! -f "$GITHUB_WORKSPACE/bin/kind" ]; then
159 KIND_VERSION="v0.20.0"
160 curl -Lo "$GITHUB_WORKSPACE/bin/kind" \
161 "https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64"
162 chmod +x "$GITHUB_WORKSPACE/bin/kind"
163 fi
164 kind version
165
166 # -----------------------------------------------------------------------
167 # Install kail
168 # -----------------------------------------------------------------------
169 - name: Install kail
170 shell: bash
171 run: |
172 echo "Installing kail..."
173 if [ ! -f "$GITHUB_WORKSPACE/bin/kail" ]; then
174 KAIL_VERSION="v0.17.4"
175 wget -O /tmp/kail.tar.gz \
176 "https://github.com/boz/kail/releases/download/${KAIL_VERSION}/kail_${KAIL_VERSION}_linux_amd64.tar.gz"
177 tar -xzf /tmp/kail.tar.gz -C "$GITHUB_WORKSPACE/bin" kail
178 chmod +x "$GITHUB_WORKSPACE/bin/kail"
179 rm /tmp/kail.tar.gz
180 fi
181
182 # -----------------------------------------------------------------------
183 # Install voltctl
184 # -----------------------------------------------------------------------
185 - name: Install voltctl
186 shell: bash
187 run: |
188 echo "Installing voltctl..."
189 if [ "${{ inputs.gerrit-project }}" != "voltctl" ]; then
190 if [ ! -f "$GITHUB_WORKSPACE/bin/voltctl" ]; then
191 VOLTCTL_VERSION="1.8.45"
192 curl -Lo "$GITHUB_WORKSPACE/bin/voltctl" \
193 "https://github.com/opencord/voltctl/releases/download/v${VOLTCTL_VERSION}/voltctl-${VOLTCTL_VERSION}-linux-amd64"
194 chmod +x "$GITHUB_WORKSPACE/bin/voltctl"
195 fi
196 fi
197
198 # -----------------------------------------------------------------------
199 # Checkout VOLTHA repositories
200 # -----------------------------------------------------------------------
201 - name: Checkout voltha-system-tests
202 uses: actions/checkout@v4
203 with:
204 repository: opencord/voltha-system-tests
205 ref: ${{ inputs.branch }}
206 path: voltha-system-tests
207
208 - name: Apply voltha-system-tests patch
209 if: inputs.voltha-system-tests-change != ''
210 shell: bash
211 working-directory: voltha-system-tests
212 run: |
213 echo "Applying voltha-system-tests change ${{ inputs.voltha-system-tests-change }}"
214 git fetch https://gerrit.lfbroadband.org/voltha-system-tests \
215 refs/changes/${{ inputs.voltha-system-tests-change }}
216 git checkout FETCH_HEAD
217
218 - name: Checkout voltha-helm-charts
219 uses: actions/checkout@v4
220 with:
221 repository: opencord/voltha-helm-charts
222 ref: ${{ inputs.branch }}
223 path: voltha-helm-charts
224
225 - name: Apply voltha-helm-charts patch
226 if: inputs.voltha-helm-charts-change != ''
227 shell: bash
228 working-directory: voltha-helm-charts
229 run: |
230 echo "Applying voltha-helm-charts change ${{ inputs.voltha-helm-charts-change }}"
231 git fetch https://gerrit.lfbroadband.org/voltha-helm-charts \
232 refs/changes/${{ inputs.voltha-helm-charts-change }}
233 git checkout FETCH_HEAD
234
235 # -----------------------------------------------------------------------
236 # Checkout and build gerrit project if specified
237 # -----------------------------------------------------------------------
238 - name: Checkout gerrit project
239 if: inputs.gerrit-project != ''
240 uses: actions/checkout@v4
241 with:
242 repository: opencord/${{ inputs.gerrit-project }}
243 ref: ${{ inputs.gerrit-refspec }}
244 path: ${{ inputs.gerrit-project }}
245
246 - name: Build gerrit project
247 if: inputs.gerrit-project != ''
248 shell: bash
249 working-directory: ${{ inputs.gerrit-project }}
250 run: |
251 echo "Building ${{ inputs.gerrit-project }}..."
252 if [ -f "Makefile" ]; then
253 make docker-build
254 fi
255
256 - name: Build and install voltctl from source
257 if: inputs.gerrit-project == 'voltctl'
258 shell: bash
259 working-directory: voltctl
260 run: |
261 echo "Building voltctl from source..."
262 make build
263 cp voltctl "$GITHUB_WORKSPACE/bin/"
264 chmod +x "$GITHUB_WORKSPACE/bin/voltctl"
265
266 # -----------------------------------------------------------------------
267 # Create kind cluster
268 # -----------------------------------------------------------------------
269 - name: Check if kind cluster exists
270 id: cluster-check
271 shell: bash
272 run: |
273 if kind get clusters | grep -q "^${{ inputs.cluster-name }}$"; then
274 echo "exists=true" >> $GITHUB_OUTPUT
275 else
276 echo "exists=false" >> $GITHUB_OUTPUT
277 fi
278
279 - name: Create kind cluster
280 if: steps.cluster-check.outputs.exists == 'false'
281 shell: bash
282 run: |
283 echo "Creating kind cluster ${{ inputs.cluster-name }}..."
284 cat <<EOF > /tmp/kind-config.yaml
285 kind: Cluster
286 apiVersion: kind.x-k8s.io/v1alpha4
287 nodes:
288 - role: control-plane
289 - role: worker
290 - role: worker
291 EOF
292
293 kind create cluster --name ${{ inputs.cluster-name }} --config /tmp/kind-config.yaml
294
295 # Configure kubeconfig
296 mkdir -p $HOME/.kube
297 kind export kubeconfig --name ${{ inputs.cluster-name }} --kubeconfig $HOME/.kube/kind-${{ inputs.cluster-name }}
298
299 # Wait for cluster to be ready
300 kubectl wait --for=condition=Ready nodes --all --timeout=300s
301
302 # -----------------------------------------------------------------------
303 # Load images to kind if building a component
304 # -----------------------------------------------------------------------
305 - name: Load images to kind
306 if: inputs.gerrit-project != '' && inputs.gerrit-project != 'voltctl'
307 shell: bash
308 run: |
309 echo "Loading images to kind cluster..."
310 PROJECT="${{ inputs.gerrit-project }}"
311 IMAGE_NAME="${PROJECT//-/_}"
312
313 # Find the built image
314 IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep -E "voltha/${PROJECT}|opencord/${PROJECT}" | head -1)
315
316 if [ -n "$IMAGE" ]; then
317 echo "Loading image: $IMAGE"
318 kind load docker-image "$IMAGE" --name ${{ inputs.cluster-name }}
319 else
320 echo "Warning: No image found for project $PROJECT"
321 fi
322
323 # -----------------------------------------------------------------------
324 # Setup Helm repositories
325 # -----------------------------------------------------------------------
326 - name: Setup Helm repositories
327 shell: bash
328 run: |
329 echo "Adding Helm repositories..."
330 helm repo add onf https://charts.lfbroadband.org
331 helm repo add cord https://charts.lfbroadband.org
332 helm repo update
333
334 # -----------------------------------------------------------------------
335 # Run tests
336 # -----------------------------------------------------------------------
337 - name: Install PyYAML for test parsing
338 shell: bash
339 run: |
340 pip3 install pyyaml
341
342 - name: Create test execution script
343 shell: bash
344 run: |
345 # Create the test execution script inline
346 cat > /tmp/execute_test.sh <<'EXECUTE_TEST_SCRIPT'
347 #!/bin/bash
348 set -euo pipefail
349
350 # Get environment variables
351 TEST_TARGET="${TEST_TARGET:-functional-single-kind-dt}"
352 WORKFLOW="${WORKFLOW:-dt}"
353 TEST_FLAGS="${TEST_FLAGS:-}"
354 TEARDOWN="${TEARDOWN:-true}"
355 TEST_LOGGING="${TEST_LOGGING:-True}"
356 VGC_ENABLED="${VGC_ENABLED:-false}"
357 INFRA_NAMESPACE="${INFRA_NAMESPACE:-default}"
358 VOLTHA_NAMESPACE="${VOLTHA_NAMESPACE:-voltha}"
359 LOGS_DIR="${LOGS_DIR:-$GITHUB_WORKSPACE/logs}"
360 EXTRA_HELM_FLAGS="${EXTRA_HELM_FLAGS:-}"
361 LOG_LEVEL="${LOG_LEVEL:-WARN}"
362 DOCKER_REGISTRY="${DOCKER_REGISTRY:-linuxfoundation.jfrog.io/voltha-docker}"
363 OLTS="${OLTS:-1}"
364 WITH_MONITORING="${WITH_MONITORING:-false}"
365 ENABLE_MAC_LEARNING="${ENABLE_MAC_LEARNING:-false}"
366 EXTRA_ROBOT_ARGS="${EXTRA_ROBOT_ARGS:-}"
367 BRANCH="${BRANCH:-master}"
368 GERRIT_PROJECT="${GERRIT_PROJECT:-}"
369
370 # Helper functions
371 banner() {
372 echo ""
373 echo "** -----------------------------------------------------------------------"
374 echo "** $1"
375 echo "** -----------------------------------------------------------------------"
376 echo ""
377 }
378
379 cleanup_port_forward() {
380 echo "Cleaning up port-forward processes..."
381 pkill -f "kubectl.*port-forward" || true
382 }
383
384 get_pods_info() {
385 local logs_dir=$1
386 mkdir -p "$logs_dir"
387 kubectl get pods --all-namespaces -o wide > "$logs_dir/pods.txt" || true
388 kubectl get nodes -o wide > "$logs_dir/nodes.txt" || true
389 kubectl describe pods -n "$VOLTHA_NAMESPACE" > "$logs_dir/voltha-pods-describe.txt" || true
390 kubectl describe pods -n "$INFRA_NAMESPACE" > "$logs_dir/infra-pods-describe.txt" || true
391 }
392
393 # Stage: Cleanup (if teardown enabled)
394 if [ "$TEARDOWN" = "true" ]; then
395 banner "Cleanup - Helm Teardown"
396 cleanup_port_forward
397 for namespace in default "$INFRA_NAMESPACE" "$VOLTHA_NAMESPACE"; do
398 echo "Cleaning up Helm releases in namespace: $namespace"
399 helm list -n "$namespace" -q | xargs -r helm uninstall -n "$namespace" || true
400 done
401 echo "Waiting for pods to terminate..."
402 kubectl wait --for=delete pods --all -n "$VOLTHA_NAMESPACE" --timeout=120s || true
403 kubectl wait --for=delete pods --all -n "$INFRA_NAMESPACE" --timeout=120s || true
404 fi
405
406 # Stage: Deploy Common Infrastructure
407 banner "Deploying Common Infrastructure"
408 if [ "$WITH_MONITORING" = "true" ]; then
409 echo "Deploying monitoring stack..."
410 helm install nem-monitoring onf/nem-monitoring \
411 --set prometheus.alertmanager.enabled=false \
412 --set prometheus.pushgateway.enabled=false \
413 --set kpi_exporter.enabled=false \
414 --set dashboards.xos=false \
415 --set dashboards.onos=false \
416 --set dashboards.aaa=false \
417 --set dashboards.voltha=false \
418 --wait || true
419 fi
420
421 # Stage: Deploy VOLTHA
422 if [ "$TEARDOWN" = "true" ]; then
423 banner "Deploying VOLTHA"
424 ONOS_LOG="${LOGS_DIR}/onos-voltha-startup-combined.log"
425 mkdir -p "$LOGS_DIR"
426 touch "$ONOS_LOG"
427 _TAG=kail-startup kail -n "${INFRA_NAMESPACE}" -n "${VOLTHA_NAMESPACE}" > "$ONOS_LOG" &
428 KAIL_PID=$!
429
430 LOCAL_CHARTS="false"
431 if [ -d "$GITHUB_WORKSPACE/voltha-helm-charts" ]; then
432 LOCAL_CHARTS="true"
433 fi
434
435 HELM_FLAGS="--set global.log_level=${LOG_LEVEL^^}"
436 if [ "$VGC_ENABLED" != "true" ]; then
437 HELM_FLAGS="$HELM_FLAGS --set onos-classic.onosSshPort=30115"
438 HELM_FLAGS="$HELM_FLAGS --set onos-classic.onosApiPort=30120"
439 HELM_FLAGS="$HELM_FLAGS --set onos-classic.onosOfPort=31653"
440 HELM_FLAGS="$HELM_FLAGS --set onos-classic.individualOpenFlowNodePorts=true"
441 fi
442 if [ -n "$EXTRA_HELM_FLAGS" ]; then
443 HELM_FLAGS="$HELM_FLAGS $EXTRA_HELM_FLAGS"
444 fi
445 if [ -n "$TEST_FLAGS" ]; then
446 HELM_FLAGS="$HELM_FLAGS $TEST_FLAGS"
447 fi
448
449 if [ -n "$GERRIT_PROJECT" ] && [ "$GERRIT_PROJECT" != "voltctl" ]; then
450 IMAGE_TAG="citest"
451 case "$GERRIT_PROJECT" in
452 voltha-go)
453 HELM_FLAGS="$HELM_FLAGS --set voltha.image.tag=$IMAGE_TAG"
454 ;;
455 voltha-openolt-adapter)
456 HELM_FLAGS="$HELM_FLAGS --set voltha-adapter-openolt.image.tag=$IMAGE_TAG"
457 ;;
458 voltha-openonu-adapter-go)
459 HELM_FLAGS="$HELM_FLAGS --set voltha-adapter-openonu.image.tag=$IMAGE_TAG"
460 ;;
461 ofagent-go)
462 HELM_FLAGS="$HELM_FLAGS --set voltha.ofagent.image.tag=$IMAGE_TAG"
463 ;;
464 bbsim)
465 HELM_FLAGS="$HELM_FLAGS --set bbsim.image.tag=$IMAGE_TAG"
466 ;;
467 esac
468 fi
469
470 echo "Deploying VOLTHA with workflow: $WORKFLOW"
471 echo "Helm flags: $HELM_FLAGS"
472
473 if [ "$LOCAL_CHARTS" = "true" ]; then
474 echo "Using local charts from $GITHUB_WORKSPACE/voltha-helm-charts"
475 helm dependency update "$GITHUB_WORKSPACE/voltha-helm-charts/voltha-infra" || true
476 helm dependency update "$GITHUB_WORKSPACE/voltha-helm-charts/voltha-stack" || true
477 helm install voltha-infra "$GITHUB_WORKSPACE/voltha-helm-charts/voltha-infra" \
478 -n "$INFRA_NAMESPACE" --create-namespace --wait --timeout 120m
479 helm install voltha "$GITHUB_WORKSPACE/voltha-helm-charts/voltha-stack" \
480 -n "$VOLTHA_NAMESPACE" --create-namespace \
481 --set global.stack_name=voltha \
482 --set global.voltha_infra_name=voltha-infra \
483 --set global.voltha_infra_namespace="$INFRA_NAMESPACE" \
484 $(echo "$HELM_FLAGS") --wait --timeout 120m
485 else
486 echo "Using charts from Helm repository"
487 helm install voltha-infra onf/voltha-infra \
488 -n "$INFRA_NAMESPACE" --create-namespace --wait --timeout 120m
489 helm install voltha onf/voltha-stack \
490 -n "$VOLTHA_NAMESPACE" --create-namespace \
491 --set global.stack_name=voltha \
492 --set global.voltha_infra_name=voltha-infra \
493 --set global.voltha_infra_namespace="$INFRA_NAMESPACE" \
494 $(echo "$HELM_FLAGS") --wait --timeout 120m
495 fi
496
497 for i in $(seq 0 $((OLTS - 1))); do
498 echo "Deploying bbsim${i}..."
499 if [ "$LOCAL_CHARTS" = "true" ]; then
500 helm install "bbsim${i}" "$GITHUB_WORKSPACE/voltha-helm-charts/bbsim" \
501 -n "$VOLTHA_NAMESPACE" --set olt_id="${i}" --wait || true
502 else
503 helm install "bbsim${i}" onf/bbsim \
504 -n "$VOLTHA_NAMESPACE" --set olt_id="${i}" --wait || true
505 fi
506 done
507
508 if [ -n "${KAIL_PID:-}" ]; then
509 kill "$KAIL_PID" || true
510 wait "$KAIL_PID" 2>/dev/null || true
511 fi
512 gzip -f "$ONOS_LOG" || true
513
514 echo "Setting up port forwarding..."
515 kubectl port-forward --address 0.0.0.0 -n "$INFRA_NAMESPACE" svc/voltha-infra-kafka 9092:9092 &
516 bbsim_dmi_port=50075
517 for i in $(seq 0 $((OLTS - 1))); do
518 kubectl port-forward --address 0.0.0.0 -n "$VOLTHA_NAMESPACE" "svc/bbsim${i}" "${bbsim_dmi_port}:50075" &
519 ((bbsim_dmi_port++))
520 done
521 if [ "$WITH_MONITORING" = "true" ]; then
522 kubectl port-forward --address 0.0.0.0 -n default svc/nem-monitoring-prometheus-server 31301:80 &
523 fi
524 if [ "$VGC_ENABLED" = "true" ]; then
525 kubectl port-forward --address 0.0.0.0 -n "$VOLTHA_NAMESPACE" svc/voltha-voltha-go-controller 8181:8181 &
526 fi
527 sleep 5
528 fi
529
530 # Stage: Run Tests
531 banner "Running test ${TEST_TARGET} on workflow ${WORKFLOW}"
532 if [ "$WITH_MONITORING" = "true" ]; then
533 echo "Collecting initial memory consumption..."
534 mkdir -p "$GITHUB_WORKSPACE/voltha-pods-mem-consumption-${WORKFLOW}"
535 cd "$GITHUB_WORKSPACE/voltha-system-tests"
536 if [ -f "requirements.txt" ]; then
537 python3 -m venv .venv || true
538 source .venv/bin/activate || true
539 pip install -r requirements.txt || true
540 if [ -f "scripts/mem_consumption.py" ]; then
541 python scripts/mem_consumption.py \
542 -o "$GITHUB_WORKSPACE/voltha-pods-mem-consumption-${WORKFLOW}" \
543 -a 0.0.0.0:31301 -n "$VOLTHA_NAMESPACE" || true
544 fi
545 fi
546 fi
547
548 echo "Running Robot Framework tests..."
549 mkdir -p "$LOGS_DIR"
550 export ROBOT_MISC_ARGS="-d ${LOGS_DIR} ${EXTRA_ROBOT_ARGS}"
551 ROBOT_MISC_ARGS="${ROBOT_MISC_ARGS} -v ONOS_SSH_PORT:30115"
552 ROBOT_MISC_ARGS="${ROBOT_MISC_ARGS} -v ONOS_REST_PORT:30120"
553 ROBOT_MISC_ARGS="${ROBOT_MISC_ARGS} -v NAMESPACE:${VOLTHA_NAMESPACE}"
554 ROBOT_MISC_ARGS="${ROBOT_MISC_ARGS} -v INFRA_NAMESPACE:${INFRA_NAMESPACE}"
555 ROBOT_MISC_ARGS="${ROBOT_MISC_ARGS} -v container_log_dir:${LOGS_DIR}"
556 ROBOT_MISC_ARGS="${ROBOT_MISC_ARGS} -v logging:${TEST_LOGGING}"
557 export ROBOT_MISC_ARGS
558 export KVSTOREPREFIX="voltha/voltha_voltha"
559 cd "$GITHUB_WORKSPACE/voltha-system-tests"
560 make "${TEST_TARGET}" || TEST_RESULT=$?
561
562 get_pods_info "$LOGS_DIR"
563
564 if [ "$WITH_MONITORING" = "true" ]; then
565 echo "Collecting final memory consumption..."
566 cd "$GITHUB_WORKSPACE/voltha-system-tests"
567 source .venv/bin/activate || true
568 if [ -f "scripts/mem_consumption.py" ]; then
569 python scripts/mem_consumption.py \
570 -o "$GITHUB_WORKSPACE/voltha-pods-mem-consumption-${WORKFLOW}" \
571 -a 0.0.0.0:31301 -n "$VOLTHA_NAMESPACE" || true
572 fi
573 fi
574
575 echo "Compressing logs..."
576 cd "$LOGS_DIR"
577 gzip *-combined.log 2>/dev/null || true
578 banner "Test execution completed"
579 exit ${TEST_RESULT:-0}
580 EXECUTE_TEST_SCRIPT
581
582 chmod +x /tmp/execute_test.sh
583
584 - name: Execute tests
585 id: test-execution
586 shell: bash
587 run: |
588 echo "Executing tests..."
589
590 # Create logs directory
591 mkdir -p $GITHUB_WORKSPACE/logs
592 echo "results-path=$GITHUB_WORKSPACE/logs" >> $GITHUB_OUTPUT
593
594 # Parse test targets from YAML
595 cat > /tmp/test-targets.yaml <<'EOF'
596 ${{ inputs.test-targets }}
597 EOF
598
599 # Run each test target
600 python3 - <<'PYTHON_SCRIPT'
601 import yaml
602 import subprocess
603 import os
604 import sys
605
606 with open('/tmp/test-targets.yaml', 'r') as f:
607 tests = yaml.safe_load(f)
608
609 if not tests:
610 print("No tests defined")
611 sys.exit(0)
612
613 workspace = os.environ['GITHUB_WORKSPACE']
614 test_failures = []
615
616 for idx, test in enumerate(tests):
617 target = test.get('target', '')
618 workflow = test.get('workflow', '')
619 flags = test.get('flags', '')
620 teardown = test.get('teardown', True)
621 logging = test.get('logging', True)
622 vgc_enabled = test.get('vgcEnabled', False)
623
624 print(f"\n** -----------------------------------------------------------------------")
625 print(f"** Executing test {target} on workflow {workflow}")
626 print(f"** -----------------------------------------------------------------------\n")
627
628 # Set environment variables
629 env = os.environ.copy()
630 env['TEST_TARGET'] = target
631 env['WORKFLOW'] = workflow
632 env['TEST_FLAGS'] = flags
633 env['TEARDOWN'] = str(teardown).lower()
634 env['TEST_LOGGING'] = 'True' if logging else 'False'
635 env['VGC_ENABLED'] = 'true' if vgc_enabled else 'false'
636 env['INFRA_NAMESPACE'] = 'default'
637 env['VOLTHA_NAMESPACE'] = 'voltha'
638 env['LOGS_DIR'] = f"{workspace}/logs/{target}"
639 env['EXTRA_HELM_FLAGS'] = "${{ inputs.extra-helm-flags }}"
640 env['LOG_LEVEL'] = "${{ inputs.log-level }}"
641 env['DOCKER_REGISTRY'] = "${{ inputs.docker-registry }}"
642 env['OLTS'] = "${{ inputs.olts }}"
643 env['WITH_MONITORING'] = "${{ inputs.with-monitoring }}"
644 env['ENABLE_MAC_LEARNING'] = "${{ inputs.enable-mac-learning }}"
645 env['EXTRA_ROBOT_ARGS'] = "${{ inputs.extra-robot-args }}"
646 env['BRANCH'] = "${{ inputs.branch }}"
647 env['GERRIT_PROJECT'] = "${{ inputs.gerrit-project }}"
648
649 # Create logs directory for this test
650 os.makedirs(env['LOGS_DIR'], exist_ok=True)
651
652 # Execute the test using the inline script
653 script_path = "/tmp/execute_test.sh"
654
655 print(f"Running test script: {script_path}")
656
657 try:
658 result = subprocess.run(
659 ['/bin/bash', script_path],
660 env=env,
661 check=True
662 )
663 print(f"\nTest {target} completed successfully\n")
664 except subprocess.CalledProcessError as e:
665 print(f"\nTest {target} failed with exit code {e.returncode}\n")
666 test_failures.append(target)
667 # Continue with other tests
668 continue
669 except Exception as e:
670 print(f"\nTest {target} failed with exception: {e}\n")
671 test_failures.append(target)
672 continue
673
674 if test_failures:
675 print(f"\n** Failed tests: {', '.join(test_failures)}")
676 sys.exit(1)
677 else:
678 print("\n** All tests passed successfully")
679
680 PYTHON_SCRIPT
681
682 # -----------------------------------------------------------------------
683 # Collect artifacts
684 # -----------------------------------------------------------------------
685 - name: Collect pod information
686 if: always()
687 shell: bash
688 run: |
689 echo "Collecting pod information..."
690 mkdir -p $GITHUB_WORKSPACE/logs/artifacts
691
692 kubectl get pods --all-namespaces -o wide > $GITHUB_WORKSPACE/logs/artifacts/pods.txt || true
693 kubectl get nodes -o wide > $GITHUB_WORKSPACE/logs/artifacts/nodes.txt || true
694 kubectl get events --all-namespaces --sort-by='.lastTimestamp' > $GITHUB_WORKSPACE/logs/artifacts/events.txt || true
695
696 - name: Collect VOLTHA logs
697 if: always()
698 shell: bash
699 run: |
700 echo "Collecting VOLTHA logs..."
701 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha \
702 > $GITHUB_WORKSPACE/logs/artifacts/voltha.log || true
703
704 - name: Cleanup port-forward processes
705 if: always()
706 shell: bash
707 run: |
708 echo "Cleaning up port-forward processes..."
709 pkill -f "kubectl.*port-forward" || true
710
711 - name: Upload test results
712 if: always()
713 uses: actions/upload-artifact@v4
714 with:
715 name: bbsim-test-results-${{ github.run_id }}
716 path: |
717 ${{ github.workspace }}/logs/**/*.log
718 ${{ github.workspace }}/logs/**/*.gz
719 ${{ github.workspace }}/logs/**/*.txt
720 ${{ github.workspace }}/logs/**/*.html
721 ${{ github.workspace }}/logs/**/*.xml
722 ${{ github.workspace }}/logs/**/voltha-pods-mem-consumption-*/*
723 retention-days: 30
724 if-no-files-found: warn
725
726 # -----------------------------------------------------------------------
727 # Cleanup
728 # -----------------------------------------------------------------------
729 - name: Delete kind cluster
730 if: always()
731 shell: bash
732 run: |
733 # Note: Cluster deletion is optional and can be controlled by workflow
734 echo "To delete cluster manually, run: kind delete cluster --name ${{ inputs.cluster-name }}"