Detect and alert on stuck jobs
CI / Test (rest) (pull_request) Successful in 39s
CI / Test (store) (pull_request) Successful in 40s
CI / Lint (pull_request) Failing after 11s
CI / Build (linux/amd64) (pull_request) Successful in 8s
CI / Build (linux/arm64) (pull_request) Successful in 7s
CI / Build (windows/amd64) (pull_request) Successful in 25s
CI / Test (server-http) (pull_request) Successful in 1m39s
e2e / Playwright vs docker-compose (pull_request) Successful in 1m16s
CI / Test (rest) (pull_request) Successful in 39s
CI / Test (store) (pull_request) Successful in 40s
CI / Lint (pull_request) Failing after 11s
CI / Build (linux/amd64) (pull_request) Successful in 8s
CI / Build (linux/arm64) (pull_request) Successful in 7s
CI / Build (windows/amd64) (pull_request) Successful in 25s
CI / Test (server-http) (pull_request) Successful in 1m39s
e2e / Playwright vs docker-compose (pull_request) Successful in 1m16s
This commit is contained in:
@@ -7,6 +7,48 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestListRunningJobActivity(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := openTestStore(t)
|
||||
ctx := context.Background()
|
||||
hostID := makeSchedHost(t, s)
|
||||
started := time.Now().UTC().Add(-8 * time.Hour).Truncate(time.Second)
|
||||
|
||||
for _, id := range []string{"running-idle", "running-active", "finished"} {
|
||||
if err := s.CreateJob(ctx, Job{ID: id, HostID: hostID, Kind: "backup", ActorKind: "user", CreatedAt: started}); err != nil {
|
||||
t.Fatalf("create %s: %v", id, err)
|
||||
}
|
||||
if err := s.MarkJobStarted(ctx, id, started); err != nil {
|
||||
t.Fatalf("start %s: %v", id, err)
|
||||
}
|
||||
}
|
||||
activity := started.Add(7 * time.Hour)
|
||||
if err := s.AppendJobLog(ctx, "running-active", 1, activity, "stdout", "still working"); err != nil {
|
||||
t.Fatalf("append log: %v", err)
|
||||
}
|
||||
if err := s.MarkJobFinished(ctx, "finished", "succeeded", 0, nil, "", activity); err != nil {
|
||||
t.Fatalf("finish: %v", err)
|
||||
}
|
||||
|
||||
got, err := s.ListRunningJobActivity(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("list activity: %v", err)
|
||||
}
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("got %d rows, want 2: %+v", len(got), got)
|
||||
}
|
||||
byID := make(map[string]RunningJobActivity, len(got))
|
||||
for _, row := range got {
|
||||
byID[row.JobID] = row
|
||||
}
|
||||
if !byID["running-idle"].LastActivity.Equal(started) {
|
||||
t.Errorf("idle last activity = %s, want %s", byID["running-idle"].LastActivity, started)
|
||||
}
|
||||
if !byID["running-active"].LastActivity.Equal(activity) {
|
||||
t.Errorf("active last activity = %s, want %s", byID["running-active"].LastActivity, activity)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLatestJobByKind(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := openTestStore(t)
|
||||
|
||||
Reference in New Issue
Block a user