mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13693 from chaochn47/fix_coverage
Fix coverage failures
This commit is contained in:
commit
2923960ecd
@ -18,7 +18,7 @@ GO_BUILD_ENV=("CGO_ENABLED=0" "GO_BUILD_FLAGS=${GO_BUILD_FLAGS}" "GOOS=${GOOS}"
|
||||
toggle_failpoints() {
|
||||
mode="$1"
|
||||
if command -v gofail >/dev/null 2>&1; then
|
||||
run gofail "$mode" server/etcdserver/ server/mvcc/backend/
|
||||
run gofail "$mode" server/etcdserver/ server/storage/backend/
|
||||
elif [[ "$mode" != "disable" ]]; then
|
||||
log_error "FAILPOINTS set but gofail not found"
|
||||
exit 1
|
||||
|
@ -242,7 +242,7 @@ function split_dir {
|
||||
local num="${2}"
|
||||
local i=0
|
||||
for f in "${d}/"*; do
|
||||
local g=$(( "${i}" % "${num}" ))
|
||||
local g=$(( i % num ))
|
||||
mkdir -p "${d}_${g}"
|
||||
mv "${f}" "${d}_${g}/"
|
||||
(( i++ ))
|
||||
|
@ -31,29 +31,41 @@ import (
|
||||
)
|
||||
|
||||
func TestSerializableReadWithoutQuorum(t *testing.T) {
|
||||
// Initialize a cluster with 3 members
|
||||
epc, err := e2e.InitEtcdProcessCluster(t, e2e.NewConfigAutoTLS())
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to initilize the etcd cluster: %v", err)
|
||||
tcs := []struct {
|
||||
name string
|
||||
testFunc func(cx ctlCtx)
|
||||
}{
|
||||
{
|
||||
name: "serializableReadTest",
|
||||
testFunc: serializableReadTest,
|
||||
},
|
||||
{
|
||||
name: "linearizableReadTest",
|
||||
testFunc: linearizableReadTest,
|
||||
},
|
||||
}
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// Initialize a cluster with 3 members
|
||||
epc, err := e2e.InitEtcdProcessCluster(t, e2e.NewConfigAutoTLS())
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to initilize the etcd cluster: %v", err)
|
||||
}
|
||||
|
||||
// Remove two members, so that only one etcd will get started
|
||||
epc.Procs = epc.Procs[:1]
|
||||
// Remove two members, so that only one etcd will get started
|
||||
epc.Procs = epc.Procs[:1]
|
||||
|
||||
// Start the etcd cluster with only one member
|
||||
if err := epc.Start(); err != nil {
|
||||
t.Fatalf("Failed to start the etcd cluster: %v", err)
|
||||
// Start the etcd cluster with only one member
|
||||
if err := epc.Start(); err != nil {
|
||||
t.Fatalf("Failed to start the etcd cluster: %v", err)
|
||||
}
|
||||
|
||||
// construct the ctl context
|
||||
cx := getDefaultCtlCtx(t)
|
||||
cx.epc = epc
|
||||
runCtlTest(t, tc.testFunc, nil, cx)
|
||||
})
|
||||
}
|
||||
|
||||
// construct the ctl context
|
||||
cx := getDefaultCtlCtx(t)
|
||||
cx.epc = epc
|
||||
|
||||
// run serializable test and wait for result
|
||||
runCtlTest(t, serializableReadTest, nil, cx)
|
||||
|
||||
// run linearizable test and wait for result
|
||||
runCtlTest(t, linearizableReadTest, nil, cx)
|
||||
}
|
||||
|
||||
func serializableReadTest(cx ctlCtx) {
|
||||
@ -65,7 +77,7 @@ func serializableReadTest(cx ctlCtx) {
|
||||
|
||||
func linearizableReadTest(cx ctlCtx) {
|
||||
cx.quorum = true
|
||||
if err := ctlV3Get(cx, []string{"key1"}, []kv{}...); err == nil {
|
||||
cx.t.Error("linearizableReadTest is expected to fail, but it succeeded")
|
||||
if err := ctlV3GetWithErr(cx, []string{"key"}, []string{"retrying of unary invoker failed"}); err != nil { // expect errors
|
||||
cx.t.Fatalf("ctlV3GetWithErr error (%v)", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user