Skip to content

Commit 5a4ac3f

Browse files
dev: fix flap in tests & NextResultAsync on skipping
* dev: fix flap tests (run processing ack may not be able to start on time) * Ado.Net NextResultAsync on skipping any more messages in ExecuteScalarAsync & ExecuteNonQueryAsync (will faster and safety)
1 parent 5f05a51 commit 5a4ac3f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Ydb.Sdk/src/Ado/YdbCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override async Task<int> ExecuteNonQueryAsync(CancellationToken cancellat
3131
{
3232
await using var dataReader = await ExecuteReaderAsync(cancellationToken);
3333

34-
while (await dataReader.ReadAsync(cancellationToken))
34+
while (await dataReader.NextResultAsync(cancellationToken))
3535
{
3636
}
3737

@@ -51,7 +51,7 @@ public override async Task<int> ExecuteNonQueryAsync(CancellationToken cancellat
5151
? dataReader.IsDBNull(0) ? null : dataReader.GetValue(0)
5252
: null;
5353

54-
while (await dataReader.ReadAsync(cancellationToken))
54+
while (await dataReader.NextResultAsync(cancellationToken))
5555
{
5656
}
5757

src/Ydb.Sdk/tests/Topic/WriterUnitTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ public async Task Initialize_WhenFailWriteMessage_ShouldRetryInitializeAndReturn
130130
Assert.Equal(PersistenceStatus.Written, (await writer.WriteAsync("abacaba")).Status);
131131

132132
// check attempt repeated!!!
133-
_mockStream.Verify(stream => stream.Write(It.IsAny<FromClient>()), Times.Exactly(3));
133+
_mockStream.Verify(stream => stream.Write(It.IsAny<FromClient>()),
134+
Times.AtLeast(2)); // run processing ack may not be able to start on time
134135
_mockStream.Verify(stream => stream.MoveNextAsync(), Times.Exactly(3));
135136
_mockStream.Verify(stream => stream.Current, Times.Exactly(2));
136137
}
@@ -178,7 +179,8 @@ public async Task Initialize_WhenFailMoveNextAsync_ShouldRetryInitializeAndRetur
178179

179180
// check attempt repeated!!!
180181
_mockStream.Verify(stream => stream.Write(It.IsAny<FromClient>()), Times.Exactly(3));
181-
_mockStream.Verify(stream => stream.MoveNextAsync(), Times.Exactly(4));
182+
_mockStream.Verify(stream => stream.MoveNextAsync(),
183+
Times.AtLeast(3)); // run processing ack may not be able to start on time
182184
_mockStream.Verify(stream => stream.Current, Times.Exactly(2));
183185
}
184186

0 commit comments

Comments
 (0)