Skip to content

Commit

Permalink
wip: 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 10, 2024
1 parent 23eda62 commit 2bd4862
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 188 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ jobs:
mkdir log
mkdir test-e2e-encap-coverage
ANTREA_LOG_DIR=$PWD/log ANTREA_COV_DIR=$PWD/test-e2e-encap-coverage ./ci/kind/test-e2e-kind.sh --encap-mode encap --coverage
- name: Generate coverage files
run: |
cd test-e2e-encap-coverage
for dir in */; go tool covdata textfmt -i="${dir}" -o "${dir%?}_$(date +%Y-%m-%d_%H-%M-%S).out" && rm -rf "${dir}"
cd -
- name: Tar coverage files
run: tar -czf test-e2e-encap-coverage.tar.gz test-e2e-encap-coverage
- name: Upload coverage for test-e2e-encap-coverage
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ WIN_BUILD_OVS_TAG := $(NANOSERVER_VERSION)-$(WIN_OVS_VERSION)
GIT_HOOKS := $(shell find hack/git_client_side_hooks -type f -print)
DOCKER_NETWORK ?= default
TRIVY_TARGET_IMAGE ?=
GOCOVERDIR ?= "/tmp/coverage"

GOLANGCI_LINT_VERSION := v1.54.0
GOLANGCI_LINT_BINDIR := $(CURDIR)/.golangci-bin
Expand Down Expand Up @@ -106,7 +107,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 +121,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 +136,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 +151,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
6 changes: 5 additions & 1 deletion build/charts/antrea/templates/agent/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ spec:
{{- 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: GOCOVERDIR
value: /tmp/coverage
- name: SKIP_CNI_BINARIES
value: {{ join "," .Values.cni.skipBinaries | quote }}
{{- if .Values.agent.dontLoadKernelModules }}
Expand Down Expand Up @@ -131,7 +133,7 @@ spec:
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: ["-c", "sleep 2; antrea-agent-coverage $(cat /agent-arg-file | tr '\n' ' '); while true; do sleep 5 & wait $!; done"]
{{- else}}
command: ["antrea-agent"]
# Log to both "/var/log/antrea/" and stderr (so "kubectl logs" can work).-
Expand Down Expand Up @@ -163,6 +165,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: GOCOVERDIR
value: /tmp/coverage
{{- if eq .Values.trafficEncryptionMode "ipsec" }}
# Pre-shared key for IPsec IKE.
- name: ANTREA_IPSEC_PSK
Expand Down
4 changes: 3 additions & 1 deletion build/charts/antrea/templates/controller/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
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: ["-c", "antrea-controller-coverage $(cat /controller-arg-file | tr '\n' ' '); while true; do sleep 5 & wait $!; done"]
{{- else }}
command: ["antrea-controller"]
# Log to both "/var/log/antrea/" and stderr (so "kubectl logs" can work).
Expand All @@ -85,6 +85,8 @@ spec:
{{- end }}
env:
# Provide pod and node information for clusterinformation CRD.
- name: GOCOVERDIR
value: /tmp/coverage
- name: POD_NAME
valueFrom:
fieldRef:
Expand Down
4 changes: 3 additions & 1 deletion build/charts/flow-aggregator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
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: [ "-c", "flow-aggregator-coverage $(cat /flow-aggregator-arg-file | tr '\n' ' '); while true; do sleep 5 & wait $!; done" ]
{{- else }}
args:
- --config
Expand All @@ -44,6 +44,8 @@ spec:
{{- end }}
{{- end }}
env:
- name: GOCOVERDIR
value: /tmp/coverage
- name: POD_NAME
valueFrom:
fieldRef:
Expand Down
1 change: 1 addition & 0 deletions build/images/Dockerfile.build.agent.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ 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/
Expand Down
2 changes: 1 addition & 1 deletion 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,6 +34,7 @@ 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/
Expand Down
2 changes: 1 addition & 1 deletion 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,6 +40,7 @@ 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 /
Expand Down
1 change: 1 addition & 0 deletions build/images/flow-aggregator/Dockerfile.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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/
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 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
1 change: 1 addition & 0 deletions multicluster/build/images/Dockerfile.build.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ 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 /
28 changes: 0 additions & 28 deletions multicluster/cmd/multicluster-controller/bincover_run_main_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ spec:
spec:
containers:
- command: ["/bin/sh"]
args: ["-c", "/antrea-mc-controller-coverage -test.run=TestBincoverRunMain -test.coverprofile=antrea-mc-controller.cov.out leader --config=/controller_manager_config.yaml; while true; do sleep 5 & wait $!; done"]
args: ["-c", "/antrea-mc-controller-coverage leader --config=/controller_manager_config.yaml; while true; do sleep 5 & wait $!; done"]
name: antrea-mc-controller
image: antrea/antrea-mc-controller-coverage:latest
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ spec:
spec:
containers:
- command: ["/bin/sh"]
args: ["-c", "/antrea-mc-controller-coverage -test.run=TestBincoverRunMain -test.coverprofile=antrea-mc-controller.cov.out leader --config=/controller_manager_config.yaml; while true; do sleep 5 & wait $!; done"]
args: ["-c", "/antrea-mc-controller-coverage leader --config=/controller_manager_config.yaml; while true; do sleep 5 & wait $!; done"]
name: antrea-mc-controller
image: antrea/antrea-mc-controller-coverage:latest
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ spec:
spec:
containers:
- command: ["/bin/sh"]
args: ["-c", "/antrea-mc-controller-coverage -test.run=TestBincoverRunMain -test.coverprofile=antrea-mc-controller.cov.out member --config=/controller_manager_config.yaml; while true; do sleep 5 & wait $!; done"]
args: ["-c", "/antrea-mc-controller-coverage member --config=/controller_manager_config.yaml; while true; do sleep 5 & wait $!; done"]
name: antrea-mc-controller
image: antrea/antrea-mc-controller-coverage:latest
15 changes: 7 additions & 8 deletions test/e2e/antctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/json"
"fmt"
"net"
"path"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -117,13 +116,13 @@ func runAntctl(podName string, cmds []string, data *TestData) (string, string, e
}

func antctlCoverageArgs(antctlPath string, covDir string) []string {
const timeFormat = "20060102T150405Z0700"
timestamp := time.Now().Format(timeFormat)
covFile := fmt.Sprintf("antctl-%s.out", timestamp)
if covDir != "" {
covFile = path.Join(covDir, covFile)
}
return []string{antctlPath, "-test.run=TestBincoverRunMain", fmt.Sprintf("-test.coverprofile=%s", covFile)}
// const timeFormat = "20060102T150405Z0700"
// timestamp := time.Now().Format(timeFormat)
// covFile := fmt.Sprintf("antctl-%s.out", timestamp)
// if covDir != "" {
// covFile = path.Join(covDir, covFile)
// }
return []string{antctlPath}
}

// testAntctlAgentLocalAccess ensures antctl is accessible in an agent Pod.
Expand Down
Loading

0 comments on commit 2bd4862

Please sign in to comment.