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

Function TestInvocationWithStream

pkg/controller/rtctrl/client_test.go:98–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestInvocationWithStream(t *testing.T) {
99 rtID := "runtime"
100 rtMap := NewRuntimeManager(getFuncletNode(), &RuntimeManagerParameters{MaxRuntimeIdle: 10, MaxRunnerDefunct: 30})
101 rtParams := &NewRuntimeParameters{
102 RuntimeID: rtID,
103 ConcurrentMode: true,
104 StreamMode: false,
105 WaitRuntimeAliveTimeout: 3,
106 Resource: &api.Resource{},
107 }
108 rt := rtMap.NewRuntime(rtParams)
109 rt.SetState(RuntimeStateWarm)
110
111 rc := NewRuntimeConfigOptions()
112 ds := &DispatcherV2Options{
113 RunnerServerAddress: getTmpSock(),
114 RuntimeServerAddress: getTmpSock(),
115 UserLogFileDir: defaultUserLogFilePath,
116 UserLogType: string(UserLogTypePlain),
117 }
118 cli, _ := NewRuntimeClient(rc, ds, rtMap)
119
120 <-time.NewTicker(time.Second).C
121 cmID := "xxx"
122 ver := "1"
123 funN := "test"
124 reqid := id.GetRequestID()
125 rt.SetCommitID(cmID)
126 rt.updateStreamMode(true)
127 go initRuntime(cli.dispatchServer, rt.RuntimeID, cmID, reqid)
128
129 input := &InvocationInput{
130 Runtime: rt,
131 RequestID: reqid,
132 Configuration: &api.FunctionConfiguration{
133 CommitID: &cmID,
134 FunctionConfiguration: lambda.FunctionConfiguration{
135 FunctionName: &funN,
136 Version: &ver,
137 },
138 },
139 User: &api.User{
140 ID: "xxx",
141 },
142 WithStreamMode: true,
143 Request: &api.InvokeProxyRequest{
144 Headers: make(map[string]string, 0),
145 Body: []byte("test"),
146 },
147 Response: api.NewInvokeProxyResponse(),
148 EnableMetrics: true,
149 Logger: logs.NewLogger().WithField("request_id", reqid),
150 }
151 output := cli.InvokeFunction(input)
152 t.Logf("%+v", output)
153}
154
155func initRuntime(s *DispatchServerV2, runtimeID string, commitID string, requestID string) {

Callers

nothing calls this directly

Calls 15

NewRuntimeMethod · 0.95
InvokeFunctionMethod · 0.95
GetRequestIDFunction · 0.92
NewInvokeProxyResponseFunction · 0.92
NewLoggerFunction · 0.92
getFuncletNodeFunction · 0.85
NewRuntimeConfigOptionsFunction · 0.85
getTmpSockFunction · 0.85
NewRuntimeClientFunction · 0.85
initRuntimeFunction · 0.85
SetStateMethod · 0.80
updateStreamModeMethod · 0.80

Tested by

no test coverage detected