MCPcopy Create free account
hub / github.com/cloudwego/netpoll / TestConnectionLargeWrite

Function TestConnectionLargeWrite

connection_test.go:90–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestConnectionLargeWrite(t *testing.T) {
91 // ci machine don't have 4GB memory, so skip test
92 t.Skipf("skip large write test for ci job")
93 totalSize := 1024 * 1024 * 1024 * 4
94 var wg sync.WaitGroup
95 wg.Add(1)
96 opts := &options{}
97 opts.onRequest = func(ctx context.Context, connection Connection) error {
98 if connection.Reader().Len() < totalSize {
99 return nil
100 }
101 _, err := connection.Reader().Next(totalSize)
102 MustNil(t, err)
103 err = connection.Reader().Release()
104 MustNil(t, err)
105 wg.Done()
106 return nil
107 }
108
109 r, w := GetSysFdPairs()
110 rconn, wconn := &connection{}, &connection{}
111 rconn.init(&netFD{fd: r}, opts)
112 wconn.init(&netFD{fd: w}, opts)
113
114 msg := make([]byte, totalSize/4)
115 for i := 0; i < 4; i++ {
116 _, err := wconn.Writer().WriteBinary(msg)
117 MustNil(t, err)
118 }
119 wg.Wait()
120
121 rconn.Close()
122}
123
124func TestConnectionRead(t *testing.T) {
125 r, w := GetSysFdPairs()

Callers

nothing calls this directly

Calls 12

initMethod · 0.95
WriterMethod · 0.95
CloseMethod · 0.95
GetSysFdPairsFunction · 0.85
AddMethod · 0.80
LenMethod · 0.65
ReaderMethod · 0.65
NextMethod · 0.65
ReleaseMethod · 0.65
WriteBinaryMethod · 0.65
WaitMethod · 0.65
MustNilFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…