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

Function TestStatisticsInfo

pkg/controller/rtctrl/statistics_test.go:31–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestStatisticsInfo(t *testing.T) {
32 cmid := "commit-xxx"
33 funcName := "test"
34 reqid := id.GetRequestID()
35 now := time.Now().UnixNano()
36 ver := "1"
37 timeout := int64(3)
38 reqinfo := RequestInfo{
39 RequestID: reqid,
40 InvokeStartTimeNS: now,
41 InvokeStartTimeMS: now / int64(time.Millisecond),
42 SyncChannel: make(chan struct{}, 1),
43 TimeoutChannel: make(chan struct{}, 1),
44 Status: StatusSuccess,
45 Input: &InvocationInput{
46 RequestID: reqid,
47 Configuration: &api.FunctionConfiguration{
48 CommitID: &cmid,
49 FunctionConfiguration: lambda.FunctionConfiguration{
50 Version: &ver,
51 Timeout: &timeout,
52 FunctionName: &funcName,
53 },
54 },
55 User: &api.User{
56 ID: "xxx",
57 },
58 WithStreamMode: true,
59 Request: &api.InvokeProxyRequest{
60 Headers: make(map[string]string, 0),
61 Body: []byte("{}"),
62 },
63 Response: api.NewInvokeProxyResponse(),
64 EnableMetrics: false,
65 Logger: logs.NewLogger().WithField("request_id", reqid),
66 },
67 Output: &InvocationOutput{Output: &InvocationResponse{}, Statistic: &InvocationStatistic{}},
68 }
69 info := statisticsInfo(&reqinfo)
70 if info == nil {
71 t.Error("statistics info should not be nil")
72 return
73 }
74 if err := info.Decode(info.Encode()); err != nil {
75 t.Errorf("encode/decode statistic info failed: %s", err)
76 }
77}

Callers

nothing calls this directly

Calls 9

GetRequestIDFunction · 0.92
NewInvokeProxyResponseFunction · 0.92
NewLoggerFunction · 0.92
statisticsInfoFunction · 0.85
WithFieldMethod · 0.80
ErrorfMethod · 0.80
DecodeMethod · 0.65
EncodeMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected