forked from operator-framework/operator-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e-coverage.sh
More file actions
executable file
·35 lines (24 loc) · 1.54 KB
/
e2e-coverage.sh
File metadata and controls
executable file
·35 lines (24 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -euo pipefail
COVERAGE_NAME="${COVERAGE_NAME:-e2e}"
OPERATOR_CONTROLLER_NAMESPACE="olmv1-system"
OPERATOR_CONTROLLER_MANAGER_DEPLOYMENT_NAME="operator-controller-controller-manager"
CATALOGD_NAMESPACE="olmv1-system"
CATALOGD_MANAGER_DEPLOYMENT_NAME="catalogd-controller-manager"
COPY_POD_NAME="e2e-coverage-copy-pod"
# Create a temporary directory for coverage
COVERAGE_OUTPUT=${ROOT_DIR}/coverage/${COVERAGE_NAME}.out
COVERAGE_DIR=${ROOT_DIR}/coverage/${COVERAGE_NAME}
rm -rf ${COVERAGE_DIR} && mkdir -p ${COVERAGE_DIR}
# Coverage-instrumented binary produces coverage on termination,
# so we scale down the manager before gathering the coverage
kubectl -n "$OPERATOR_CONTROLLER_NAMESPACE" scale deployment/"$OPERATOR_CONTROLLER_MANAGER_DEPLOYMENT_NAME" --replicas=0
kubectl -n "$CATALOGD_NAMESPACE" scale deployment/"$CATALOGD_MANAGER_DEPLOYMENT_NAME" --replicas=0
# Wait for manager pods to terminate so coverage data is flushed to the PVC
kubectl -n "$OPERATOR_CONTROLLER_NAMESPACE" wait --for=delete pods -l control-plane="$OPERATOR_CONTROLLER_MANAGER_DEPLOYMENT_NAME" --timeout=60s
kubectl -n "$CATALOGD_NAMESPACE" wait --for=delete pods -l control-plane="$CATALOGD_MANAGER_DEPLOYMENT_NAME" --timeout=60s
# Copy the coverage data from the temporary pod
kubectl -n "$OPERATOR_CONTROLLER_NAMESPACE" cp "$COPY_POD_NAME":/e2e-coverage/ "$COVERAGE_DIR"
# Convert binary coverage data files into the textual format
go tool covdata textfmt -i "$COVERAGE_DIR" -o "$COVERAGE_OUTPUT"
echo "Coverage report generated successfully at: $COVERAGE_OUTPUT"