File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change
1
+ Fixed race in integration test ` TestTopicWriterLogMessagesWithoutData `
2
+
1
3
## v3.117.0
2
4
* Fixed ` conn/pool.Get() ` behaviour for YDB databases with public IPs. Bug was introduced in v3.116.2
3
5
* Added helper methods ` log.WithFields ` and ` log.FieldsFromContext ` for working with structured logging fields via context.
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
27
27
"github.com/ydb-platform/ydb-go-sdk/v3/internal/version"
28
28
"github.com/ydb-platform/ydb-go-sdk/v3/log"
29
29
xtest "github.com/ydb-platform/ydb-go-sdk/v3/pkg/xtest"
30
+ tu "github.com/ydb-platform/ydb-go-sdk/v3/testutil"
30
31
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
31
32
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicsugar"
32
33
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topictypes"
@@ -44,7 +45,7 @@ func TestTopicWriterLogMessagesWithoutData(t *testing.T) {
44
45
metaKey := "gyoeexiufo"
45
46
metaValue := "fjedeikeosbv"
46
47
47
- logs := & strings. Builder {}
48
+ logs := & tu. ThreadSafeBuilder {}
48
49
writer , err := scope .Driver ().Topic ().StartWriter (
49
50
scope .TopicPath (),
50
51
topicoptions .WithWriterProducerID (producerID ),
Original file line number Diff line number Diff line change
1
+ package testutil
2
+
3
+ import (
4
+ "strings"
5
+ "sync"
6
+ )
7
+
8
+ type ThreadSafeBuilder struct {
9
+ mu sync.Mutex
10
+ b strings.Builder
11
+ }
12
+
13
+ func (tsb * ThreadSafeBuilder ) WriteString (s string ) (int , error ) {
14
+ tsb .mu .Lock ()
15
+ defer tsb .mu .Unlock ()
16
+
17
+ return tsb .b .WriteString (s )
18
+ }
19
+
20
+ func (tsb * ThreadSafeBuilder ) Write (p []byte ) (int , error ) {
21
+ tsb .mu .Lock ()
22
+ defer tsb .mu .Unlock ()
23
+
24
+ return tsb .b .Write (p )
25
+ }
26
+
27
+ func (tsb * ThreadSafeBuilder ) String () string {
28
+ tsb .mu .Lock ()
29
+ defer tsb .mu .Unlock ()
30
+
31
+ return tsb .b .String ()
32
+ }
33
+
34
+ func (tsb * ThreadSafeBuilder ) Reset () {
35
+ tsb .mu .Lock ()
36
+ defer tsb .mu .Unlock ()
37
+ tsb .b .Reset ()
38
+ }
You can’t perform that action at this time.
0 commit comments