Skip to content

Commit d46a552

Browse files
committed
Fix CI
1 parent 92f9d1e commit d46a552

File tree

2 files changed

+20
-42
lines changed

2 files changed

+20
-42
lines changed

.github/test/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
source .github/lib.sh || exit 1
44

55
COVERAGE_PROFILE=$(mktemp)
6-
go test -race -v "-coverprofile=${COVERAGE_PROFILE}" -vet=off ./...
6+
go test -race "-coverprofile=${COVERAGE_PROFILE}" -vet=off ./...
77
go tool cover "-func=${COVERAGE_PROFILE}"
88

99
if [[ $CI ]]; then

websocket_test.go

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,6 @@ func TestAutobahnServer(t *testing.T) {
282282
map[string]interface{}{
283283
"agent": "main",
284284
"url": strings.Replace(s.URL, "http", "ws", 1),
285-
"options": map[string]interface{}{
286-
"version": 18,
287-
},
288285
},
289286
},
290287
"cases": []string{"*"},
@@ -319,45 +316,14 @@ func TestAutobahnServer(t *testing.T) {
319316
t.Fatalf("failed to run wstest: %v\nout:\n%s", err, out)
320317
}
321318

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")
354320
}
355321

356322
func echoLoop(ctx context.Context, c *websocket.Conn, t *testing.T) {
357323
defer c.Close(websocket.StatusInternalError, "")
358324

359325
echo := func() error {
360-
ctx, cancel := context.WithTimeout(ctx, time.Minute)
326+
ctx, cancel := context.WithTimeout(ctx, time.Second*15)
361327
defer cancel()
362328

363329
typ, r, err := c.Read(ctx)
@@ -465,7 +431,7 @@ func TestAutobahnClient(t *testing.T) {
465431

466432
for i := 1; i <= cases; i++ {
467433
func() {
468-
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
434+
ctx, cancel := context.WithTimeout(ctx, time.Second*15)
469435
defer cancel()
470436

471437
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) {
482448
}
483449
c.Close(websocket.StatusNormalClosure, "")
484450

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)
486456
if err != nil {
487457
t.Fatalf("failed to read index.json: %v", err)
488458
}
489459

490460
var indexJSON map[string]map[string]struct {
491-
Behavior string `json:"behavior"`
461+
Behavior string `json:"behavior"`
462+
BehaviorClose string `json:"behaviorClose"`
492463
}
493464
err = json.Unmarshal(wstestOut, &indexJSON)
494465
if err != nil {
@@ -504,14 +475,21 @@ func TestAutobahnClient(t *testing.T) {
504475
failed = true
505476
t.Errorf("test %v failed", test)
506477
}
478+
switch result.BehaviorClose {
479+
case "OK", "INFORMATIONAL":
480+
default:
481+
failed = true
482+
t.Errorf("bad close behaviour for test %v", test)
483+
}
507484
}
508485
}
509486

510487
if failed {
488+
path = strings.Replace(path, ".json", ".html", 1)
511489
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)
513491
} 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)
515493
}
516494
}
517495
}

0 commit comments

Comments
 (0)