MCPcopy
hub / github.com/nats-io/nats.go / waitForJSReady

Function waitForJSReady

jetstream/test/helper_test.go:230–247  ·  view source on GitHub ↗
(t *testing.T, nc *nats.Conn)

Source from the content-addressed store, hash-verified

228}
229
230func waitForJSReady(t *testing.T, nc *nats.Conn) {
231 var err error
232 timeout := time.Now().Add(10 * time.Second)
233 for time.Now().Before(timeout) {
234 // Use a smaller MaxWait here since if it fails, we don't want
235 // to wait for too long since we are going to try again.
236 js, err := nc.JetStream(nats.MaxWait(250 * time.Millisecond))
237 if err != nil {
238 t.Fatal(err)
239 }
240 _, err = js.AccountInfo()
241 if err != nil {
242 continue
243 }
244 return
245 }
246 t.Fatalf("Timeout waiting for JS to be ready: %v", err)
247}
248
249func withJSClusterAndStream(t *testing.T, clusterName string, size int, stream jetstream.StreamConfig, tfn func(t *testing.T, subject string, srvs ...*jsServer)) {
250 t.Helper()

Callers 1

setupJSClusterWithSizeFunction · 0.70

Calls 4

JetStreamMethod · 0.80
FatalfMethod · 0.80
AddMethod · 0.65
AccountInfoMethod · 0.65

Tested by

no test coverage detected