(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func 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 | |
| 124 | func TestEventStop(t *testing.T) { |
| 125 | rtMap := initRuntimeList(1) |
nothing calls this directly
no test coverage detected