Skip to content

Commit

Permalink
Fixed some tests missing defer s.Shutdown()
Browse files Browse the repository at this point in the history
Also some go channel send would block and leave some go routine running.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
  • Loading branch information
kozlovic committed Mar 30, 2023
1 parent cb6a28b commit e4d78a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions server/jetstream_cluster_3_test.go
Expand Up @@ -1046,6 +1046,7 @@ func TestJetStreamClusterSourceWithOptStartTime(t *testing.T) {
sd := s.JetStreamConfig().StoreDir
s.Shutdown()
s = RunJetStreamServerOnPort(-1, sd)
defer s.Shutdown()
}

// Wait a bit before checking because sync'ing (even with the defect)
Expand Down Expand Up @@ -2728,13 +2729,16 @@ func TestJetStreamClusterInterestPolicyEphemeral(t *testing.T) {
}

const msgs = 5_000
done, count := make(chan bool), 0
done, count := make(chan bool, 1), 0

sub, err := js.Subscribe(_EMPTY_, func(msg *nats.Msg) {
require_NoError(t, msg.Ack())
count++
if count >= msgs {
done <- true
select {
case done <- true:
default:
}
}
}, nats.Bind(test.stream, name), nats.ManualAck())
require_NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions server/jetstream_test.go
Expand Up @@ -18642,6 +18642,7 @@ func TestJetStreamAccountPurge(t *testing.T) {
require_NoError(t, os.Remove(storeDir+"/jwt/"+accpub+".jwt"))

s, o = RunServerWithConfig(o.ConfigFile)
defer s.Shutdown()
inspectDirs(t, 1)
purge(t)
inspectDirs(t, 0)
Expand Down
7 changes: 5 additions & 2 deletions server/norace_test.go
Expand Up @@ -6121,12 +6121,15 @@ func TestNoRaceJetStreamClusterEnsureWALCompact(t *testing.T) {
err = node.InstallSnapshot(snap)
require_NoError(t, err)

received, done := 0, make(chan bool)
received, done := 0, make(chan bool, 1)

nc.Subscribe("zz", func(m *nats.Msg) {
received++
if received >= ns {
done <- true
select {
case done <- true:
default:
}
}
m.Ack()
})
Expand Down

0 comments on commit e4d78a0

Please sign in to comment.