mirror of https://github.com/milvus-io/milvus.git
Fix MQ Factory timeout unit test (#28395)
This PR change timeout case to a longer duration in case of slow runner Also change timeout case behavior of using timeout deadline instead of waiting See also #28394 Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/28402/head
parent
cfb6edea61
commit
371875f650
|
@ -46,13 +46,13 @@ func TestPmsFactory(t *testing.T) {
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
if test.withTimeout {
|
if test.withTimeout {
|
||||||
ctx, cancel = context.WithTimeout(ctx, time.Millisecond)
|
if test.ctxTimeouted {
|
||||||
|
ctx, cancel = context.WithDeadline(ctx, time.Now().Add(-1*time.Minute))
|
||||||
|
} else {
|
||||||
|
ctx, cancel = context.WithTimeout(ctx, time.Second*10)
|
||||||
|
}
|
||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
if test.ctxTimeouted {
|
|
||||||
time.Sleep(time.Millisecond)
|
|
||||||
}
|
|
||||||
stream, err := pmsFactory.NewMsgStream(ctx)
|
stream, err := pmsFactory.NewMsgStream(ctx)
|
||||||
if test.expectedError {
|
if test.expectedError {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
@ -120,15 +120,14 @@ func TestKafkaFactory(t *testing.T) {
|
||||||
t.Run(test.description, func(t *testing.T) {
|
t.Run(test.description, func(t *testing.T) {
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
timeoutDur := time.Millisecond * 30
|
|
||||||
if test.withTimeout {
|
if test.withTimeout {
|
||||||
ctx, cancel = context.WithTimeout(ctx, timeoutDur)
|
if test.ctxTimeouted {
|
||||||
|
ctx, cancel = context.WithDeadline(ctx, time.Now().Add(-1*time.Minute))
|
||||||
|
} else {
|
||||||
|
ctx, cancel = context.WithTimeout(ctx, time.Second*10)
|
||||||
|
}
|
||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
if test.ctxTimeouted {
|
|
||||||
time.Sleep(timeoutDur)
|
|
||||||
}
|
|
||||||
stream, err := kmsFactory.NewMsgStream(ctx)
|
stream, err := kmsFactory.NewMsgStream(ctx)
|
||||||
if test.expectedError {
|
if test.expectedError {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
|
Loading…
Reference in New Issue