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

Function TestEventOccupy

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

Source from the content-addressed store, hash-verified

25)
26
27func TestEventOccupy(t *testing.T) {
28 rtMap := initRuntimeList(1)
29 list := rtMap.RuntimeList()
30 rt := list[0]
31 rt.SetState(RuntimeStateClosed)
32 err := rt.CAS(OpOccupy, &OccupyInput{CommitID: "xxx", WithStreamMode: false})
33 expectedErr := &RuntimeStateUnmatched{RuntimeID: rt.RuntimeID, CurrentState: RuntimeStateClosed, ExpectedState: []string{RuntimeStateCold}}
34 if err.Error() != expectedErr.Error() {
35 t.Errorf("occupy runtime expected %s, but got %s", expectedErr, err)
36 return
37 }
38
39 rt.SetState(RuntimeStateCold)
40 rt.Invalidate()
41 err1 := rt.CAS(OpOccupy, &OccupyInput{
42 CommitID: "xxx",
43 WithStreamMode: false,
44 MemorySize: uint64(128 * bytefmt.Megabyte),
45 })
46 expectedErr1 := &RuntimeMatchError{
47 Reason: "runner is not available",
48 }
49 if err1.Error() != expectedErr1.Error() {
50 t.Errorf("occupy runtime expected %s, but got %s", expectedErr, err)
51 return
52 }
53}
54
55func TestEventMerged(t *testing.T) {
56 rtMap := initRuntimeList(1)

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected