Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functiona: fix flaky tests #11006

Merged
merged 3 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions functional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ agent-configs:
initial-cluster: s1=https://127.0.0.1:1381,s2=https://127.0.0.1:2381,s3=https://127.0.0.1:3381
initial-cluster-state: new
initial-cluster-token: tkn
snapshot-count: 10000
snapshot-count: 2000
quota-backend-bytes: 10740000000 # 10 GiB
pre-vote: true
initial-corrupt-check: true
Expand Down Expand Up @@ -80,7 +80,7 @@ agent-configs:
initial-cluster: s1=https://127.0.0.1:1381,s2=https://127.0.0.1:2381,s3=https://127.0.0.1:3381
initial-cluster-state: new
initial-cluster-token: tkn
snapshot-count: 10000
snapshot-count: 2000
quota-backend-bytes: 10740000000 # 10 GiB
pre-vote: true
initial-corrupt-check: true
Expand Down Expand Up @@ -131,7 +131,7 @@ agent-configs:
initial-cluster: s1=https://127.0.0.1:1381,s2=https://127.0.0.1:2381,s3=https://127.0.0.1:3381
initial-cluster-state: new
initial-cluster-token: tkn
snapshot-count: 10000
snapshot-count: 2000
quota-backend-bytes: 10740000000 # 10 GiB
pre-vote: true
initial-corrupt-check: true
Expand Down
23 changes: 22 additions & 1 deletion functional/agent/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package agent

import (
"io"
"net"
"net/url"
"os"
Expand All @@ -36,7 +37,8 @@ func archive(baseDir, etcdLogPath, dataDir string) error {
return err
}

if err := os.Rename(etcdLogPath, filepath.Join(dir, "etcd.log")); err != nil {
dst := filepath.Join(dir, "etcd.log")
if err := copyFile(etcdLogPath, dst); err != nil {
if !os.IsNotExist(err) {
return err
}
Expand Down Expand Up @@ -79,6 +81,25 @@ func getURLAndPort(addr string) (urlAddr *url.URL, port int, err error) {
return urlAddr, port, err
}

func copyFile(src, dst string) error {
f, err := os.Open(src)
if err != nil {
return err
}
defer f.Close()

w, err := os.Create(dst)
if err != nil {
return err
}
defer w.Close()

if _, err = io.Copy(w, f); err != nil {
return err
}
return w.Sync()
}

func cleanPageCache() error {
// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
// https://github.com/torvalds/linux/blob/master/fs/drop_caches.c
Expand Down
10 changes: 10 additions & 0 deletions functional/rpcpb/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/clientv3/snapshot"
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
"go.etcd.io/etcd/pkg/logutil"
"go.etcd.io/etcd/pkg/transport"

"github.com/dustin/go-humanize"
Expand Down Expand Up @@ -94,10 +95,19 @@ func (m *Member) CreateEtcdClientConfig(opts ...grpc.DialOption) (cfg *clientv3.
}
}

// TODO: make this configurable
level := "error"
if os.Getenv("ETCD_CLIENT_DEBUG") != "" {
level = "debug"
}
lcfg := logutil.DefaultZapLoggerConfig
lcfg.Level = zap.NewAtomicLevelAt(logutil.ConvertToZapLevel(level))

cfg = &clientv3.Config{
Endpoints: []string{m.EtcdClientEndpoint},
DialTimeout: 10 * time.Second,
DialOptions: opts,
LogConfig: &lcfg,
}
if secure {
// assume save TLS assets are already stord on disk
Expand Down
4 changes: 2 additions & 2 deletions functional/tester/cluster_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ func (clus *Cluster) doRound() error {
)

// with network delay, some ongoing requests may fail
// only return error, if more than 10% of QPS requests fail
if cnt > int(clus.Tester.StressQPS)/10 {
// only return error, if more than 30% of QPS requests fail
if cnt > int(float64(clus.Tester.StressQPS)*0.3) {
return fmt.Errorf("expected no error in %q, got %q", fcase.String(), ess)
}
}
Expand Down