MCPcopy
hub / github.com/coder/websocket / TestAutobahn

Function TestAutobahn

autobahn_test.go:43–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41var onlyAutobahnCases = []string{}
42
43func TestAutobahn(t *testing.T) {
44 t.Parallel()
45
46 if os.Getenv("AUTOBAHN") == "" {
47 t.SkipNow()
48 }
49
50 if os.Getenv("AUTOBAHN") == "fast" {
51 // These are the slow tests.
52 excludedAutobahnCases = append(excludedAutobahnCases,
53 "9.*", "12.*", "13.*",
54 )
55 }
56
57 if len(onlyAutobahnCases) > 0 {
58 excludedAutobahnCases = []string{}
59 autobahnCases = onlyAutobahnCases
60 }
61
62 ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
63 defer cancel()
64
65 wstestURL, closeFn, err := wstestServer(t, ctx)
66 assert.Success(t, err)
67 defer func() {
68 assert.Success(t, closeFn())
69 }()
70
71 err = waitWS(ctx, wstestURL)
72 assert.Success(t, err)
73
74 cases, err := wstestCaseCount(ctx, wstestURL)
75 assert.Success(t, err)
76
77 t.Run("cases", func(t *testing.T) {
78 for i := 1; i <= cases; i++ {
79 i := i
80 t.Run("", func(t *testing.T) {
81 ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
82 defer cancel()
83
84 c, _, err := websocket.Dial(ctx, fmt.Sprintf(wstestURL+"/runCase?case=%v&agent=main", i), &websocket.DialOptions{
85 CompressionMode: websocket.CompressionContextTakeover,
86 })
87 assert.Success(t, err)
88 err = wstest.EchoLoop(ctx, c)
89 t.Logf("echoLoop: %v", err)
90 })
91 }
92 })
93
94 c, _, err := websocket.Dial(ctx, wstestURL+"/updateReports?agent=main", nil)
95 assert.Success(t, err)
96 c.Close(websocket.StatusNormalClosure, "")
97
98 checkWSTestIndex(t, "./ci/out/autobahn-report/index.json")
99}
100

Callers

nothing calls this directly

Calls 8

SuccessFunction · 0.92
DialFunction · 0.92
EchoLoopFunction · 0.92
wstestServerFunction · 0.85
waitWSFunction · 0.85
wstestCaseCountFunction · 0.85
checkWSTestIndexFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…