Skip to content

feat: Generating e2e test coverage #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chandankumar4
Copy link
Contributor

@chandankumar4 chandankumar4 commented Mar 24, 2025

Fixes #620

Modifications

Verification

Backward incompatibilities

@chandankumar4 chandankumar4 force-pushed the e2e-coverage branch 4 times, most recently from 1f79726 to ed031d5 Compare April 8, 2025 07:06
@chandankumar4 chandankumar4 changed the title Generating e2e test coverage feat: Generating e2e test coverage Apr 8, 2025
Signed-off-by: chandankumar4 <[email protected]>
@chandankumar4 chandankumar4 force-pushed the e2e-coverage branch 13 times, most recently from df8b26c to 5bbbdd0 Compare April 8, 2025 12:32
# especially steps that involve installing packages using a package manager.
ENV GOCACHE=/root/.cache/go-build
# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
Copy link
Collaborator

@juliev0 juliev0 Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was copied from the other Dockerfile, but do you mind fixing the phrasing to "the GOARCH doesn't have a default value"? (in both Dockerfiles)

# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN --mount=type=cache,target="/root/.cache/go-build" CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -cover -coverpkg=./... -o manager cmd/main.go

## Use alpine as minimal base image to package the manager binary
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment isn't right for this Dockerfile

## Use alpine as minimal base image to package the manager binary
FROM golang:1.23
WORKDIR /
COPY --from=builder /workspace/manager .
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's interesting that it works without copying the code itself in. I guess the binary alone must be aware of all of the code lines (or whatever it needs to generate the coverage report)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, I know this PR is still a WIP, but when you get to it, make sure to add some comments in here about what you're doing

volumes:
- name: config-volume
configMap:
name: numaplane-controller-config
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be easy to forget to update this file when our Deployment changes - can we change it to a patch?

./hack/numaflow-controller-def-generator/numaflow-controller-def-generator.sh
$(KUBECTL) apply -f $(TEST_MANIFEST_DIR_DEFAULT)/numaplane-ns.yaml
$(KUBECTL) kustomize $(TEST_MANIFEST_DIR) | sed '[email protected]/numaproj/@$(IMAGE_NAMESPACE)/@' | sed 's/$(IMG):$(BASE_VERSION)/$(IMG):$(VERSION)/' | $(KUBECTL) apply -f -
cat tests/e2e/coverage/controller-manager.yaml | sed 's/$(IMG):$(BASE_VERSION)/$(IMG):$(VERSION)/' | $(KUBECTL) apply -f -
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference between this and make start is the last line, right? How about we just control that with an environment variable? (Also, this will need to change based on my other comment)

$(CONTAINER_TOOL) build -t ${IMAGE_FULL_PATH} -f tests/e2e/coverage/Dockerfile .
ifdef IMAGE_IMPORT_CMD
$(IMAGE_IMPORT_CMD) ${IMAGE_FULL_PATH}
endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be able to consolidate this and make image into one by using an environment variable for the Dockerfile

app.kubernetes.io/component: controller-manager
spec:
containers:
- image: quay.io/numaproj/numaplane-controller:latest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we want a distinct image name or image tag for this one, to avoid confusion

POD_NAME=$(kubectl get pods -n numaplane-system -l app.kubernetes.io/name=controller-manager -o jsonpath="{.items[0].metadata.name}")
kubectl exec -n numaplane-system $POD_NAME -- /bin/bash -c 'pkill -f "/manager --health-probe-bind-address=:8081 --metrics-bind-address=:8080 --leader-elect"'
sleep 5s
kubectl exec -n numaplane-system $POD_NAME -- /bin/bash -c 'pkill -f "/manager --health-probe-bind-address=:8081 --metrics-bind-address=:8080 --leader-elect"'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you have to kill it twice?

run: |
mkdir -p tests/e2e/output/resources/coverage/
POD_NAME=$(kubectl get pods -n numaplane-system -l app.kubernetes.io/name=controller-manager -o jsonpath="{.items[0].metadata.name}")
kubectl cp $POD_NAME:/coverage -n numaplane-system tests/e2e/output/resources/coverage/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great. So, we can have one or more steps to:

  1. aggregate all of the e2e coverage, post that as an artifact
  2. post the unit test code coverage as an artifact
  3. aggregate e2e and unit test code coverage together and post that as an artifact

Ideal thing is to be able to have html output for these artifacts that we could view in a browser

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, you can see if we need artifacts at all, or if posting to CodeCov gives us everything we need, now that I think about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get code coverage from e2e test and have CI produce aggregate coverage
2 participants