-
Notifications
You must be signed in to change notification settings - Fork 54
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 <[email protected]>
- Loading branch information
Showing
9 changed files
with
141 additions
and
8 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
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,9 @@ | ||
namespace: operator-controller-system | ||
|
||
resources: | ||
- ../default | ||
- manager_e2e_coverage_pvc.yaml | ||
- manager_e2e_coverage_copy_pod.yaml | ||
|
||
patches: | ||
- path: manager_e2e_coverage_patch.yaml |
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,36 @@ | ||
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 | ||
readOnly: true | ||
volumes: | ||
- name: e2e-coverage-volume | ||
persistentVolumeClaim: | ||
claimName: e2e-coverage | ||
readOnly: true |
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,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: kube-rbac-proxy | ||
- name: manager | ||
env: | ||
- name: GOCOVERDIR | ||
value: /e2e-coverage | ||
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,10 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: e2e-coverage | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 64Mi |
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,33 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
COVERAGE_OUTPUT="${COVERAGE_OUTPUT:-e2e-cover.out}" | ||
|
||
OPERATOR_CONTROLLER_NAMESPACE="operator-controller-system" | ||
OPERATOR_CONTROLLER_MANAGER_DEPLOYMENT_NAME="operator-controller-controller-manager" | ||
COPY_POD_NAME="e2e-coverage-copy-pod" | ||
|
||
# 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 "$COPY_POD_NAME" | ||
|
||
# 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" |