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

Function TestInvocation

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

Source from the content-addressed store, hash-verified

34)
35
36func TestInvocation(t *testing.T) {
37 rtID := "runtime"
38 rtMap := NewRuntimeManager(getFuncletNode(), &RuntimeManagerParameters{MaxRuntimeIdle: 10, MaxRunnerDefunct: 30})
39 rtParams := &NewRuntimeParameters{
40 RuntimeID: rtID,
41 ConcurrentMode: true,
42 StreamMode: false,
43 WaitRuntimeAliveTimeout: 3,
44 Resource: &api.Resource{},
45 }
46 rt := rtMap.NewRuntime(rtParams)
47 rt.SetState(RuntimeStateWarm)
48
49 rc := NewRuntimeConfigOptions()
50 ds := &DispatcherV2Options{
51 RunnerServerAddress: getTmpSock(),
52 RuntimeServerAddress: getTmpSock(),
53 UserLogFileDir: defaultUserLogFilePath,
54 UserLogType: string(UserLogTypePlain),
55 }
56 cli, _ := NewRuntimeClient(rc, ds, rtMap)
57
58 <-time.NewTicker(time.Second).C
59 funN := "test"
60 cmID := "xxx"
61 timeout := int64(3)
62 mem := int64(256)
63 ver := "1"
64 reqid := id.GetRequestID()
65 rt.SetCommitID(cmID)
66 go initRuntime(cli.dispatchServer, rt.RuntimeID, cmID, reqid)
67
68 input := &InvocationInput{
69 Runtime: rt,
70 RequestID: reqid,
71 Configuration: &api.FunctionConfiguration{
72 CommitID: &cmID,
73 FunctionConfiguration: lambda.FunctionConfiguration{
74 FunctionName: &funN,
75 Timeout: &timeout,
76 MemorySize: &mem,
77 Version: &ver,
78 },
79 },
80 User: &api.User{
81 ID: "xxx",
82 },
83 WithStreamMode: false,
84 Request: &api.InvokeProxyRequest{
85 Headers: make(map[string]string, 0),
86 Body: []byte("test"),
87 },
88 Response: api.NewInvokeProxyResponse(),
89 EnableMetrics: false,
90 Logger: logs.NewLogger().WithField("request_id", reqid),
91 }
92
93 output := cli.InvokeFunction(input)

Callers

nothing calls this directly

Calls 14

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
WithFieldMethod · 0.80

Tested by

no test coverage detected