Skip to content

Commit

Permalink
[O2B-1420] Add CTP readout host to FLP hosts (#1838)
Browse files Browse the repository at this point in the history
* [O2B-1420] Add CTP readout host to FLP hosts

* Fix tests

* Add explanation about the logic
  • Loading branch information
martinboulais authored Jan 23, 2025
1 parent 0028a29 commit 6d7dec2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/database/seeders/20220412122043-environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module.exports = {
odc_topology: 'topology',
odc_n_epns: '2',
readout_cfg_uri: 'file:///local/replay/2024-04-17-pp-650khz-synt-4tf/readout-replay-24g-dd40.cfg',
ctp_readout_enabled: true,
ctp_readout_host: 'fake-ctp-host',
}),
},
// Destroyed
Expand Down
18 changes: 16 additions & 2 deletions lib/server/services/run/RunService.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class RunService {
}
}

return this.get({ runId }, { runType: true, detectors: true, lhcPeriod: true });
return this.get({ runId }, { runType: true, detectors: true, lhcPeriod: true, flpRoles });
});
}

Expand Down Expand Up @@ -480,6 +480,19 @@ class RunService {
let hosts = [];
try {
hosts = configuration.getArray('hosts');

/*
* If the run has CTP readout enabled, we need to add the CTP host in the list of hosts
* The reason is that hosts is defined manually using AliECS GUI to have fine grained control over enabled FLPs, but CTP readout is
* a boolean which runs automatically on a dedicated host
*/
const ctp_readout_enabled = configuration.getBool('ctp_readout_enabled');
if (ctp_readout_enabled) {
const ctp_readout_host = configuration.getString('ctp_readout_host');
if (ctp_readout_host) {
hosts.push(ctp_readout_host);
}
}
} catch (e) {
onError(e);
}
Expand All @@ -493,6 +506,7 @@ class RunService {
} catch (e) {
onError(e);
}

let triggerEnabled = false;
try {
triggerEnabled = configuration.getBool('trg_enabled');
Expand Down Expand Up @@ -533,7 +547,7 @@ class RunService {
partialRun.pdpBeamType = configuration.getString('pdp_beam_type');
partialRun.epnTopology = configuration.getString('odc_topology');
partialRun.nEpns = configuration.getString('odc_n_epns');
partialRun.nFlps = (hosts?.length ?? 0) + (ctp ? 1 : 0); // Add 1 for ctp flp which is not in hosts
partialRun.nFlps = hosts?.length ?? 0;
partialRun.readoutCfgUri = configuration.getString('readout_cfg_uri');

return {
Expand Down
1 change: 1 addition & 0 deletions test/lib/server/services/run/RunService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,5 +718,6 @@ module.exports = () => {
expect(run.readoutCfgUri).to.equal('file:///local/replay/2024-04-17-pp-650khz-synt-4tf/readout-replay-24g-dd40.cfg');
expect(run.userIdO2Start).to.equal(1);
expect(run.userIdO2Stop).to.equal(2);
expect(run.flpRoles.map(({ name }) => name)).to.deep.equal(['fake-flp1', 'fake-flp2', 'fake-ctp-host']);
});
};
2 changes: 1 addition & 1 deletion test/public/envs/detailsPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ module.exports = () => {
await waitForNavigation(page, () => pressElement(page, '#rowCmCvjNbg a:first-of-type'));
await pressElement(page, '#raw-configuration-tab');

await waitForTableLength(page, 18);
await waitForTableLength(page, 20);
expect(await page.evaluate(() => {
const cellContents = Array.from(document.querySelectorAll('table tbody tr td:first-child')).map((element) => element.innerText);
return cellContents.every((v, i) => !i || v.localeCompare(cellContents[i - 1]) >= 0);
Expand Down

0 comments on commit 6d7dec2

Please sign in to comment.