mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 12:59:06 +01:00
Bugs fixed in unit tests and archiver init
This commit is contained in:
parent
db5809d522
commit
f305863616
@ -156,6 +156,7 @@ func setup(t *testing.T) *api.RestApi {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
archiver.Start(repository.GetJobRepository())
|
||||
auth.Init()
|
||||
graph.Init()
|
||||
|
||||
|
@ -17,11 +17,12 @@ import (
|
||||
var (
|
||||
archivePending sync.WaitGroup
|
||||
archiveChannel chan *schema.Job
|
||||
r *repository.JobRepository
|
||||
jobRepo *repository.JobRepository
|
||||
)
|
||||
|
||||
func Start(jobRepo *repository.JobRepository) {
|
||||
func Start(r *repository.JobRepository) {
|
||||
archiveChannel = make(chan *schema.Job, 128)
|
||||
jobRepo = r
|
||||
|
||||
go archivingWorker()
|
||||
}
|
||||
@ -37,9 +38,9 @@ func archivingWorker() {
|
||||
start := time.Now()
|
||||
// not using meta data, called to load JobMeta into Cache?
|
||||
// will fail if job meta not in repository
|
||||
if _, err := r.FetchMetadata(job); err != nil {
|
||||
if _, err := jobRepo.FetchMetadata(job); err != nil {
|
||||
log.Errorf("archiving job (dbid: %d) failed at check metadata step: %s", job.ID, err.Error())
|
||||
r.UpdateMonitoringStatus(job.ID, schema.MonitoringStatusArchivingFailed)
|
||||
jobRepo.UpdateMonitoringStatus(job.ID, schema.MonitoringStatusArchivingFailed)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -48,16 +49,16 @@ func archivingWorker() {
|
||||
jobMeta, err := ArchiveJob(job, context.Background())
|
||||
if err != nil {
|
||||
log.Errorf("archiving job (dbid: %d) failed at archiving job step: %s", job.ID, err.Error())
|
||||
r.UpdateMonitoringStatus(job.ID, schema.MonitoringStatusArchivingFailed)
|
||||
jobRepo.UpdateMonitoringStatus(job.ID, schema.MonitoringStatusArchivingFailed)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := r.UpdateFootprint(jobMeta); err != nil {
|
||||
if err := jobRepo.UpdateFootprint(jobMeta); err != nil {
|
||||
log.Errorf("archiving job (dbid: %d) failed at update Footprint step: %s", job.ID, err.Error())
|
||||
continue
|
||||
}
|
||||
// Update the jobs database entry one last time:
|
||||
if err := r.MarkArchived(jobMeta, schema.MonitoringStatusArchivingSuccessful); err != nil {
|
||||
if err := jobRepo.MarkArchived(jobMeta, schema.MonitoringStatusArchivingSuccessful); err != nil {
|
||||
log.Errorf("archiving job (dbid: %d) failed at marking archived step: %s", job.ID, err.Error())
|
||||
continue
|
||||
}
|
||||
@ -70,6 +71,10 @@ func archivingWorker() {
|
||||
|
||||
// Trigger async archiving
|
||||
func TriggerArchiving(job *schema.Job) {
|
||||
if archiveChannel == nil {
|
||||
log.Fatal("Cannot archive without archiving channel. Did you Start the archiver?")
|
||||
}
|
||||
|
||||
archivePending.Add(1)
|
||||
archiveChannel <- job
|
||||
}
|
||||
|
@ -94,7 +94,7 @@
|
||||
},
|
||||
"scope": "hwthread",
|
||||
"aggregation": "sum",
|
||||
"energy": true,
|
||||
"energy": "power",
|
||||
"timestep": 60,
|
||||
"peak": 500,
|
||||
"normal": 250,
|
||||
@ -136,7 +136,7 @@
|
||||
},
|
||||
"scope": "accelerator",
|
||||
"aggregation": "sum",
|
||||
"energy": true,
|
||||
"energy": "power",
|
||||
"timestep": 60,
|
||||
"peak": 400,
|
||||
"normal": 200,
|
||||
@ -190,7 +190,7 @@
|
||||
},
|
||||
"scope": "socket",
|
||||
"aggregation": "sum",
|
||||
"energy": true,
|
||||
"energy": "power",
|
||||
"timestep": 60,
|
||||
"peak": 500,
|
||||
"normal": 250,
|
||||
|
@ -256,7 +256,7 @@
|
||||
"normal": 250,
|
||||
"caution": 100,
|
||||
"alert": 50,
|
||||
"energy": true
|
||||
"energy": "power"
|
||||
},
|
||||
{
|
||||
"name": "mem_power",
|
||||
@ -270,7 +270,7 @@
|
||||
"normal": 50,
|
||||
"caution": 20,
|
||||
"alert": 10,
|
||||
"energy": true
|
||||
"energy": "power"
|
||||
},
|
||||
{
|
||||
"name": "ipc",
|
||||
|
Loading…
Reference in New Issue
Block a user