Skip to content

Commit

Permalink
more efficient coverage dockerfiles
Browse files Browse the repository at this point in the history
update final yaml files
revert few unwanted changes

Signed-off-by: Shikhar Soni <[email protected]>
  • Loading branch information
shikharish committed Mar 18, 2024
1 parent fd4e9f4 commit 96166f2
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ bin
.golangci-bin
.coverage/
.trivy-bin
coverage/
coverage-without-sigint/
.DS_Store

# VIM
Expand Down
2 changes: 1 addition & 1 deletion build/images/Dockerfile.build.agent.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ LABEL description="The Docker image to deploy the antrea-agent with code coverag

USER root

RUN mkdir -p /tmp/coverage
COPY build/images/scripts/* /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antrea-agent /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antrea-agent-coverage /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antrea-cni /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antctl /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antctl-coverage /usr/local/bin/
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /
RUN mkdir -p /tmp/coverage

ENTRYPOINT [ "/run_cov_binary.sh" ]
2 changes: 1 addition & 1 deletion build/images/Dockerfile.build.controller.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ LABEL description="The Docker image to deploy the antrea-controller with code co

USER root

RUN mkdir -p /tmp/coverage
COPY --from=antrea-build /antrea/bin/antrea-controller /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antctl /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antrea-controller-coverage /usr/local/bin/
COPY --from=antrea-build /antrea/bin/antctl-coverage /usr/local/bin/
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /
RUN mkdir -p /tmp/coverage

ENTRYPOINT [ "/run_cov_binary.sh" ]
5 changes: 3 additions & 2 deletions build/images/Dockerfile.build.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ COPY . /antrea
# Build antctl first in order to share an extra layer with
# build/images/Dockerfile.build.agent.coverage and build/images/Dockerfile.build.controller.coverage.
RUN make antctl-linux antctl-instr-binary && mv bin/antctl-linux bin/antctl

# Then build antrea-agent and antrea-cni, in order to share an extra layer with
# build/images/Dockerfile.build.agent.coverage.
RUN make antrea-agent antrea-cni antrea-agent-instr-binary
Expand All @@ -40,9 +41,9 @@ LABEL description="The Docker image to deploy the Antrea CNI with code coverage

USER root

RUN mkdir -p /tmp/coverage
COPY build/images/scripts/* /usr/local/bin/
COPY --from=antrea-build /antrea/bin/* /usr/local/bin/
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /
RUN mkdir -p /tmp/coverage

ENTRYPOINT [ "/run_cov_binary.sh" ]
ENTRYPOINT [ "/run_cov_binary.sh" ]
2 changes: 1 addition & 1 deletion build/images/flow-aggregator/Dockerfile.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ LABEL description="The docker image for the flow aggregator with code coverage m

USER root

RUN mkdir -p /tmp/coverage
COPY --from=flow-aggregator-build /antrea/bin/flow-aggregator* /usr/local/bin/
COPY --from=flow-aggregator-build /antrea/bin/antctl* /usr/local/bin/
COPY --from=flow-aggregator-build /antrea/test/e2e/utils/run_cov_binary.sh /
RUN mkdir -p /tmp/coverage

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6962,6 +6962,7 @@ spec:
add:
- SYS_MODULE
env:
# If coverage is enabled, provide coverage directory variable needed by Go
# SKIP_CNI_BINARIES takes in values as a comma separated list of
# binaries that need to be skipped for installation, e.g. "portmap, bandwidth".
- name: SKIP_CNI_BINARIES
Expand Down Expand Up @@ -7008,6 +7009,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# If coverage is enabled, provide coverage directory variable needed by Go
resources:
requests:
cpu: 200m
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6961,6 +6961,7 @@ spec:
add:
- SYS_MODULE
env:
# If coverage is enabled, provide coverage directory variable needed by Go
# SKIP_CNI_BINARIES takes in values as a comma separated list of
# binaries that need to be skipped for installation, e.g. "portmap, bandwidth".
- name: SKIP_CNI_BINARIES
Expand Down Expand Up @@ -7007,6 +7008,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# If coverage is enabled, provide coverage directory variable needed by Go
- name: "ANTREA_CLOUD_EKS"
value: "true"
resources:
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6959,6 +6959,7 @@ spec:
add:
- SYS_MODULE
env:
# If coverage is enabled, provide coverage directory variable needed by Go
# SKIP_CNI_BINARIES takes in values as a comma separated list of
# binaries that need to be skipped for installation, e.g. "portmap, bandwidth".
- name: SKIP_CNI_BINARIES
Expand Down Expand Up @@ -7006,6 +7007,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# If coverage is enabled, provide coverage directory variable needed by Go
resources:
requests:
cpu: 200m
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6973,6 +6973,7 @@ spec:
add:
- SYS_MODULE
env:
# If coverage is enabled, provide coverage directory variable needed by Go
# SKIP_CNI_BINARIES takes in values as a comma separated list of
# binaries that need to be skipped for installation, e.g. "portmap, bandwidth".
- name: SKIP_CNI_BINARIES
Expand Down Expand Up @@ -7020,6 +7021,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# If coverage is enabled, provide coverage directory variable needed by Go
# Pre-shared key for IPsec IKE.
- name: ANTREA_IPSEC_PSK
valueFrom:
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6959,6 +6959,7 @@ spec:
add:
- SYS_MODULE
env:
# If coverage is enabled, provide coverage directory variable needed by Go
# SKIP_CNI_BINARIES takes in values as a comma separated list of
# binaries that need to be skipped for installation, e.g. "portmap, bandwidth".
- name: SKIP_CNI_BINARIES
Expand Down Expand Up @@ -7006,6 +7007,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# If coverage is enabled, provide coverage directory variable needed by Go
resources:
requests:
cpu: 200m
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/flow-aggregator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
command:
- flow-aggregator
env:
- name: POD_NAME
valueFrom:
Expand Down
2 changes: 1 addition & 1 deletion hack/git_client_side_hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ do
RANGE="$REMOTE_SHA..$LOCAL_SHA"
fi

NOT_SIGNED_OFF=$(git rev-list --no-merges --grep="^Signed-off-by: " --invert-grep "$RANGE")
NOT_SIGNED_OFF=$(git rev-list --no-merges --author "$AUTHOR" --grep="^Signed-off-by: " --invert-grep "$RANGE")
if [ -n "$NOT_SIGNED_OFF" ]
then
echo >&2 "ERROR: The following commits have no DCO sign-off:"
Expand Down
2 changes: 1 addition & 1 deletion multicluster/build/images/Dockerfile.build.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ LABEL description="The Docker image to deploy the Antrea Multi-cluster Controlle

USER root

RUN mkdir -p /tmp/coverage
COPY --from=antrea-build /antrea/multicluster/bin/antrea-mc-controller-coverage /
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /
RUN mkdir -p /tmp/coverage

ENTRYPOINT [ "/run_cov_binary.sh" ]
7 changes: 4 additions & 3 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ func (data *TestData) killProcessAndCollectCovFiles(namespace, podName, containe
}

log.Infof("Copying coverage files from Pod '%s'", podName)
if err := data.collectAntctlCovFiles(podName, containerName, namespace, covDir); err != nil {
if err := data.collectCovFiles(podName, containerName, namespace, covDir); err != nil {
return fmt.Errorf("error when copying antctl coverage files: %v", err)
}

Expand Down Expand Up @@ -2715,8 +2715,8 @@ func (data *TestData) gracefulExitFlowAggregator(covDir string) error {
return nil
}

// collectAntctlCovFiles collects coverage files for the antctl binary from the Pod and saves them to the coverage directory
func (data *TestData) collectAntctlCovFiles(podName string, containerName string, nsName string, covDir string) error {
// collectCovFiles collects coverage files from the Pod and saves them to the coverage directory
func (data *TestData) collectCovFiles(podName string, containerName string, nsName string, covDir string) error {
// copy antctl coverage files from Pod to the coverage directory
cmds := []string{"bash", "-c", "find /tmp/coverage -mindepth 1"}
stdout, stderr, err := data.RunCommandFromPod(nsName, podName, containerName, cmds)
Expand Down Expand Up @@ -2763,6 +2763,7 @@ func (data *TestData) collectAntctlCovFilesFromControlPlaneNode(covDir string) e
cmd = fmt.Sprintf("find %s -mindepth 1 -exec basename {} ';'", cpNodeCoverageDir)
}
rc, stdout, stderr, err := data.RunCommandOnNode(controlPlaneNodeName(), cmd)
fmt.Println("STDOUT: ", stdout)
if err != nil || rc != 0 {
return fmt.Errorf("error when running this find command '%s' on control-plane Node '%s', stderr: <%v>, err: <%v>", cmd, controlPlaneNodeName(), stderr, err)

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/utils/run_cov_binary.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/usr/bin/env bash

# Copyright 2024 Antrea Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script is meant to wrap a coverage instrumented binary.
# When the main process is killed, the script will start sleeping until a signal
# is received, providing the opportunity for the user to retrieve code coverage
Expand Down

0 comments on commit 96166f2

Please sign in to comment.