Skip to content

Commit 47ab2e7

Browse files
committed
wait sent close message before exit from test
1 parent 79f22d2 commit 47ab2e7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

internal/topic/topicreaderinternal/stream_reader_impl_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,12 @@ func TestStreamReaderImpl_OnPartitionCloseHandle(t *testing.T) {
165165

166166
e.Start()
167167

168+
stopPartitionResponseSent := make(empty.Chan)
168169
e.stream.EXPECT().Send(&rawtopicreader.StopPartitionSessionResponse{
169170
PartitionSessionID: e.partitionSessionID,
170-
}).Return(nil)
171+
}).Return(nil).Do(func(_ interface{}) {
172+
close(stopPartitionResponseSent)
173+
})
171174

172175
e.SendFromServer(&rawtopicreader.StopPartitionSessionRequest{
173176
PartitionSessionID: e.partitionSessionID,
@@ -178,6 +181,7 @@ func TestStreamReaderImpl_OnPartitionCloseHandle(t *testing.T) {
178181
_, err := e.reader.ReadMessageBatch(readMessagesCtx, newReadMessageBatchOptions())
179182
require.Error(t, err)
180183
require.Error(t, readMessagesCtx.Err())
184+
xtest.WaitChannelClosed(t, stopPartitionResponseSent)
181185
})
182186
xtest.TestManyTimesWithName(t, "TraceGracefulFalse", func(t testing.TB) {
183187
e := newTopicReaderTestEnv(t)

internal/xtest/manytimes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestManyTimes(t testing.TB, test TestFunc, opts ...TestManyTimesOption) {
3636
// run test, then check stopAfter for guarantee run test least once
3737
runTest(t, test)
3838

39-
if time.Since(start) > options.stopAfter {
39+
if time.Since(start) > options.stopAfter || t.Failed() {
4040
t.Log("test run counter:", testCounter)
4141
return
4242
}

0 commit comments

Comments
 (0)