Skip to content

Commit cb5c492

Browse files
committed
fix(ci): invalid protoc and a datarace in command.
1 parent d13a968 commit cb5c492

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ E2E_TEST_CLUSTER_NAME ?= lima-$(LIMA_INSTANCE)
5252
E2E_TEST_KUBECTL_CONTEXT ?= lima
5353

5454
KUBECTL ?= limactl shell $(LIMA_INSTANCE) sudo kubectl
55-
PROTOC_VERSION = 29.6
55+
PROTOC_VERSION = 33.4
5656
PROTOC_OS ?= osx
5757
PROTOC_ZIP = protoc-${PROTOC_VERSION}-${PROTOC_OS}-x86_64.zip
5858
# you might also want to change ~/lima.yaml k3s version

command/command.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type backgroundCmd struct {
8787
ticker *time.Ticker // Used to send regular SIGCONT signal to process
8888
err chan error // Used to monitor the exit of the command
8989
keepAliveQuit chan int // Used to kill the keepAlive goroutine
90+
keepAliveDone chan struct{} // Closed when the keepAlive goroutine exits
9091
pid int // PID of the process
9192
}
9293

@@ -121,6 +122,7 @@ func NewBackgroundCmd(cmd Cmd, log *zap.SugaredLogger, processManager process.Ma
121122
nil,
122123
nil,
123124
nil,
125+
nil,
124126
process.NotFoundProcessPID,
125127
}
126128
}
@@ -193,10 +195,13 @@ func (w *backgroundCmd) KeepAlive() {
193195
w.ticker = time.NewTicker(cmdKeepAliveTickDuration)
194196

195197
w.keepAliveQuit = make(chan int, 1) // we need a buffered channel so the sender doesn't block
198+
w.keepAliveDone = make(chan struct{})
196199

197200
w.log.Debug("monitoring sending SIGCONT signal to process every 1s")
198201

199202
go func() {
203+
defer close(w.keepAliveDone)
204+
200205
for {
201206
exit, err := w.sendSIGCONTSignal()
202207
if err != nil {

command/command_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,19 @@ var _ = Describe("BackgroundCmd", func() {
244244
sut.KeepAlive()
245245
sut.KeepAlive() // we call it twice voluntarily to test the invariant that only a single goroutine is created
246246

247-
// Wait enough interval to have at least expected calls (times + 20%)
248-
<-time.After(cmdKeepAliveTickDuration*time.Duration(times) + cmdBootstrapAllowedDuration/5)
249-
250247
underSut, ok := sut.(*backgroundCmd)
251248
Expect(ok).To(BeTrue())
252249
Expect(underSut).ToNot(BeNil())
253250

251+
// Ensure the keepAlive goroutine has fully exited before mock cleanup runs,
252+
// preventing panics when mocks are called after the test finishes.
253+
DeferCleanup(func() {
254+
<-underSut.keepAliveDone
255+
})
256+
257+
// Wait enough interval to have at least expected calls (times + 20%)
258+
<-time.After(cmdKeepAliveTickDuration*time.Duration(times) + cmdBootstrapAllowedDuration/5)
259+
254260
// Stop timer ASAP to have realistic amount of calls
255261
underSut.keepAliveQuit <- 0
256262
},
@@ -268,12 +274,17 @@ var _ = Describe("BackgroundCmd", func() {
268274
sut.KeepAlive()
269275
sut.KeepAlive() // we call it twice voluntarily to test the invariant that only a single goroutine is created
270276

271-
// Wait enough interval to have at least expected calls (times + 20%)
272-
<-time.After(cmdKeepAliveTickDuration*time.Duration(times) + cmdBootstrapAllowedDuration/5)
273-
274277
underSut, ok := sut.(*backgroundCmd)
275278
Expect(ok).To(BeTrue())
276279
Expect(underSut).ToNot(BeNil())
280+
281+
// Ensure the keepAlive goroutine has fully exited before mock cleanup runs.
282+
DeferCleanup(func() {
283+
<-underSut.keepAliveDone
284+
})
285+
286+
// Wait enough interval to have at least expected calls (times + 20%)
287+
<-time.After(cmdKeepAliveTickDuration*time.Duration(times) + cmdBootstrapAllowedDuration/5)
277288
},
278289
Entry("Find fails once", nil, errors.New("find fails"), nil, 1),
279290
Entry("Signal fails once", &os.Process{}, nil, errors.New("signal fails"), 1),

0 commit comments

Comments
 (0)