@@ -282,9 +282,6 @@ func TestAutobahnServer(t *testing.T) {
282
282
map [string ]interface {}{
283
283
"agent" : "main" ,
284
284
"url" : strings .Replace (s .URL , "http" , "ws" , 1 ),
285
- "options" : map [string ]interface {}{
286
- "version" : 18 ,
287
- },
288
285
},
289
286
},
290
287
"cases" : []string {"*" },
@@ -319,45 +316,14 @@ func TestAutobahnServer(t *testing.T) {
319
316
t .Fatalf ("failed to run wstest: %v\n out:\n %s" , err , out )
320
317
}
321
318
322
- b , err := ioutil .ReadFile ("./wstest_reports/server/index.json" )
323
- if err != nil {
324
- t .Fatalf ("failed to read index.json: %v" , err )
325
- }
326
-
327
- var indexJSON map [string ]map [string ]struct {
328
- Behavior string `json:"behavior"`
329
- }
330
- err = json .Unmarshal (b , & indexJSON )
331
- if err != nil {
332
- t .Fatalf ("failed to unmarshal index.json: %v" , err )
333
- }
334
-
335
- var failed bool
336
- for _ , tests := range indexJSON {
337
- for test , result := range tests {
338
- switch result .Behavior {
339
- case "OK" , "NON-STRICT" , "INFORMATIONAL" :
340
- default :
341
- failed = true
342
- t .Errorf ("test %v failed" , test )
343
- }
344
- }
345
- }
346
-
347
- if failed {
348
- if os .Getenv ("CI" ) == "" {
349
- t .Errorf ("wstest found failure, please see ./wstest_reports/server/index.html" )
350
- } else {
351
- t .Errorf ("wstest found failure, please run test.sh locally to see ./wstest_reports/server/index.html" )
352
- }
353
- }
319
+ checkWSTestIndex (t , "./wstest_reports/server/index.json" )
354
320
}
355
321
356
322
func echoLoop (ctx context.Context , c * websocket.Conn , t * testing.T ) {
357
323
defer c .Close (websocket .StatusInternalError , "" )
358
324
359
325
echo := func () error {
360
- ctx , cancel := context .WithTimeout (ctx , time .Minute )
326
+ ctx , cancel := context .WithTimeout (ctx , time .Second * 15 )
361
327
defer cancel ()
362
328
363
329
typ , r , err := c .Read (ctx )
@@ -465,7 +431,7 @@ func TestAutobahnClient(t *testing.T) {
465
431
466
432
for i := 1 ; i <= cases ; i ++ {
467
433
func () {
468
- ctx , cancel := context .WithTimeout (ctx , time .Second * 5 )
434
+ ctx , cancel := context .WithTimeout (ctx , time .Second * 15 )
469
435
defer cancel ()
470
436
471
437
c , _ , err := websocket .Dial (ctx , fmt .Sprintf ("ws://localhost:9001/runCase?case=%v&agent=main" , i ))
@@ -482,13 +448,18 @@ func TestAutobahnClient(t *testing.T) {
482
448
}
483
449
c .Close (websocket .StatusNormalClosure , "" )
484
450
485
- wstestOut , err := ioutil .ReadFile ("./wstest_reports/client/index.json" )
451
+ checkWSTestIndex (t , "./wstest_reports/client/index.json" )
452
+ }
453
+
454
+ func checkWSTestIndex (t * testing.T , path string ) {
455
+ wstestOut , err := ioutil .ReadFile (path )
486
456
if err != nil {
487
457
t .Fatalf ("failed to read index.json: %v" , err )
488
458
}
489
459
490
460
var indexJSON map [string ]map [string ]struct {
491
- Behavior string `json:"behavior"`
461
+ Behavior string `json:"behavior"`
462
+ BehaviorClose string `json:"behaviorClose"`
492
463
}
493
464
err = json .Unmarshal (wstestOut , & indexJSON )
494
465
if err != nil {
@@ -504,14 +475,21 @@ func TestAutobahnClient(t *testing.T) {
504
475
failed = true
505
476
t .Errorf ("test %v failed" , test )
506
477
}
478
+ switch result .BehaviorClose {
479
+ case "OK" , "INFORMATIONAL" :
480
+ default :
481
+ failed = true
482
+ t .Errorf ("bad close behaviour for test %v" , test )
483
+ }
507
484
}
508
485
}
509
486
510
487
if failed {
488
+ path = strings .Replace (path , ".json" , ".html" , 1 )
511
489
if os .Getenv ("CI" ) == "" {
512
- t .Errorf ("wstest found failure, please see ./wstest_reports/client/index.html" )
490
+ t .Errorf ("wstest found failure, please see %q" , path )
513
491
} else {
514
- t .Errorf ("wstest found failure, please run test.sh locally to see ./wstest_reports/client/index.html" )
492
+ t .Errorf ("wstest found failure, please run test.sh locally to see %q" , path )
515
493
}
516
494
}
517
495
}
0 commit comments