MCPcopy Index your code
hub / github.com/coder/coder / TestDetectorHungOtherJobTypes

Function TestDetectorHungOtherJobTypes

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

Source from the content-addressed store, hash-verified

396}
397
398func TestDetectorHungOtherJobTypes(t *testing.T) {
399 t.Parallel()
400
401 ctx := testutil.Context(t, testutil.WaitLong)
402 env := newDetectorTestEnv(ctx, t)
403 defer env.close()
404
405 var (
406 now = time.Now()
407 tenMinAgo = now.Add(-time.Minute * 10)
408 sixMinAgo = now.Add(-time.Minute * 6)
409 org = dbgen.Organization(t, env.DB, database.Organization{})
410 user = dbgen.User(t, env.DB, database.User{})
411 file = dbgen.File(t, env.DB, database.File{})
412
413 // Template import job.
414 templateImportJob = dbgen.ProvisionerJob(t, env.DB, env.Pubsub, database.ProvisionerJob{
415 CreatedAt: tenMinAgo,
416 UpdatedAt: sixMinAgo,
417 StartedAt: sql.NullTime{
418 Time: tenMinAgo,
419 Valid: true,
420 },
421 OrganizationID: org.ID,
422 InitiatorID: user.ID,
423 Provisioner: database.ProvisionerTypeEcho,
424 StorageMethod: database.ProvisionerStorageMethodFile,
425 FileID: file.ID,
426 Type: database.ProvisionerJobTypeTemplateVersionImport,
427 Input: []byte("{}"),
428 })
429 _ = dbgen.TemplateVersion(t, env.DB, database.TemplateVersion{
430 OrganizationID: org.ID,
431 JobID: templateImportJob.ID,
432 CreatedBy: user.ID,
433 })
434 )
435
436 // Template dry-run job.
437 dryRunVersion := dbgen.TemplateVersion(t, env.DB, database.TemplateVersion{
438 OrganizationID: org.ID,
439 CreatedBy: user.ID,
440 })
441 input, err := json.Marshal(provisionerdserver.TemplateVersionDryRunJob{
442 TemplateVersionID: dryRunVersion.ID,
443 })
444 require.NoError(t, err)
445 templateDryRunJob := dbgen.ProvisionerJob(t, env.DB, env.Pubsub, database.ProvisionerJob{
446 CreatedAt: tenMinAgo,
447 UpdatedAt: sixMinAgo,
448 StartedAt: sql.NullTime{
449 Time: tenMinAgo,
450 Valid: true,
451 },
452 OrganizationID: org.ID,
453 InitiatorID: user.ID,
454 Provisioner: database.ProvisionerTypeEcho,
455 StorageMethod: database.ProvisionerStorageMethodFile,

Callers

nothing calls this directly

Calls 15

ContextFunction · 0.92
OrganizationFunction · 0.92
UserFunction · 0.92
FileFunction · 0.92
ProvisionerJobFunction · 0.92
TemplateVersionFunction · 0.92
newDetectorTestEnvFunction · 0.85
requireTerminatedJobFunction · 0.85
LogMethod · 0.80
closeMethod · 0.65
AddMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected