(t *testing.T)
| 182 | } |
| 183 | |
| 184 | func TestWSConcurrentConns(t *testing.T) { |
| 185 | sopts := testWSGetDefaultOptions(t, false) |
| 186 | s := RunServerWithOptions(sopts) |
| 187 | defer s.Shutdown() |
| 188 | |
| 189 | url := fmt.Sprintf("ws://127.0.0.1:%d", sopts.Websocket.Port) |
| 190 | |
| 191 | total := 50 |
| 192 | errCh := make(chan error, total) |
| 193 | wg := sync.WaitGroup{} |
| 194 | wg.Add(total) |
| 195 | for i := 0; i < total; i++ { |
| 196 | go func() { |
| 197 | defer wg.Done() |
| 198 | |
| 199 | nc, err := nats.Connect(url) |
| 200 | if err != nil { |
| 201 | errCh <- fmt.Errorf("Error on connect: %v", err) |
| 202 | return |
| 203 | } |
| 204 | defer nc.Close() |
| 205 | |
| 206 | sub, err := nc.SubscribeSync(nuid.Next()) |
| 207 | if err != nil { |
| 208 | errCh <- fmt.Errorf("Error on subscribe: %v", err) |
| 209 | return |
| 210 | } |
| 211 | nc.Publish(sub.Subject, []byte("here")) |
| 212 | if _, err := sub.NextMsg(time.Second); err != nil { |
| 213 | errCh <- err |
| 214 | } |
| 215 | }() |
| 216 | } |
| 217 | wg.Wait() |
| 218 | select { |
| 219 | case e := <-errCh: |
| 220 | t.Fatal(e.Error()) |
| 221 | default: |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | func TestWSCompression(t *testing.T) { |
| 226 | msgSize := rand.Intn(40000) |
nothing calls this directly
no test coverage detected