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

Function TestEventMark

pkg/controller/rtctrl/event_test.go:87–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestEventMark(t *testing.T) {
88 rtMap := initRuntimeList(1)
89 list := rtMap.RuntimeList()
90 rt := list[0]
91 err := rt.CAS(OpMark, &MarkInput{CommitID: "xxx", ConcurrentQuota: 1})
92 expectedErr := &RuntimeStateUnmatched{
93 RuntimeID: rt.RuntimeID,
94 CurrentState: RuntimeStateCold,
95 ExpectedState: []string{RuntimeStateWarmUp, RuntimeStateWarm},
96 }
97 if err.Error() != expectedErr.Error() {
98 t.Errorf("mark runtime expected %s, but got %s", expectedErr, err)
99 return
100 }
101
102 rt.CAS(OpOccupy, &OccupyInput{CommitID: "xxx", WithStreamMode: false})
103 err2 := rt.CAS(OpMark, &MarkInput{CommitID: "xxx", ConcurrentQuota: 1})
104 expectedErr2 := &RuntimeMatchError{
105 Reason: "concurrency exceed limit",
106 }
107 if err2.Error() != expectedErr2.Error() {
108 t.Errorf("mark runtime expected %s, but got %s", expectedErr2, err2)
109 return
110 }
111
112 rt.SetState(RuntimeStateWarm)
113 rt.Invalidate()
114 err1 := rt.CAS(OpMark, &MarkInput{CommitID: "xxx", ConcurrentQuota: 1})
115 expectedErr1 := &RuntimeMatchError{
116 Reason: "runner is not available",
117 }
118 if err1.Error() != expectedErr1.Error() {
119 t.Errorf("mark runtime expected %s, but got %s", expectedErr1, err1)
120 return
121 }
122}
123
124func TestEventStop(t *testing.T) {
125 rtMap := initRuntimeList(1)

Callers

nothing calls this directly

Calls 9

ErrorMethod · 0.95
ErrorMethod · 0.95
initRuntimeListFunction · 0.85
CASMethod · 0.80
ErrorfMethod · 0.80
SetStateMethod · 0.80
InvalidateMethod · 0.80
RuntimeListMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected