File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
12
12
"net/url"
13
13
strconv "strconv"
14
14
"strings"
15
+ "sync"
15
16
"testing"
16
17
"time"
17
18
@@ -250,6 +251,25 @@ func TestFrontendCheckReady(t *testing.T) {
250
251
}
251
252
}
252
253
254
+ type syncBuf struct {
255
+ mu sync.Mutex
256
+ buf bytes.Buffer
257
+ }
258
+
259
+ func (sb * syncBuf ) Write (p []byte ) (n int , err error ) {
260
+ sb .mu .Lock ()
261
+ defer sb .mu .Unlock ()
262
+
263
+ return sb .buf .Write (p )
264
+ }
265
+
266
+ func (sb * syncBuf ) String () string {
267
+ sb .mu .Lock ()
268
+ defer sb .mu .Unlock ()
269
+
270
+ return sb .buf .String ()
271
+ }
272
+
253
273
func TestFrontend_LogsSlowQueriesFormValues (t * testing.T ) {
254
274
// Create an HTTP server listening locally. This server mocks the downstream
255
275
// Prometheus API-compatible server.
@@ -271,8 +291,8 @@ func TestFrontend_LogsSlowQueriesFormValues(t *testing.T) {
271
291
config .Handler .LogQueriesLongerThan = 1 * time .Microsecond
272
292
config .DownstreamURL = fmt .Sprintf ("http://%s" , downstreamListen .Addr ())
273
293
274
- var buf bytes. Buffer
275
- l := log .NewLogfmtLogger (log . NewSyncWriter ( & buf ) )
294
+ var buf syncBuf
295
+ l := log .NewLogfmtLogger (& buf )
276
296
277
297
test := func (addr string ) {
278
298
data := url.Values {}
You can’t perform that action at this time.
0 commit comments