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

test: Wrap provisionerd channel closes in sync.Once#1181

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 intomainfromwrapclose
Apr 26, 2022
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
20 changes: 16 additions & 4 deletionsprovisionerd/provisionerd_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -84,6 +84,7 @@ func TestProvisionerd(t *testing.T) {
t.Run("CloseCancelsJob", func(t *testing.T) {
t.Parallel()
completeChan := make(chan struct{})
var completed sync.Once
var closer io.Closer
var closerMutex sync.Mutex
closerMutex.Lock()
Expand All@@ -105,7 +106,9 @@ func TestProvisionerd(t *testing.T) {
},
updateJob: noopUpdateJob,
failJob: func(ctx context.Context, job *proto.FailedJob) (*proto.Empty, error) {
close(completeChan)
completed.Do(func() {
close(completeChan)
})
return &proto.Empty{}, nil
},
}), nil
Expand DownExpand Up@@ -432,6 +435,8 @@ func TestProvisionerd(t *testing.T) {

t.Run("Shutdown", func(t *testing.T) {
t.Parallel()
var updated sync.Once
var completed sync.Once
updateChan := make(chan struct{})
completeChan := make(chan struct{})
server := createProvisionerd(t, func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
Expand All@@ -453,12 +458,16 @@ func TestProvisionerd(t *testing.T) {
updateJob: func(ctx context.Context, update *proto.UpdateJobRequest) (*proto.UpdateJobResponse, error) {
if len(update.Logs) > 0 && update.Logs[0].Source == proto.LogSource_PROVISIONER {
// Close on a log so we know when the job is in progress!
close(updateChan)
updated.Do(func() {
close(updateChan)
})
}
return &proto.UpdateJobResponse{}, nil
},
failJob: func(ctx context.Context, job *proto.FailedJob) (*proto.Empty, error) {
close(completeChan)
completed.Do(func() {
close(completeChan)
})
return &proto.Empty{}, nil
},
}), nil
Expand DownExpand Up@@ -642,6 +651,7 @@ func TestProvisionerd(t *testing.T) {

t.Run("ReconnectAndComplete", func(t *testing.T) {
t.Parallel()
var completed sync.Once
var second atomic.Bool
failChan := make(chan struct{})
failedChan := make(chan struct{})
Expand All@@ -650,7 +660,9 @@ func TestProvisionerd(t *testing.T) {
client := createProvisionerDaemonClient(t, provisionerDaemonTestServer{
acquireJob: func(ctx context.Context, _ *proto.Empty) (*proto.AcquiredJob, error) {
if second.Load() {
close(completeChan)
completed.Do(func() {
close(completeChan)
})
return &proto.AcquiredJob{}, nil
}
return &proto.AcquiredJob{
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp