mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #15544 from jmhbnz/remove_e2e_calc
Remove e2e from coverage calculation
This commit is contained in:
commit
e11a32366e
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build !linux || cov
|
//go:build !linux
|
||||||
|
|
||||||
package osutil
|
package osutil
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build linux && !cov
|
//go:build linux
|
||||||
|
|
||||||
package osutil
|
package osutil
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ set -o pipefail
|
|||||||
LOG_FILE=${1:-test-coverage.log}
|
LOG_FILE=${1:-test-coverage.log}
|
||||||
|
|
||||||
# We collect the coverage
|
# 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="$?"
|
test_success="$?"
|
||||||
|
|
||||||
# We try to upload whatever we have:
|
# We try to upload whatever we have:
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#
|
#
|
||||||
# Run code coverage
|
# Run code coverage
|
||||||
# COVERDIR must either be a absolute path or a relative path to the etcd root
|
# 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
|
# $ go tool cover -html ./coverage/cover.out
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -171,13 +171,6 @@ function grpcproxy_e2e_pass {
|
|||||||
|
|
||||||
################# COVERAGE #####################################################
|
################# 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]
|
# pkg_to_coverflag [prefix] [pkgs]
|
||||||
# produces name of .coverprofile file to be used for tests of this package
|
# produces name of .coverprofile file to be used for tests of this package
|
||||||
function pkg_to_coverprofileflag {
|
function pkg_to_coverprofileflag {
|
||||||
@ -264,11 +257,6 @@ function cov_pass {
|
|||||||
return 255
|
return 255
|
||||||
fi
|
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
|
local coverdir
|
||||||
coverdir=$(readlink -f "${COVERDIR}")
|
coverdir=$(readlink -f "${COVERDIR}")
|
||||||
mkdir -p "${coverdir}"
|
mkdir -p "${coverdir}"
|
||||||
@ -298,18 +286,6 @@ function cov_pass {
|
|||||||
run_for_module "tests" go_test "./integration/..." "parallel" "pkg_to_coverprofileflag integration_cluster_proxy" \
|
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"
|
-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"
|
local cover_out_file="${coverdir}/all.coverprofile"
|
||||||
merge_cov "${coverdir}"
|
merge_cov "${coverdir}"
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build !cov
|
|
||||||
|
|
||||||
package e2e
|
package e2e
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,114 +0,0 @@
|
|||||||
// Copyright 2018 The etcd 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.
|
|
||||||
|
|
||||||
//go:build cov
|
|
||||||
|
|
||||||
package e2e
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"go.etcd.io/etcd/tests/v3/framework/e2e"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCtlV3Watch(t *testing.T) { testCtl(t, watchTest) }
|
|
||||||
func TestCtlV3WatchNoTLS(t *testing.T) { testCtl(t, watchTest, withCfg(*e2e.NewConfigNoTLS())) }
|
|
||||||
func TestCtlV3WatchClientTLS(t *testing.T) { testCtl(t, watchTest, withCfg(*e2e.NewConfigClientTLS())) }
|
|
||||||
func TestCtlV3WatchPeerTLS(t *testing.T) { testCtl(t, watchTest, withCfg(*e2e.NewConfigPeerTLS())) }
|
|
||||||
func TestCtlV3WatchTimeout(t *testing.T) { testCtl(t, watchTest, withDialTimeout(0)) }
|
|
||||||
|
|
||||||
func TestCtlV3WatchInteractive(t *testing.T) {
|
|
||||||
testCtl(t, watchTest, withInteractive())
|
|
||||||
}
|
|
||||||
func TestCtlV3WatchInteractiveNoTLS(t *testing.T) {
|
|
||||||
testCtl(t, watchTest, withInteractive(), withCfg(*e2e.NewConfigNoTLS()))
|
|
||||||
}
|
|
||||||
func TestCtlV3WatchInteractiveClientTLS(t *testing.T) {
|
|
||||||
testCtl(t, watchTest, withInteractive(), withCfg(*e2e.NewConfigClientTLS()))
|
|
||||||
}
|
|
||||||
func TestCtlV3WatchInteractivePeerTLS(t *testing.T) {
|
|
||||||
testCtl(t, watchTest, withInteractive(), withCfg(*e2e.NewConfigPeerTLS()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func watchTest(cx ctlCtx) {
|
|
||||||
tests := []struct {
|
|
||||||
puts []kv
|
|
||||||
envKey string
|
|
||||||
envRange string
|
|
||||||
args []string
|
|
||||||
|
|
||||||
wkv []kvExec
|
|
||||||
}{
|
|
||||||
{ // watch 1 key with env
|
|
||||||
puts: []kv{{"sample", "value"}},
|
|
||||||
envKey: "sample",
|
|
||||||
args: []string{"--rev", "1"},
|
|
||||||
wkv: []kvExec{{key: "sample", val: "value"}},
|
|
||||||
},
|
|
||||||
// coverage tests get extra arguments:
|
|
||||||
// ./bin/etcdctl_test -test.coverprofile=e2e.1525392462795198897.coverprofile -test.outputdir=../..
|
|
||||||
// do not test watch exec commands
|
|
||||||
{ // watch 3 keys by prefix, with env
|
|
||||||
puts: []kv{{"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"}},
|
|
||||||
envKey: "key",
|
|
||||||
args: []string{"--rev", "1", "--prefix"},
|
|
||||||
wkv: []kvExec{{key: "key1", val: "val1"}, {key: "key2", val: "val2"}, {key: "key3", val: "val3"}},
|
|
||||||
},
|
|
||||||
{ // watch 3 keys by range, with env
|
|
||||||
puts: []kv{{"key1", "val1"}, {"key3", "val3"}, {"key2", "val2"}},
|
|
||||||
envKey: "key",
|
|
||||||
envRange: "key3",
|
|
||||||
args: []string{"--rev", "1"},
|
|
||||||
wkv: []kvExec{{key: "key1", val: "val1"}, {key: "key2", val: "val2"}},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, tt := range tests {
|
|
||||||
donec := make(chan struct{})
|
|
||||||
go func(i int, puts []kv) {
|
|
||||||
for j := range puts {
|
|
||||||
if err := ctlV3Put(cx, puts[j].key, puts[j].val, ""); err != nil {
|
|
||||||
cx.t.Fatalf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(donec)
|
|
||||||
}(i, tt.puts)
|
|
||||||
|
|
||||||
unsetEnv := func() {}
|
|
||||||
if tt.envKey != "" || tt.envRange != "" {
|
|
||||||
if tt.envKey != "" {
|
|
||||||
os.Setenv("ETCDCTL_WATCH_KEY", tt.envKey)
|
|
||||||
unsetEnv = func() { os.Unsetenv("ETCDCTL_WATCH_KEY") }
|
|
||||||
}
|
|
||||||
if tt.envRange != "" {
|
|
||||||
os.Setenv("ETCDCTL_WATCH_RANGE_END", tt.envRange)
|
|
||||||
unsetEnv = func() { os.Unsetenv("ETCDCTL_WATCH_RANGE_END") }
|
|
||||||
}
|
|
||||||
if tt.envKey != "" && tt.envRange != "" {
|
|
||||||
unsetEnv = func() {
|
|
||||||
os.Unsetenv("ETCDCTL_WATCH_KEY")
|
|
||||||
os.Unsetenv("ETCDCTL_WATCH_RANGE_END")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := ctlV3Watch(cx, tt.args, tt.wkv...); err != nil {
|
|
||||||
if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
|
|
||||||
cx.t.Errorf("watchTest #%d: ctlV3Watch error (%v)", i, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsetEnv()
|
|
||||||
<-donec
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,8 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build !cov
|
|
||||||
|
|
||||||
package e2e
|
package e2e
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build !cov && !cluster_proxy
|
//go:build !cluster_proxy
|
||||||
|
|
||||||
package e2e
|
package e2e
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build !cov
|
|
||||||
|
|
||||||
package e2e
|
package e2e
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -28,6 +28,26 @@ var (
|
|||||||
additionalArgs func() ([]string, error)
|
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) {
|
func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
|
||||||
return SpawnNamedCmd(strings.Join(args, "_"), args, envVars)
|
return SpawnNamedCmd(strings.Join(args, "_"), args, envVars)
|
||||||
}
|
}
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
// Copyright 2017 The etcd 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.
|
|
||||||
|
|
||||||
//go:build cov
|
|
||||||
|
|
||||||
package e2e
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
|
||||||
"go.etcd.io/etcd/tests/v3/framework/testutils"
|
|
||||||
)
|
|
||||||
|
|
||||||
const noOutputLineCount = 2 // cov-enabled binaries emit PASS and coverage count lines
|
|
||||||
|
|
||||||
var (
|
|
||||||
coverDir = testutils.MustAbsPath(os.Getenv("COVERDIR"))
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
initBinPath = initBinPathCov
|
|
||||||
additionalArgs = additionalArgsCov
|
|
||||||
}
|
|
||||||
|
|
||||||
func initBinPathCov(binDir string) binPath {
|
|
||||||
return binPath{
|
|
||||||
Etcd: binDir + "/etcd_test",
|
|
||||||
EtcdLastRelease: binDir + "/etcd-last-release",
|
|
||||||
Etcdctl: binDir + "/etcdctl_test",
|
|
||||||
Etcdutl: binDir + "/etcdutl_test",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func additionalArgsCov() ([]string, error) {
|
|
||||||
if !fileutil.Exist(coverDir) {
|
|
||||||
return nil, fmt.Errorf("could not find coverage folder: %s", coverDir)
|
|
||||||
}
|
|
||||||
covArgs := []string{
|
|
||||||
fmt.Sprintf("-test.coverprofile=e2e.%v.coverprofile", time.Now().UnixNano()),
|
|
||||||
"-test.outputdir=" + coverDir,
|
|
||||||
}
|
|
||||||
return covArgs, nil
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
// Copyright 2017 The etcd 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.
|
|
||||||
|
|
||||||
//go:build !cov
|
|
||||||
|
|
||||||
package e2e
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user