Skip to content

Commit

Permalink
Merge pull request #15544 from jmhbnz/remove_e2e_calc
Browse files Browse the repository at this point in the history
Remove e2e from coverage calculation
  • Loading branch information
serathius authored Mar 30, 2023
2 parents 418010b + 870d478 commit e11a323
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 243 deletions.
2 changes: 1 addition & 1 deletion pkg/osutil/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !linux || cov
//go:build !linux

package osutil

Expand Down
2 changes: 1 addition & 1 deletion pkg/osutil/signal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build linux && !cov
//go:build linux

package osutil

Expand Down
2 changes: 1 addition & 1 deletion scripts/codecov_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o pipefail
LOG_FILE=${1:-test-coverage.log}

# We collect the coverage
COVERDIR=covdir PASSES='build build_cov cov' ./scripts/test.sh 2>&1 | tee "${LOG_FILE}"
COVERDIR=covdir PASSES='build cov' ./scripts/test.sh 2>&1 | tee "${LOG_FILE}"
test_success="$?"

# We try to upload whatever we have:
Expand Down
26 changes: 1 addition & 25 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#
# Run code coverage
# COVERDIR must either be a absolute path or a relative path to the etcd root
# $ COVERDIR=coverage PASSES="build build_cov cov" ./scripts/test.sh
# $ COVERDIR=coverage PASSES="build cov" ./scripts/test.sh
# $ go tool cover -html ./coverage/cover.out
set -e

Expand Down Expand Up @@ -171,13 +171,6 @@ function grpcproxy_e2e_pass {

################# COVERAGE #####################################################

# Builds artifacts used by tests/e2e in coverage mode.
function build_cov_pass {
run_for_module "server" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcd_test" || return $?
run_for_module "etcdctl" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcdctl_test" || return $?
run_for_module "etcdutl" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcdutl_test"
}

# pkg_to_coverflag [prefix] [pkgs]
# produces name of .coverprofile file to be used for tests of this package
function pkg_to_coverprofileflag {
Expand Down Expand Up @@ -264,11 +257,6 @@ function cov_pass {
return 255
fi

if [ ! -f "bin/etcd_test" ]; then
log_error "etcd_test binary not found. Call: PASSES='build_cov' ./scripts/test.sh"
return 255
fi

local coverdir
coverdir=$(readlink -f "${COVERDIR}")
mkdir -p "${coverdir}"
Expand Down Expand Up @@ -298,18 +286,6 @@ function cov_pass {
run_for_module "tests" go_test "./integration/..." "parallel" "pkg_to_coverprofileflag integration_cluster_proxy" \
-tags cluster_proxy -timeout=30m "${gocov_build_flags[@]}" || failed="$failed integration_cluster_proxy"

log_callout "[$(date)] Collecting coverage from e2e tests ..."
# We don't pass 'gocov_build_flags' nor 'pkg_to_coverprofileflag' here,
# as the coverage is collected from the ./bin/etcd_test & ./bin/etcdctl_test internally spawned.
mkdir -p "${coverdir}/e2e"
COVERDIR="${coverdir}/e2e" run_for_module "tests" go_test "./e2e/..." "keep_going" : -tags=cov -timeout 30m "$@" || failed="$failed tests_e2e"
split_dir "${coverdir}/e2e" 10

log_callout "[$(date)] Collecting coverage from e2e tests with proxy ..."
mkdir -p "${coverdir}/e2e_proxy"
COVERDIR="${coverdir}/e2e_proxy" run_for_module "tests" go_test "./e2e/..." "keep_going" : -tags="cov cluster_proxy" -timeout 30m "$@" || failed="$failed tests_e2e_proxy"
split_dir "${coverdir}/e2e_proxy" 10

local cover_out_file="${coverdir}/all.coverprofile"
merge_cov "${coverdir}"

Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/ctl_v3_completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !cov

package e2e

import (
Expand Down
114 changes: 0 additions & 114 deletions tests/e2e/ctl_v3_watch_cov_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions tests/e2e/ctl_v3_watch_no_cov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !cov

package e2e

import (
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/v3_cipher_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !cov && !cluster_proxy
//go:build !cluster_proxy

package e2e

Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/zap_logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !cov

package e2e

import (
Expand Down
20 changes: 20 additions & 0 deletions tests/framework/e2e/etcd_spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ var (
additionalArgs func() ([]string, error)
)

const noOutputLineCount = 0 // regular binaries emit no extra lines

func init() {
initBinPath = initBinPathNoCov
additionalArgs = additionalArgsNoCov
}

func initBinPathNoCov(binDir string) binPath {
return binPath{
Etcd: binDir + "/etcd",
EtcdLastRelease: binDir + "/etcd-last-release",
Etcdctl: binDir + "/etcdctl",
Etcdutl: binDir + "/etcdutl",
}
}

func additionalArgsNoCov() ([]string, error) {
return []string{}, nil
}

func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
return SpawnNamedCmd(strings.Join(args, "_"), args, envVars)
}
Expand Down
57 changes: 0 additions & 57 deletions tests/framework/e2e/etcd_spawn_cov.go

This file was deleted.

37 changes: 0 additions & 37 deletions tests/framework/e2e/etcd_spawn_nocov.go

This file was deleted.

0 comments on commit e11a323

Please sign in to comment.