MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / TestSendGenericRequestLoop

Function TestSendGenericRequestLoop

pkg/controller/rtctrl/runtime_test.go:146–236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestSendGenericRequestLoop(t *testing.T) {
147 id := "runtime-id"
148 cmid := "commit-xxx"
149 reqid := utilID.GetRequestID()
150 rtMap := NewRuntimeManager(getFuncletNode(), &RuntimeManagerParameters{MaxRuntimeIdle: 10, MaxRunnerDefunct: 30})
151 rtParams := &NewRuntimeParameters{
152 RuntimeID: id,
153 ConcurrentMode: false,
154 StreamMode: false,
155 WaitRuntimeAliveTimeout: 3,
156 Resource: &api.Resource{},
157 }
158 rt := rtMap.NewRuntime(rtParams)
159 req, resp := buildRequestResponse(id, cmid, reqid)
160 conn, _, ok := setupHijackConn(resp, req)
161 if !ok {
162 t.Error("setup hijack connect failed")
163 return
164 }
165 rt.SetState(RuntimeStateCold)
166 params := &startRuntimeParams{
167 commitID: cmid,
168 hostIP: "127.0.0.1",
169 conn: conn,
170 warmNotify: make(chan struct{}),
171 urlParams: req.URL.Query(),
172 }
173 if err := rt.initRuntime(params); err != nil {
174 t.Errorf("init runtime failed: %s", err)
175 return
176 }
177
178 now := time.Now().UnixNano()
179 ver := "1"
180 reqinfo := RequestInfo{
181 RequestID: reqid,
182 Runtime: rt,
183 InvokeStartTimeNS: now,
184 InvokeStartTimeMS: now / int64(time.Millisecond),
185 SyncChannel: make(chan struct{}, 1),
186 TimeoutChannel: make(chan struct{}, 1),
187 Input: &InvocationInput{
188 Runtime: rt,
189 RequestID: reqid,
190 Configuration: &api.FunctionConfiguration{
191 CommitID: &cmid,
192 FunctionConfiguration: lambda.FunctionConfiguration{Version: &ver},
193 },
194 User: &api.User{
195 ID: "xxx",
196 },
197 WithStreamMode: false,
198 Request: &api.InvokeProxyRequest{
199 Headers: make(map[string]string, 0),
200 Body: []byte("{}"),
201 },
202 Response: api.NewInvokeProxyResponse(),
203 EnableMetrics: true,

Callers

nothing calls this directly

Calls 15

NewRuntimeMethod · 0.95
NewInvokeProxyResponseFunction · 0.92
NewLoggerFunction · 0.92
getFuncletNodeFunction · 0.85
buildRequestResponseFunction · 0.85
setupHijackConnFunction · 0.85
NewRtCtrlInvokeMetricFunction · 0.85
SetStateMethod · 0.80
initRuntimeMethod · 0.80
ErrorfMethod · 0.80
WithFieldMethod · 0.80

Tested by

no test coverage detected