-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
- Loading branch information
Showing
4 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: e2e-coverage-copy-pod | ||
labels: | ||
app.kubernetes.io/name: e2e-coverage-copy-pod | ||
app.kubernetes.io/instance: controller-manager | ||
app.kubernetes.io/component: e2e-coverage | ||
app.kubernetes.io/created-by: operator-controller | ||
app.kubernetes.io/part-of: operator-controller | ||
app.kubernetes.io/managed-by: kustomize | ||
spec: | ||
restartPolicy: Never | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 65532 | ||
seccompProfile: | ||
type: RuntimeDefault | ||
containers: | ||
- name: tar | ||
image: busybox:1.36 | ||
command: ["sleep", "infinity"] | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- "ALL" | ||
volumeMounts: | ||
- name: e2e-coverage-volume | ||
mountPath: /e2e-coverage | ||
volumes: | ||
- name: e2e-coverage-volume | ||
persistentVolumeClaim: | ||
claimName: e2e-coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
OPERATOR_CONTROLLER_NAMESPACE="${OPERATOR_CONTROLLER_NAMESPACE:-operator-controller-system}" | ||
OPERATOR_CONTROLLER_MANAGER_DEPLOYMENT_NAME="${OPERATOR_CONTROLLER_MANAGER_DEPLOYMENT_NAME:-operator-controller-controller-manager}" | ||
COVERAGE_OUTPUT="${COVERAGE_OUTPUT:-e2e-cover.out}" | ||
|
||
# Create a temporary directory for coverage | ||
COVERAGE_DIR=$(mktemp -d) | ||
|
||
# Trap to cleanup temporary directory on script exit | ||
function cleanup { | ||
rm -rf "$COVERAGE_DIR" | ||
} | ||
trap cleanup EXIT | ||
|
||
# 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 | ||
|
||
# Wait for the copy pod to be ready | ||
kubectl -n "$OPERATOR_CONTROLLER_NAMESPACE" wait --for=condition=ready pod e2e-coverage-copy-pod | ||
|
||
# Copy the coverage data from the temporary pod | ||
kubectl -n "$OPERATOR_CONTROLLER_NAMESPACE" cp e2e-coverage-copy-pod:/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" |