Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: add a mutex around reading logs from scaletests#7521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 1 commit intomainfromsynclogs
May 14, 2023
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletionsscaletest/harness/run.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"io"
"sync"
"time"

"golang.org/x/xerrors"
Expand DownExpand Up@@ -65,7 +66,7 @@ type TestRun struct {
id string
runner Runnable

logs *bytes.Buffer
logs *syncBuffer
done chan struct{}
started time.Time
duration time.Duration
Expand All@@ -87,7 +88,9 @@ func (r *TestRun) FullID() string {
// Run executes the Run function with a self-managed log writer, panic handler,
// error recording and duration recording. The test error is returned.
func (r *TestRun) Run(ctx context.Context) (err error) {
r.logs = new(bytes.Buffer)
r.logs = &syncBuffer{
buf: new(bytes.Buffer),
}
r.done = make(chan struct{})
defer close(r.done)

Expand DownExpand Up@@ -132,3 +135,20 @@ func (r *TestRun) Cleanup(ctx context.Context) (err error) {
//nolint:revive // we use named returns because we mutate it in a defer
return
}

type syncBuffer struct {
buf *bytes.Buffer
mut sync.Mutex
}

func (sb *syncBuffer) Write(p []byte) (n int, err error) {
sb.mut.Lock()
defer sb.mut.Unlock()
return sb.buf.Write(p)
}

func (sb *syncBuffer) String() string {
sb.mut.Lock()
defer sb.mut.Unlock()
return sb.buf.String()
}

[8]ページ先頭

©2009-2025 Movatter.jp