Skip to content

Commit

Permalink
try fixing race in tests of ctl socket
Browse files Browse the repository at this point in the history
there were a few test failures on the github runners. i can't reproduce it
locally. but i can see how they are happening: a gorouting running servectlcmd
could still be doing cleanup (removing files) while a next ctl command was
being run. with this change, we wait for servectlcmd to be done before starting
on a next test.
  • Loading branch information
mjl- committed Jun 10, 2024
1 parent 8254e9c commit ac3596a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ func TestCtl(t *testing.T) {
cconn, sconn := net.Pipe()
clientctl := ctl{conn: cconn, log: pkglog}
serverctl := ctl{conn: sconn, log: pkglog}
go servectlcmd(ctxbg, &serverctl, func() {})
done := make(chan struct{})
go func() {
servectlcmd(ctxbg, &serverctl, func() {})
close(done)
}()
fn(&clientctl)
cconn.Close()
<-done
sconn.Close()
}

Expand Down

0 comments on commit ac3596a

Please sign in to comment.