mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #15242 from fuweid/linearizability-forcestop-cluster
tests/linearizability: force stop cluster with signal kill
This commit is contained in:
commit
65aa0fa305
@ -823,11 +823,17 @@ func (epc *EtcdProcessCluster) rollingStart(f func(ep EtcdProcess) error) error
|
||||
}
|
||||
|
||||
func (epc *EtcdProcessCluster) Stop() (err error) {
|
||||
for _, p := range epc.Procs {
|
||||
if p == nil {
|
||||
errCh := make(chan error, len(epc.Procs))
|
||||
for i := range epc.Procs {
|
||||
if epc.Procs[i] == nil {
|
||||
errCh <- nil
|
||||
continue
|
||||
}
|
||||
if curErr := p.Stop(); curErr != nil {
|
||||
go func(n int) { errCh <- epc.Procs[n].Stop() }(i)
|
||||
}
|
||||
|
||||
for range epc.Procs {
|
||||
if curErr := <-errCh; curErr != nil {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%v; %v", err, curErr)
|
||||
} else {
|
||||
@ -835,6 +841,7 @@ func (epc *EtcdProcessCluster) Stop() (err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
close(errCh)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ func TestLinearizability(t *testing.T) {
|
||||
retries: 3,
|
||||
waitBetweenTriggers: waitBetweenFailpointTriggers,
|
||||
}, *scenario.traffic)
|
||||
clus.Stop()
|
||||
forcestopCluster(clus)
|
||||
longestHistory, remainingEvents := pickLongestHistory(events)
|
||||
validateEventsMatch(t, longestHistory, remainingEvents)
|
||||
operations = patchOperationBasedOnWatchEvents(operations, longestHistory)
|
||||
@ -455,3 +455,11 @@ func testResultsDirectory(t *testing.T) (string, error) {
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// forcestopCluster stops the etcd member with signal kill.
|
||||
func forcestopCluster(clus *e2e.EtcdProcessCluster) error {
|
||||
for _, member := range clus.Procs {
|
||||
member.Kill()
|
||||
}
|
||||
return clus.Stop()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user