Merge pull request #11006 from gyuho/functional

functiona: fix flaky tests
This commit is contained in:
Gyuho Lee 2019-08-08 09:08:23 -07:00 committed by GitHub
commit 1c65af7acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 6 deletions

View File

@ -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
@ -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
@ -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

View File

@ -15,6 +15,7 @@
package agent
import (
"io"
"net"
"net/url"
"os"
@ -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
}
@ -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

View File

@ -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"
@ -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

View File

@ -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)
}
}