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

Function TestKunLogStatStore

pkg/controller/rtctrl/logstore_test.go:49–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestKunLogStatStore(t *testing.T) {
50 params := &LogStatStoreParameter{
51 RequestID: "1111",
52 RuntimeID: "aaaa",
53 UserID: "user",
54 FunctionName: "func",
55 FunctionVersion: "1",
56 FilePath: "/tmp",
57 LogType: "bos",
58 }
59 s := newLogStatStore(params).(*kunLogStatStore)
60 if s.Receiver() != "aaaa" {
61 t.Error(s.Receiver())
62 return
63 }
64 if s.String() != "1111@aaaa" {
65 t.Error(s.String())
66 return
67 }
68
69 _, err := s.WriteStdLog(StdoutLog, []byte("stdout logline"), false)
70 if err != nil {
71 t.Error(err)
72 return
73 }
74 _, err = s.WriteStdLog(StderrLog, []byte("stderr logline"), false)
75 if err != nil {
76 t.Error(err)
77 return
78 }
79 err = s.WriteFunctionLog("easyfaas logline")
80 if err != nil {
81 t.Error(err)
82 return
83 }
84 if s.flags.Has(flagOutdone) || s.flags.Has(flagErrdone) {
85 t.Error(s.flags)
86 return
87 }
88 s.SetMemUsed(1024)
89 if 1024 != s.MemUsed() {
90 t.Errorf("memused: %d", s.MemUsed())
91 return
92 }
93
94 s.WriteStdLog(StdoutLog, []byte("stdout logline 2"), true)
95 s.WriteStdLog(StderrLog, []byte("stderr logline 2"), true)
96 if !s.flags.Has(flagOutdone) || !s.flags.Has(flagErrdone) {
97 t.Error(s.flags)
98 return
99 }
100 logdata, err := s.Close()
101 if err != nil {
102 t.Error(err)
103 return
104 }
105 if len(logdata) <= 0 {
106 t.Error("no log?")

Callers

nothing calls this directly

Calls 13

newLogStatStoreFunction · 0.85
ErrorfMethod · 0.80
ReceiverMethod · 0.65
StringMethod · 0.65
WriteStdLogMethod · 0.65
WriteFunctionLogMethod · 0.65
SetMemUsedMethod · 0.65
MemUsedMethod · 0.65
CloseMethod · 0.65
LogFileMethod · 0.65
WaitMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected