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-tester: add logging statement #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,10 @@ func (s *EtcdServer) applyAll(ep *etcdProgress, apply *apply) {
}

func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
plog.Info("start applySnapshot")

if raft.IsEmptySnap(apply.snapshot) {
plog.Info("start applySnapshot raft.IsEmptySnap() returns true. exit")
return
}

Expand Down Expand Up @@ -863,6 +866,7 @@ func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
ep.appliedi = apply.snapshot.Metadata.Index
ep.snapi = ep.appliedi
ep.confState = apply.snapshot.Metadata.ConfState
plog.Info("applySnapshot done")
}

func (s *EtcdServer) applyEntries(ep *etcdProgress, apply *apply) {
Expand Down
17 changes: 16 additions & 1 deletion pkg/netutil/isolate_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func RecoverPort(port int) error {

// SetLatency adds latency in millisecond scale with random variations.
func SetLatency(ms, rv int) error {
fmt.Printf("SetLatency ms %v rv %v\n", ms, rv)
ifce, err := GetDefaultInterface()
fmt.Printf("SetLatency GetDefaultInterface() status: ifce %v, err (%v)\n", ifce, err)
if err != nil {
return err
}
Expand All @@ -52,24 +54,37 @@ func SetLatency(ms, rv int) error {
rv = 1
}
cmdStr := fmt.Sprintf("sudo tc qdisc add dev %s root netem delay %dms %dms distribution normal", ifce, ms, rv)
fmt.Printf("SetLatency cmd: %v\n", cmdStr)
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output()
if err != nil {
fmt.Printf("SetLatency cmd: %v error (%v)\n", cmdStr, err)
// the rule has already been added. Overwrite it.
cmdStr = fmt.Sprintf("sudo tc qdisc change dev %s root netem delay %dms %dms distribution normal", ifce, ms, rv)
fmt.Printf("SetLatency cmd: %v\n", cmdStr)
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output()
if err != nil {
fmt.Printf("SetLatency cmd: %v error (%v)\n", cmdStr, err)
return err
}
}
fmt.Printf("SetLatency ms %v rv %v done\n", ms, rv)

return nil
}

// RemoveLatency resets latency configurations.
func RemoveLatency() error {
fmt.Printf("RemoveLatency\n")
ifce, err := GetDefaultInterface()
fmt.Printf("RemoveLatency GetDefaultInterface() status: ifce %v, err (%v)\n", ifce, err)
if err != nil {
return err
}
_, err = exec.Command("/bin/sh", "-c", fmt.Sprintf("sudo tc qdisc del dev %s root netem", ifce)).Output()
cmdStr := fmt.Sprintf("sudo tc qdisc del dev %s root netem", ifce)
fmt.Printf("RemoveLatency cmd: %v\n", cmdStr)
_, err = exec.Command("/bin/sh", "-c", cmdStr).Output()
if err != nil {
fmt.Printf("RemoveLatency cmd: %v\n error (%v)\n", cmdStr, err)
}
return err
}
4 changes: 4 additions & 0 deletions raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,10 +1102,14 @@ func (r *raft) handleSnapshot(m pb.Message) {
r.logger.Infof("%x [commit: %d] restored snapshot [index: %d, term: %d]",
r.id, r.raftLog.committed, sindex, sterm)
r.send(pb.Message{To: m.From, Type: pb.MsgAppResp, Index: r.raftLog.lastIndex()})
r.logger.Infof("%x [commit: %d] restored snapshot [index: %d, term: %d] sent MsgApp",
r.id, r.raftLog.committed, sindex, sterm)
} else {
r.logger.Infof("%x [commit: %d] ignored snapshot [index: %d, term: %d]",
r.id, r.raftLog.committed, sindex, sterm)
r.send(pb.Message{To: m.From, Type: pb.MsgAppResp, Index: r.raftLog.committed})
r.logger.Infof("%x [commit: %d] ignored snapshot [index: %d, term: %d] sent MsgApp",
r.id, r.raftLog.committed, sindex, sterm)
}
}

Expand Down
12 changes: 6 additions & 6 deletions tools/functional-tester/etcd-tester/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ func (hc *hashChecker) Check() error {
type leaseChecker struct{ ls *leaseStresser }

func (lc *leaseChecker) Check() error {
plog.Infof("checking revoked leases %v", lc.ls.revokedLeases.leases)
plog.Debugf("checking revoked leases %v", lc.ls.revokedLeases.leases)
if err := lc.check(true, lc.ls.revokedLeases.leases); err != nil {
return err
}
plog.Infof("checking alive leases %v", lc.ls.aliveLeases.leases)
plog.Debugf("checking alive leases %v", lc.ls.aliveLeases.leases)
if err := lc.check(false, lc.ls.aliveLeases.leases); err != nil {
return err
}
plog.Infof("checking short lived leases %v", lc.ls.shortLivedLeases.leases)
plog.Debugf("checking short lived leases %v", lc.ls.shortLivedLeases.leases)
return lc.checkShortLivedLeases()

}
Expand Down Expand Up @@ -122,14 +122,14 @@ func (lc *leaseChecker) checkShortLivedLease(ctx context.Context, leaseID int64)
return nil
}
if err != nil {
plog.Warningf("retry %d. failed to retrieve lease %v error (%v)", i, leaseID, err)
plog.Debugf("retry %d. failed to retrieve lease %v error (%v)", i, leaseID, err)
continue
}
if resp.TTL > 0 {
plog.Warningf("lease %v is not expired. sleep for %d until it expires.", leaseID, resp.TTL)
plog.Debugf("lease %v is not expired. sleep for %d until it expires.", leaseID, resp.TTL)
time.Sleep(time.Duration(resp.TTL) * time.Second)
} else {
plog.Warningf("retry %d. lease %v is expired but not yet revoked", i, leaseID)
plog.Debugf("retry %d. lease %v is expired but not yet revoked", i, leaseID)
time.Sleep(time.Second)
}
if err = lc.checkLease(ctx, false, leaseID); err != nil {
Expand Down
10 changes: 9 additions & 1 deletion tools/functional-tester/etcd-tester/failure_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,26 @@ func newFailureIsolateAll() failure {
}

func injectLatency(m *member) error {
plog.Printf("%v Injecting Latency", m.ClientURL)
if err := m.Agent.SetLatency(slowNetworkLatency, randomVariation); err != nil {
m.Agent.RemoveLatency()
plog.Printf("%v Injecting Latency error (%v)", m.ClientURL, err)
rErr := m.Agent.RemoveLatency()
plog.Printf("%v Injecting Latency's Removing Latency status %v", m.ClientURL, rErr)
return err
}
plog.Printf("%v Injecting Latency done", m.ClientURL)
return nil
}

func recoverLatency(m *member) error {
plog.Printf("%v recovering Latency", m.ClientURL)
if err := m.Agent.RemoveLatency(); err != nil {
plog.Printf("%v recovering Latency error (%v)", m.ClientURL, err)
return err
}
plog.Printf("%v recovering Latency sleep for %v", m.ClientURL, waitRecover)
time.Sleep(waitRecover)
plog.Printf("%v recovering Latency done", m.ClientURL)
return nil
}

Expand Down
27 changes: 17 additions & 10 deletions tools/functional-tester/etcd-tester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,23 @@ func makeFailures(types string, c *cluster) []failure {
switch fails[i] {
case "default":
defaultFailures := []failure{
newFailureKillAll(),
newFailureKillMajority(),
newFailureKillOne(),
newFailureKillLeader(),
newFailureKillOneForLongTime(),
newFailureKillLeaderForLongTime(),
newFailureIsolate(),
newFailureIsolateAll(),
newFailureSlowNetworkOneMember(),
newFailureSlowNetworkLeader(),
// newFailureKillAll(),
// newFailureKillMajority(),
// newFailureKillOne(),
// newFailureKillLeader(),
// newFailureKillOneForLongTime(),
// newFailureKillLeaderForLongTime(),
// newFailureIsolate(),
// newFailureIsolateAll(),
// newFailureSlowNetworkOneMember(),
// newFailureSlowNetworkLeader(),
newFailureSlowNetworkAll(),
newFailureSlowNetworkAll(),
newFailureSlowNetworkAll(),
newFailureSlowNetworkAll(),
newFailureSlowNetworkAll(),
newFailureSlowNetworkAll(),
newFailureSlowNetworkAll(),
newFailureSlowNetworkAll(),
}
failures = append(failures, defaultFailures...)
Expand Down