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

functional: run tests with embedded etcd, add logger field #9572

Merged
merged 34 commits into from
Apr 17, 2018
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
575cf94
functional/rpcpb: add "*Etcd.EmbedConfig", and logger fields
gyuho Apr 15, 2018
3312810
functional/agent: handle "embed.Etcd", logger sync
gyuho Apr 15, 2018
82e84a0
pkg/logutil: add "NewGRPCLoggerV2FromZap", "NewRaftLogger"
gyuho Apr 15, 2018
041b906
*: configure server logger
gyuho Apr 15, 2018
d5d4025
CHANGELOG-3.4: highlight logger change
gyuho Apr 15, 2018
f879c1d
integration: use default logger "capnslog"
gyuho Apr 15, 2018
bdbed26
etcdserver: support structured logging
gyuho Apr 16, 2018
0dad8ab
pkg: support structured logger
gyuho Apr 16, 2018
c00c6cb
mvcc: support structured logger
gyuho Apr 16, 2018
fdbedac
wal: support structured logger
gyuho Apr 16, 2018
c68f625
rafthttp: support structured logger
gyuho Apr 16, 2018
ce8348e
raftsnap: support structured logger
gyuho Apr 16, 2018
f57fa6a
auth: support structured logger
gyuho Apr 16, 2018
d1c7d40
snapshot: support structured logger
gyuho Apr 16, 2018
6dbce6b
clientv3,etcdctl: support structured logger
gyuho Apr 16, 2018
9063805
contrib/tools: support structured logger
gyuho Apr 16, 2018
a7fd274
integration: support structured logger
gyuho Apr 16, 2018
c712e08
embed,etcdmain: support structured logger
gyuho Apr 16, 2018
677894b
functional/agent: support embedded etcd
gyuho Apr 16, 2018
f34c5dc
functional/tester: run tests with embedded etcd
gyuho Apr 16, 2018
2bd88e3
pkg/transport: check nil logger
gyuho Apr 16, 2018
38e32a1
snapshot: ignore server logs
gyuho Apr 16, 2018
cc77874
embed: support "io-discard" for logging, fix racey logging setup
gyuho Apr 16, 2018
35a80bc
integration,embed: ignore embed log output
gyuho Apr 16, 2018
d1c2ae8
functional/tester: handle "raft.ErrProposalDropped"
gyuho Apr 16, 2018
2ee2a96
functional/tester: use binary for tests for now
gyuho Apr 16, 2018
f63b5c1
functional/agent: fix etcd exec path check
gyuho Apr 16, 2018
c716bea
CHANGELOG-3.4: highlight WAL changes
gyuho Apr 16, 2018
b7ce6b7
Documentation/upgrades: highlight wal, embed changes
gyuho Apr 16, 2018
ae9ccd8
etcdctl/ctlv3: fix snapshot command e2e tests
gyuho Apr 17, 2018
92c3274
tests/e2e: fix TestIssue6361
gyuho Apr 17, 2018
a3b9d82
tests/e2e: fix gateway tests
gyuho Apr 17, 2018
1c44293
tests/e2e: comment out TestEtcdCorruptHash debugging lines
gyuho Apr 17, 2018
18b3e45
*: support --log-output=discard
gyuho Apr 17, 2018
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
Next Next commit
functional/rpcpb: add "*Etcd.EmbedConfig", and logger fields
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Apr 17, 2018
commit 575cf94852cc9fa0f27d17ca184695048bc0783e
18 changes: 12 additions & 6 deletions functional.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
agent-configs:
- etcd-exec-path: ./bin/etcd
- etcd-exec: ./bin/etcd
agent-addr: 127.0.0.1:19027
failpoint-http-addr: http://127.0.0.1:7381
base-dir: /tmp/etcd-functional-1
etcd-log-path: /tmp/etcd-functional-1/etcd.log
etcd-client-proxy: false
etcd-peer-proxy: true
etcd-client-endpoint: 127.0.0.1:1379
@@ -34,6 +33,9 @@ agent-configs:
quota-backend-bytes: 10740000000 # 10 GiB
pre-vote: true
initial-corrupt-check: true
logger: zap
log-output: /tmp/etcd-functional-1/etcd.log
debug: true
client-cert-data: ""
client-cert-path: ""
client-key-data: ""
@@ -48,11 +50,10 @@ agent-configs:
peer-trusted-ca-path: ""
snapshot-path: /tmp/etcd-functional-1.snapshot.db

- etcd-exec-path: ./bin/etcd
- etcd-exec: ./bin/etcd
agent-addr: 127.0.0.1:29027
failpoint-http-addr: http://127.0.0.1:7382
base-dir: /tmp/etcd-functional-2
etcd-log-path: /tmp/etcd-functional-2/etcd.log
etcd-client-proxy: false
etcd-peer-proxy: true
etcd-client-endpoint: 127.0.0.1:2379
@@ -83,6 +84,9 @@ agent-configs:
quota-backend-bytes: 10740000000 # 10 GiB
pre-vote: true
initial-corrupt-check: true
logger: zap
log-output: /tmp/etcd-functional-2/etcd.log
debug: true
client-cert-data: ""
client-cert-path: ""
client-key-data: ""
@@ -97,11 +101,10 @@ agent-configs:
peer-trusted-ca-path: ""
snapshot-path: /tmp/etcd-functional-2.snapshot.db

- etcd-exec-path: ./bin/etcd
- etcd-exec: ./bin/etcd
agent-addr: 127.0.0.1:39027
failpoint-http-addr: http://127.0.0.1:7383
base-dir: /tmp/etcd-functional-3
etcd-log-path: /tmp/etcd-functional-3/etcd.log
etcd-client-proxy: false
etcd-peer-proxy: true
etcd-client-endpoint: 127.0.0.1:3379
@@ -132,6 +135,9 @@ agent-configs:
quota-backend-bytes: 10740000000 # 10 GiB
pre-vote: true
initial-corrupt-check: true
logger: zap
log-output: /tmp/etcd-functional-3/etcd.log
debug: true
client-cert-data: ""
client-cert-path: ""
client-key-data: ""
4 changes: 2 additions & 2 deletions functional/agent/handler.go
Original file line number Diff line number Diff line change
@@ -233,13 +233,13 @@ func (srv *Server) createEtcdLogFile() error {
}

func (srv *Server) creatEtcdCmd(fromSnapshot bool) {
etcdPath, etcdFlags := srv.Member.EtcdExecPath, srv.Member.Etcd.Flags()
etcdPath, etcdFlags := srv.Member.EtcdExec, srv.Member.Etcd.Flags()
if fromSnapshot {
etcdFlags = srv.Member.EtcdOnSnapshotRestore.Flags()
}
u, _ := url.Parse(srv.Member.FailpointHTTPAddr)
srv.lg.Info("creating etcd command",
zap.String("etcd-exec-path", etcdPath),
zap.String("etcd-exec", etcdPath),
zap.Strings("etcd-flags", etcdFlags),
zap.String("failpoint-http-addr", srv.Member.FailpointHTTPAddr),
zap.String("failpoint-addr", u.Host),
81 changes: 78 additions & 3 deletions functional/rpcpb/etcd_config.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,10 @@ import (
"fmt"
"reflect"
"strings"

"github.com/coreos/etcd/embed"
"github.com/coreos/etcd/pkg/transport"
"github.com/coreos/etcd/pkg/types"
)

var etcdFields = []string{
@@ -53,12 +57,16 @@ var etcdFields = []string{

"PreVote",
"InitialCorruptCheck",

"Logger",
"LogOutput",
"Debug",
}

// Flags returns etcd flags in string slice.
func (cfg *Etcd) Flags() (fs []string) {
tp := reflect.TypeOf(*cfg)
vo := reflect.ValueOf(*cfg)
func (e *Etcd) Flags() (fs []string) {
tp := reflect.TypeOf(*e)
vo := reflect.ValueOf(*e)
for _, name := range etcdFields {
field, ok := tp.FieldByName(name)
if !ok {
@@ -97,3 +105,70 @@ func (cfg *Etcd) Flags() (fs []string) {
}
return fs
}

// EmbedConfig returns etcd embed.Config.
func (e *Etcd) EmbedConfig() (cfg *embed.Config, err error) {
var lcURLs types.URLs
lcURLs, err = types.NewURLs(e.ListenClientURLs)
if err != nil {
return nil, err
}
var acURLs types.URLs
acURLs, err = types.NewURLs(e.AdvertiseClientURLs)
if err != nil {
return nil, err
}
var lpURLs types.URLs
lpURLs, err = types.NewURLs(e.ListenPeerURLs)
if err != nil {
return nil, err
}
var apURLs types.URLs
apURLs, err = types.NewURLs(e.AdvertisePeerURLs)
if err != nil {
return nil, err
}

cfg = embed.NewConfig()
cfg.Name = e.Name
cfg.Dir = e.DataDir
cfg.WalDir = e.WALDir
cfg.TickMs = uint(e.HeartbeatIntervalMs)
cfg.ElectionMs = uint(e.ElectionTimeoutMs)

cfg.LCUrls = lcURLs
cfg.ACUrls = acURLs
cfg.ClientAutoTLS = e.ClientAutoTLS
cfg.ClientTLSInfo = transport.TLSInfo{
ClientCertAuth: e.ClientCertAuth,
CertFile: e.ClientCertFile,
KeyFile: e.ClientKeyFile,
TrustedCAFile: e.ClientTrustedCAFile,
}

cfg.LPUrls = lpURLs
cfg.APUrls = apURLs
cfg.PeerAutoTLS = e.PeerAutoTLS
cfg.PeerTLSInfo = transport.TLSInfo{
ClientCertAuth: e.PeerClientCertAuth,
CertFile: e.PeerCertFile,
KeyFile: e.PeerKeyFile,
TrustedCAFile: e.PeerTrustedCAFile,
}

cfg.InitialCluster = e.InitialCluster
cfg.ClusterState = e.InitialClusterState
cfg.InitialClusterToken = e.InitialClusterToken

cfg.SnapCount = uint64(e.SnapshotCount)
cfg.QuotaBackendBytes = e.QuotaBackendBytes

cfg.PreVote = e.PreVote
cfg.ExperimentalInitialCorruptCheck = e.InitialCorruptCheck

cfg.Logger = e.Logger
cfg.LogOutput = e.LogOutput
cfg.Debug = e.Debug

return cfg, nil
}
81 changes: 71 additions & 10 deletions functional/rpcpb/etcd_config_test.go
Original file line number Diff line number Diff line change
@@ -17,13 +17,16 @@ package rpcpb
import (
"reflect"
"testing"

"github.com/coreos/etcd/embed"
"github.com/coreos/etcd/pkg/types"
)

func TestEtcdFlags(t *testing.T) {
cfg := &Etcd{
func TestEtcd(t *testing.T) {
e := &Etcd{
Name: "s1",
DataDir: "/tmp/etcd-agent-data-1/etcd.data",
WALDir: "/tmp/etcd-agent-data-1/etcd.data/member/wal",
DataDir: "/tmp/etcd-functionl-1/etcd.data",
WALDir: "/tmp/etcd-functionl-1/etcd.data/member/wal",

HeartbeatIntervalMs: 100,
ElectionTimeoutMs: 1000,
@@ -53,12 +56,16 @@ func TestEtcdFlags(t *testing.T) {

PreVote: true,
InitialCorruptCheck: true,

Logger: "zap",
LogOutput: "/tmp/etcd-functional-1/etcd.log",
Debug: true,
}

exp := []string{
exps := []string{
"--name=s1",
"--data-dir=/tmp/etcd-agent-data-1/etcd.data",
"--wal-dir=/tmp/etcd-agent-data-1/etcd.data/member/wal",
"--data-dir=/tmp/etcd-functionl-1/etcd.data",
"--wal-dir=/tmp/etcd-functionl-1/etcd.data/member/wal",
"--heartbeat-interval=100",
"--election-timeout=1000",
"--listen-client-urls=https://127.0.0.1:1379",
@@ -76,9 +83,63 @@ func TestEtcdFlags(t *testing.T) {
"--quota-backend-bytes=10740000000",
"--pre-vote=true",
"--experimental-initial-corrupt-check=true",
"--logger=zap",
"--log-output=/tmp/etcd-functional-1/etcd.log",
"--debug=true",
}
fs := e.Flags()
if !reflect.DeepEqual(exps, fs) {
t.Fatalf("expected %q, got %q", exps, fs)
}

var err error
var lcURLs types.URLs
lcURLs, err = types.NewURLs([]string{"https://127.0.0.1:1379"})
if err != nil {
t.Fatal(err)
}
var acURLs types.URLs
acURLs, err = types.NewURLs([]string{"https://127.0.0.1:13790"})
if err != nil {
t.Fatal(err)
}
var lpURLs types.URLs
lpURLs, err = types.NewURLs([]string{"https://127.0.0.1:1380"})
if err != nil {
t.Fatal(err)
}
var apURLs types.URLs
apURLs, err = types.NewURLs([]string{"https://127.0.0.1:13800"})
if err != nil {
t.Fatal(err)
}
expc := embed.NewConfig()
expc.Name = "s1"
expc.Dir = "/tmp/etcd-functionl-1/etcd.data"
expc.WalDir = "/tmp/etcd-functionl-1/etcd.data/member/wal"
expc.TickMs = 100
expc.ElectionMs = 1000
expc.LCUrls = lcURLs
expc.ACUrls = acURLs
expc.ClientAutoTLS = true
expc.LPUrls = lpURLs
expc.APUrls = apURLs
expc.PeerAutoTLS = true
expc.InitialCluster = "s1=https://127.0.0.1:13800,s2=https://127.0.0.1:23800,s3=https://127.0.0.1:33800"
expc.ClusterState = "new"
expc.InitialClusterToken = "tkn"
expc.SnapCount = 10000
expc.QuotaBackendBytes = 10740000000
expc.PreVote = true
expc.ExperimentalInitialCorruptCheck = true
expc.Logger = "zap"
expc.LogOutput = "/tmp/etcd-functional-1/etcd.log"
expc.Debug = true
cfg, err := e.EmbedConfig()
if err != nil {
t.Fatal(err)
}
fs := cfg.Flags()
if !reflect.DeepEqual(exp, fs) {
t.Fatalf("expected %q, got %q", exp, fs)
if !reflect.DeepEqual(expc, cfg) {
t.Fatalf("expected %+v, got %+v", expc, cfg)
}
}
Loading