MCPcopy Create free account
hub / github.com/coder/coder / TestDetectorNoHungJobs

Function TestDetectorNoHungJobs

coderd/jobreaper/detector_test.go:116–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestDetectorNoHungJobs(t *testing.T) {
117 t.Parallel()
118
119 ctx := testutil.Context(t, testutil.WaitLong)
120 env := newDetectorTestEnv(ctx, t)
121 defer env.close()
122
123 // Insert some jobs that are running and haven't been updated in a while,
124 // but not enough to be considered hung.
125 now := time.Now()
126 org := dbgen.Organization(t, env.DB, database.Organization{})
127 user := dbgen.User(t, env.DB, database.User{})
128 file := dbgen.File(t, env.DB, database.File{})
129 for i := 0; i < 5; i++ {
130 dbgen.ProvisionerJob(t, env.DB, env.Pubsub, database.ProvisionerJob{
131 CreatedAt: now.Add(-time.Minute * 5),
132 UpdatedAt: now.Add(-time.Minute * time.Duration(i)),
133 StartedAt: sql.NullTime{
134 Time: now.Add(-time.Minute * 5),
135 Valid: true,
136 },
137 OrganizationID: org.ID,
138 InitiatorID: user.ID,
139 Provisioner: database.ProvisionerTypeEcho,
140 StorageMethod: database.ProvisionerStorageMethodFile,
141 FileID: file.ID,
142 Type: database.ProvisionerJobTypeWorkspaceBuild,
143 Input: []byte("{}"),
144 })
145 }
146
147 stats := env.tick(ctx, now)
148 require.NoError(t, stats.Error)
149 require.Empty(t, stats.TerminatedJobIDs)
150}
151
152func TestDetectorHungWorkspaceBuild(t *testing.T) {
153 t.Parallel()

Callers

nothing calls this directly

Calls 11

ContextFunction · 0.92
OrganizationFunction · 0.92
UserFunction · 0.92
FileFunction · 0.92
ProvisionerJobFunction · 0.92
newDetectorTestEnvFunction · 0.85
DurationMethod · 0.80
closeMethod · 0.65
AddMethod · 0.65
tickMethod · 0.45
EmptyMethod · 0.45

Tested by

no test coverage detected