Skip to content

Commit

Permalink
Remove bincover
Browse files Browse the repository at this point in the history
Signed-off-by: Shikhar Soni <[email protected]>
  • Loading branch information
shikharish committed Mar 15, 2024
1 parent 0886d74 commit baae5b5
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 234 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ bin
.golangci-bin
.coverage/
.trivy-bin

coverage/
coverage-without-sigint/
.DS_Store

# VIM
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ antrea-agent-simulator:
.PHONY: antrea-agent-instr-binary
antrea-agent-instr-binary:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) test -tags testbincover -covermode count -coverpkg=antrea.io/antrea/pkg/... -c -o $(BINDIR)/antrea-agent-coverage $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/antrea-agent
GOOS=linux $(GO) build -cover -o $(BINDIR)/antrea-agent-coverage -coverpkg=antrea.io/antrea/cmd/antrea-agent,antrea.io/antrea/pkg/... $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/antrea-agent

.PHONY: antrea-controller
antrea-controller:
Expand All @@ -120,7 +120,7 @@ antrea-controller:
.PHONY: antrea-controller-instr-binary
antrea-controller-instr-binary:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) test -tags testbincover -covermode count -coverpkg=antrea.io/antrea/pkg/... -c -o $(BINDIR)/antrea-controller-coverage $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/antrea-controller
GOOS=linux $(GO) build -cover -o $(BINDIR)/antrea-controller-coverage -coverpkg=antrea.io/antrea/cmd/antrea-controller,antrea.io/antrea/pkg/... $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/antrea-controller

.PHONY: antrea-cni
antrea-cni:
Expand All @@ -135,7 +135,7 @@ antrea-cni-release:
.PHONY: antctl-instr-binary
antctl-instr-binary:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) test -tags testbincover -covermode count -coverpkg=antrea.io/antrea/pkg/... -c -o $(BINDIR)/antctl-coverage $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/antctl
GOOS=linux $(GO) build -cover -o $(BINDIR)/antctl-coverage -coverpkg=antrea.io/antrea/cmd/antctl,antrea.io/antrea/pkg/... $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/antctl

.PHONY: windows-bin
windows-bin:
Expand All @@ -150,7 +150,7 @@ flow-aggregator:
.PHONY: flow-aggregator-instr-binary
flow-aggregator-instr-binary:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) test -tags testbincover -covermode count -coverpkg=antrea.io/antrea/pkg/... -c -o $(BINDIR)/flow-aggregator-coverage $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/flow-aggregator
GOOS=linux $(GO) build -cover -o $(BINDIR)/flow-aggregator-coverage -coverpkg=antrea.io/antrea/cmd/flow-aggregator,antrea.io/antrea/pkg/... $(GOFLAGS) -ldflags '$(LDFLAGS)' antrea.io/antrea/cmd/flow-aggregator

.PHONY: test-unit test-integration
ifeq ($(UNAME_S),Linux)
Expand Down
21 changes: 19 additions & 2 deletions build/charts/antrea/templates/agent/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ spec:
- name: {{ $k | quote }}
value: {{ $v | quote }}
{{- end }}
# If coverage is enabled, provide coverage directory variable needed by Go
{{- if ((.Values.testing).coverage) }}
- name: GOCOVERDIR
value: /tmp/coverage
{{- end }}
# 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 @@ -130,8 +135,15 @@ spec:
image: {{ include "antreaAgentImage" . | quote }}
imagePullPolicy: {{ include "antreaAgentImagePullPolicy" . }}
{{- if ((.Values.testing).coverage) }}
command: ["/bin/sh"]
args: ["-c", "sleep 2; antrea-agent-coverage -test.run=TestBincoverRunMain -test.coverprofile=antrea-agent.cov.out -args-file=/agent-arg-file; while true; do sleep 5 & wait $!; done"]
args:
- "antrea-agent-coverage"
- "--config=/etc/antrea/antrea-agent.conf"
- "--logtostderr=false"
- "--log_dir=/var/log/antrea"
- "--alsologtostderr"
- "--log_file_max_size=100"
- "--log_file_max_num=4"
- "--v=4"
{{- else}}
command: ["antrea-agent"]
# Log to both "/var/log/antrea/" and stderr (so "kubectl logs" can work).-
Expand Down Expand Up @@ -163,6 +175,11 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# If coverage is enabled, provide coverage directory variable needed by Go
{{- if ((.Values.testing).coverage) }}
- name: GOCOVERDIR
value: /tmp/coverage
{{- end }}
{{- if eq .Values.trafficEncryptionMode "ipsec" }}
# Pre-shared key for IPsec IKE.
- name: ANTREA_IPSEC_PSK
Expand Down
15 changes: 13 additions & 2 deletions build/charts/antrea/templates/controller/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ spec:
imagePullPolicy: {{ include "antreaControllerImagePullPolicy" . }}
resources: {{- .Values.controller.antreaController.resources | toYaml | nindent 12 }}
{{- if ((.Values.testing).coverage) }}
command: ["/bin/sh"]
args: ["-c", "antrea-controller-coverage -test.run=TestBincoverRunMain -test.coverprofile=antrea-controller.cov.out -args-file=/controller-arg-file; while true; do sleep 5 & wait $!; done"]
args:
- "antrea-controller-coverage"
- "--config=/etc/antrea/antrea-controller.conf"
- "--logtostderr=false"
- "--log_dir=/var/log/antrea"
- "--alsologtostderr"
- "--log_file_max_size=100"
- "--log_file_max_num=4"
- "--v=4"
{{- else }}
command: ["antrea-controller"]
# Log to both "/var/log/antrea/" and stderr (so "kubectl logs" can work).
Expand All @@ -85,6 +92,10 @@ spec:
{{- end }}
env:
# Provide pod and node information for clusterinformation CRD.
{{- if ((.Values.testing).coverage) }}
- name: GOCOVERDIR
value: /tmp/coverage
{{- end }}
- name: POD_NAME
valueFrom:
fieldRef:
Expand Down
17 changes: 15 additions & 2 deletions build/charts/flow-aggregator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ spec:
image: {{ include "flowAggregatorImage" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.testing.coverage }}
command: [ "/bin/sh" ]
args: [ "-c", "flow-aggregator-coverage -test.run=TestBincoverRunMain -test.coverprofile=flow-aggregator.cov.out -args-file=/flow-aggregator-arg-file; while true; do sleep 5 & wait $!; done" ]
args:
- "flow-aggregator-coverage"
- "--config=/etc/antrea/flow-aggregator.conf"
- "--logtostderr=false"
- "--log_dir=/var/log/antrea"
- "--alsologtostderr"
- "--log_file_max_size=100"
- "--log_file_max_num=4"
- "--v=4"
{{- else }}
command: [ "flow-aggregator" ]
args:
- --config
- /etc/flow-aggregator/flow-aggregator.conf
Expand All @@ -44,6 +52,11 @@ spec:
{{- end }}
{{- end }}
env:
# If coverage is enabled, provide coverage directory variable needed by Go
{{- if ((.Values.testing).coverage) }}
- name: GOCOVERDIR
value: /tmp/coverage
{{- end }}
- name: POD_NAME
valueFrom:
fieldRef:
Expand Down
5 changes: 4 additions & 1 deletion build/images/Dockerfile.build.agent.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +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/coverage/agent-arg-file /
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /

ENTRYPOINT [ "/./run_cov_binary.sh" ]
6 changes: 4 additions & 2 deletions build/images/Dockerfile.build.controller.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ RUN go mod download
COPY . /antrea

RUN make antctl-linux antctl-instr-binary && mv bin/antctl-linux bin/antctl

RUN make antrea-controller antrea-controller-instr-binary

FROM ubuntu:22.04
Expand All @@ -35,8 +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/coverage/controller-arg-file /
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /

ENTRYPOINT [ "/./run_cov_binary.sh" ]
7 changes: 4 additions & 3 deletions build/images/Dockerfile.build.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ 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 @@ -41,7 +40,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/coverage/controller-arg-file /
COPY --from=antrea-build /antrea/test/e2e/coverage/agent-arg-file /
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /

ENTRYPOINT [ "/./run_cov_binary.sh" ]
5 changes: 4 additions & 1 deletion build/images/flow-aggregator/Dockerfile.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ 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/test/e2e/coverage/flow-aggregator-arg-file /
COPY --from=flow-aggregator-build /antrea/bin/antctl* /usr/local/bin/
COPY --from=antrea-build /antrea/test/e2e/utils/run_cov_binary.sh /

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT [ "/./run_cov_binary.sh" ]
9 changes: 9 additions & 0 deletions ci/kind/test-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ function run_test {
EXTRA_ARGS="$vlan_args --external-server-ips $(docker inspect external-server -f '{{.NetworkSettings.Networks.kind.IPAddress}},{{.NetworkSettings.Networks.kind.GlobalIPv6Address}}')"

go test -v -timeout=$timeout $RUN_OPT antrea.io/antrea/test/e2e $flow_visibility_args -provider=kind --logs-export-dir=$ANTREA_LOG_DIR --skip-cases=$skiplist $coverage_args $EXTRA_ARGS

if $coverage; then
pushd $ANTREA_COV_DIR
for dir in */; do
go tool covdata textfmt -i="${dir}" -o "${dir%?}_$(date +%Y-%m-%d_%H-%M-%S).cov.out"
rm -rf "${dir}";
done
popd
fi
}

if [[ "$mode" == "" ]] || [[ "$mode" == "encap" ]]; then
Expand Down
28 changes: 0 additions & 28 deletions cmd/antctl/bincover_run_main_test.go

This file was deleted.

28 changes: 0 additions & 28 deletions cmd/antrea-agent/bincover_run_main_test.go

This file was deleted.

28 changes: 0 additions & 28 deletions cmd/antrea-controller/bincover_run_main_test.go

This file was deleted.

28 changes: 0 additions & 28 deletions cmd/flow-aggregator/bincover_run_main_test.go

This file was deleted.

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 --author "$AUTHOR" --grep="^Signed-off-by: " --invert-grep "$RANGE")
NOT_SIGNED_OFF=$(git rev-list --no-merges --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/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bin: fmt vet ## Build manager binary.

.PHONY: antrea-mc-instr-binary
antrea-mc-instr-binary:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go test -tags testbincover -covermode count -coverpkg=antrea.io/antrea/multicluster/... -c -o bin/antrea-mc-controller-coverage antrea.io/antrea/multicluster/cmd/...
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -cover -coverpkg=antrea.io/antrea/multicluster/...,antrea.io/antrea/multicluster/cmd/... -o bin/antrea-mc-controller-coverage1 antrea.io/antrea/multicluster/cmd/...

run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
Expand Down
5 changes: 5 additions & 0 deletions multicluster/build/images/Dockerfile.build.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ 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 /

ENTRYPOINT [ "/./run_cov_binary.sh" ]

Loading

0 comments on commit baae5b5

Please sign in to comment.