mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #12773 from ptabor/20210310-test-fixes
Minor test fixes
This commit is contained in:
commit
527c765ece
@ -80,7 +80,7 @@ func TestDialCancel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDialTimeout(t *testing.T) {
|
func TestDialTimeout(t *testing.T) {
|
||||||
defer testutil.AfterTest(t)
|
testutil.BeforeTest(t)
|
||||||
|
|
||||||
wantError := context.DeadlineExceeded
|
wantError := context.DeadlineExceeded
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ import (
|
|||||||
"github.com/creack/pty"
|
"github.com/creack/pty"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const DEBUG_LINES_TAIL = 40
|
||||||
|
|
||||||
type ExpectProcess struct {
|
type ExpectProcess struct {
|
||||||
cmd *exec.Cmd
|
cmd *exec.Cmd
|
||||||
fpty *os.File
|
fpty *os.File
|
||||||
@ -96,6 +98,8 @@ func (ep *ExpectProcess) read() {
|
|||||||
|
|
||||||
// ExpectFunc returns the first line satisfying the function f.
|
// ExpectFunc returns the first line satisfying the function f.
|
||||||
func (ep *ExpectProcess) ExpectFunc(f func(string) bool) (string, error) {
|
func (ep *ExpectProcess) ExpectFunc(f func(string) bool) (string, error) {
|
||||||
|
lastLinesBuffer := make([]string, 0)
|
||||||
|
|
||||||
ep.mu.Lock()
|
ep.mu.Lock()
|
||||||
for {
|
for {
|
||||||
for len(ep.lines) == 0 && ep.err == nil {
|
for len(ep.lines) == 0 && ep.err == nil {
|
||||||
@ -106,13 +110,19 @@ func (ep *ExpectProcess) ExpectFunc(f func(string) bool) (string, error) {
|
|||||||
}
|
}
|
||||||
l := ep.lines[0]
|
l := ep.lines[0]
|
||||||
ep.lines = ep.lines[1:]
|
ep.lines = ep.lines[1:]
|
||||||
|
lastLinesBuffer = append(lastLinesBuffer, l)
|
||||||
|
if l := len(lastLinesBuffer); l > DEBUG_LINES_TAIL {
|
||||||
|
lastLinesBuffer = lastLinesBuffer[l-DEBUG_LINES_TAIL : l-1]
|
||||||
|
}
|
||||||
if f(l) {
|
if f(l) {
|
||||||
ep.mu.Unlock()
|
ep.mu.Unlock()
|
||||||
return l, nil
|
return l, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ep.mu.Unlock()
|
ep.mu.Unlock()
|
||||||
return "", ep.err
|
return "", fmt.Errorf("Match not found."+
|
||||||
|
" Set EXPECT_DEBUG for more info Err: %v, last lines:\n%s\n\n",
|
||||||
|
ep.err, strings.Join(lastLinesBuffer, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expect returns the first line containing the given string.
|
// Expect returns the first line containing the given string.
|
||||||
|
@ -35,7 +35,7 @@ import (
|
|||||||
|
|
||||||
// TestV3StorageQuotaApply tests the V3 server respects quotas during apply
|
// TestV3StorageQuotaApply tests the V3 server respects quotas during apply
|
||||||
func TestV3StorageQuotaApply(t *testing.T) {
|
func TestV3StorageQuotaApply(t *testing.T) {
|
||||||
testutil.AfterTest(t)
|
testutil.BeforeTest(t)
|
||||||
quotasize := int64(16 * os.Getpagesize())
|
quotasize := int64(16 * os.Getpagesize())
|
||||||
|
|
||||||
clus := NewClusterV3(t, &ClusterConfig{Size: 2})
|
clus := NewClusterV3(t, &ClusterConfig{Size: 2})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user