Skip to content

Commit 3fe23e8

Browse files
committed
Add EOR reason in case of LHC user stopping run
1 parent a879bdc commit 3fe23e8

2 files changed

Lines changed: 40 additions & 6 deletions

File tree

lib/server/kafka/AliEcsSynchronizer.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,24 @@ class AliEcsSynchronizer {
8585
}
8686

8787
if (transition === 'STOP_ACTIVITY' || transition === 'GO_ERROR') {
88+
const eorReasons = [];
89+
if (userName === 'LHC') {
90+
this._logger.infoMessage(`Run ${runNumber} stopped by LHC user, adding adequate EOR reason`);
91+
eorReasons.push({
92+
category: 'LHC',
93+
title: 'Dump',
94+
description: 'Run stopped due to LHC dump',
95+
});
96+
}
8897
runService
8998
.createOrUpdate(
9099
runNumber,
91100
environmentId,
92101
{ timeO2End: timestamp.toNumber() },
93-
{ userO2Stop: { userIdentifier: { externalUserId }, name: userName } },
102+
{
103+
userO2Stop: { userIdentifier: { externalUserId }, name: userName },
104+
eorReasons,
105+
},
94106
)
95107
.catch((error) => this._logger.errorMessage(`Failed to save run end for ${runNumber}: ${error.message}`));
96108
}

test/lib/server/services/run/RunService.test.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ module.exports = () => {
359359

360360
const run = await runService.update(
361361
{ runNumber },
362-
{ relations: { eorReasons: eorReasons } },
362+
{ relations: { eorReasons } },
363363
);
364364

365365
expect(run.eorReasons).to.lengthOf(2);
@@ -391,7 +391,7 @@ module.exports = () => {
391391

392392
const run = await runService.update(
393393
{ runNumber },
394-
{ relations: { eorReasons: eorReasons } },
394+
{ relations: { eorReasons } },
395395
);
396396

397397
expect(run.eorReasons).to.lengthOf(2);
@@ -431,7 +431,7 @@ module.exports = () => {
431431

432432
const run = await runService.update(
433433
{ runNumber },
434-
{ relations: { eorReasons: eorReasons } },
434+
{ relations: { eorReasons } },
435435
);
436436

437437
// Should only include the valid ones without throwing for invalid one (is simply excluded)
@@ -453,7 +453,7 @@ module.exports = () => {
453453

454454
const run = await runService.update(
455455
{ runNumber },
456-
{ relations: { eorReasons: eorReasons } },
456+
{ relations: { eorReasons } },
457457
);
458458

459459
expect(run.eorReasons).to.lengthOf(0);
@@ -485,7 +485,7 @@ module.exports = () => {
485485

486486
const run = await runService.update(
487487
{ runNumber },
488-
{ relations: { eorReasons: eorReasons } },
488+
{ relations: { eorReasons } },
489489
);
490490

491491
// EorReasons should only include the one that does not have an id
@@ -733,4 +733,26 @@ module.exports = () => {
733733
expect(run.userIdO2Stop).to.equal(2);
734734
expect(run.flpRoles.map(({ name }) => name)).to.deep.equal(['fake-flp1', 'fake-flp2', 'fake-ctp-host']);
735735
});
736+
737+
it('should successfully update a run with provided EOR reasons via the createOrUpdate', async () => {
738+
const run = await runService.createOrUpdate(
739+
1234,
740+
'CmCvjNbg',
741+
{ },
742+
{
743+
eorReasons: [
744+
{
745+
category: 'DETECTORS',
746+
title: 'TPC',
747+
description: 'Run stopped due to LHC dump',
748+
},
749+
],
750+
},
751+
);
752+
// console.log(run);
753+
expect(run.eorReasons).to.have.lengthOf(1);
754+
expect(run.eorReasons[0].category).to.equal('DETECTORS');
755+
expect(run.eorReasons[0].title).to.equal('TPC');
756+
expect(run.eorReasons[0].description).to.equal('Run stopped due to LHC dump');
757+
});
736758
};

0 commit comments

Comments
 (0)