From 6d7dec20c9a36bb0035f8f0da8c6b66709008d18 Mon Sep 17 00:00:00 2001 From: Martin Boulais <31805063+martinboulais@users.noreply.github.com> Date: Thu, 23 Jan 2025 14:03:21 +0100 Subject: [PATCH] [O2B-1420] Add CTP readout host to FLP hosts (#1838) * [O2B-1420] Add CTP readout host to FLP hosts * Fix tests * Add explanation about the logic --- .../seeders/20220412122043-environments.js | 2 ++ lib/server/services/run/RunService.js | 18 ++++++++++++++++-- .../lib/server/services/run/RunService.test.js | 1 + test/public/envs/detailsPage.test.js | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/database/seeders/20220412122043-environments.js b/lib/database/seeders/20220412122043-environments.js index 2faf4f6e1e..11e943e623 100644 --- a/lib/database/seeders/20220412122043-environments.js +++ b/lib/database/seeders/20220412122043-environments.js @@ -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 diff --git a/lib/server/services/run/RunService.js b/lib/server/services/run/RunService.js index d39d69e36a..681fbf3439 100644 --- a/lib/server/services/run/RunService.js +++ b/lib/server/services/run/RunService.js @@ -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 }); }); } @@ -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); } @@ -493,6 +506,7 @@ class RunService { } catch (e) { onError(e); } + let triggerEnabled = false; try { triggerEnabled = configuration.getBool('trg_enabled'); @@ -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 { diff --git a/test/lib/server/services/run/RunService.test.js b/test/lib/server/services/run/RunService.test.js index 6f661f8bb5..59ed33c343 100644 --- a/test/lib/server/services/run/RunService.test.js +++ b/test/lib/server/services/run/RunService.test.js @@ -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']); }); }; diff --git a/test/public/envs/detailsPage.test.js b/test/public/envs/detailsPage.test.js index 1734c8cff6..cb0919a73e 100644 --- a/test/public/envs/detailsPage.test.js +++ b/test/public/envs/detailsPage.test.js @@ -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);