Skip to content

Commit

Permalink
Merge branch 'main' into mboulais/O2B-1412/retry-on-kafka-failure
Browse files Browse the repository at this point in the history
  • Loading branch information
martinboulais authored Dec 12, 2024
2 parents 3e8ad22 + 6d2c9c9 commit 1f7d67f
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 101 deletions.
2 changes: 1 addition & 1 deletion lib/config/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const {
} = process.env ?? {};

exports.services = {
enableHousekeeping: process.env?.ENABLE_HOUSEKEEPING ?? false,
enableHousekeeping: process.env?.ENABLE_HOUSEKEEPING?.toLowerCase() === 'true',
aliEcsGui: {
url: process.env?.ALI_ECS_GUI_URL || null,
token: process.env?.ALI_ECS_GUI_TOKEN || null,
Expand Down
25 changes: 5 additions & 20 deletions lib/database/repositories/QcFlagRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,32 +203,17 @@ class QcFlagRepository extends Repository {
GROUP_CONCAT(effectivePeriods.flagsList) AS flagsList,
IF(
(
COALESCE(run.time_trg_end, run.time_o2_end ) IS NULL
OR COALESCE(run.time_trg_start, run.time_o2_start) IS NULL
),
run.time_start IS NULL OR run.time_end IS NULL,
IF(
SUM(
COALESCE(effectivePeriods.\`to\` , 0)
+ COALESCE(effectivePeriods.\`from\`, 0)
) = 0,
effectivePeriods.\`from\` IS NULL AND effectivePeriods.\`to\` IS NULL,
1,
null
),
SUM(
COALESCE(
effectivePeriods.\`to\`,
UNIX_TIMESTAMP(run.time_trg_end),
UNIX_TIMESTAMP(run.time_o2_end)
)
- COALESCE(
effectivePeriods.\`from\`,
UNIX_TIMESTAMP(run.time_trg_start),
UNIX_TIMESTAMP(run.time_o2_start)
)
COALESCE(effectivePeriods.\`to\`, UNIX_TIMESTAMP(run.time_end))
- COALESCE(effectivePeriods.\`from\`, UNIX_TIMESTAMP(run.time_start))
) / (
UNIX_TIMESTAMP(COALESCE(run.time_trg_end, run.time_o2_end))
- UNIX_TIMESTAMP(COALESCE(run.time_trg_start, run.time_o2_start))
UNIX_TIMESTAMP(run.time_end) - UNIX_TIMESTAMP(run.time_start)
)
) AS effectiveRunCoverage
Expand Down
7 changes: 1 addition & 6 deletions lib/public/components/Pagination/amountSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ const perPageAmountInputComponent = (onCustomChoiceConfirm, paginationModel) =>
oninput: ({ target }) => {
paginationModel.customItemsPerPage = target.value;
},
onkeyup: ({ key }) => {
if (key === 'Enter') {
onCustomChoiceConfirm();
}
},
onblur: onCustomChoiceConfirm,
onchange: onCustomChoiceConfirm,
});

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/public/views/Runs/ActiveColumns/runsActiveColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,6 @@ export const runsActiveColumns = {
name: 'L3 / Dipole',
visible: false,
filter: ({ aliceL3AndDipoleCurrentFilter }) => selectionDropdown(aliceL3AndDipoleCurrentFilter, { selectorPrefix: 'l3-dipole-current' }),
profiles: ['runsPerLhcPeriod', 'runsPerDataPass', 'runsPerSimulationPass'],
profiles: ['runsPerLhcPeriod', 'runsPerDataPass', 'runsPerSimulationPass', profiles.none],
},
};
27 changes: 6 additions & 21 deletions lib/server/services/qualityControlFlag/QcFlagService.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,35 +264,20 @@ class QcFlagService {
[
sequelize.literal(`
IF(
(
COALESCE(run.time_trg_end, run.time_o2_end ) IS NULL
OR COALESCE(run.time_trg_start, run.time_o2_start) IS NULL
),
run.time_start IS NULL OR run.time_end IS NULL,
IF(
SUM(
COALESCE(UNIX_TIMESTAMP(effectivePeriods.\`to\` ), 0)
+ COALESCE(UNIX_TIMESTAMP(effectivePeriods.\`from\`), 0)
) = 0,
effectivePeriods.\`from\` IS NULL AND effectivePeriods.\`to\` IS NULL,
1,
null
),
SUM(
UNIX_TIMESTAMP(COALESCE(
effectivePeriods.\`to\`,
run.time_trg_end,
run.time_o2_end
))
- UNIX_TIMESTAMP(COALESCE(
effectivePeriods.\`from\`,
run.time_trg_start,
run.time_o2_start
))
UNIX_TIMESTAMP(COALESCE(effectivePeriods.\`to\`, run.time_end))
- UNIX_TIMESTAMP(COALESCE(effectivePeriods.\`from\`, run.time_start))
) / (
UNIX_TIMESTAMP(COALESCE(run.time_trg_end, run.time_o2_end))
- UNIX_TIMESTAMP(COALESCE(run.time_trg_start, run.time_o2_start))
UNIX_TIMESTAMP(run.time_end) - UNIX_TIMESTAMP(run.time_start)
)
)
`),
`),
'effectiveRunCoverage',
],
[
Expand Down
6 changes: 3 additions & 3 deletions lib/server/services/run/setO2StopOfLostRuns.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ exports.setO2StopOfLostRuns = async (runNumbersOfRunningRuns, modificationTimePe
FROM runs
WHERE time_o2_end IS NULL
AND time_trg_end IS NULL
AND COALESCE(time_trg_start, time_o2_start) IS NOT NULL
AND COALESCE(time_trg_start, time_o2_start) >= '${timestampToMysql(modificationTimePeriod.from, true)}'
AND COALESCE(time_trg_start, time_o2_start) < '${timestampToMysql(modificationTimePeriod.to, true)}'
AND time_start IS NOT NULL
AND time_start >= '${timestampToMysql(modificationTimePeriod.from, true)}'
AND time_start < '${timestampToMysql(modificationTimePeriod.to, true)}'
`;
if (runNumbersOfRunningRuns.length > 0) {
fetchQuery += ` AND run_number NOT IN (${runNumbersOfRunningRuns.join(',')})`;
Expand Down
71 changes: 51 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions test/public/flps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
*/

const OverviewSuite = require('./overview.test');
// eslint-disable-next-line capitalized-comments
const DetailSuite = require('./detail.test');

module.exports = () => {
describe('Overview Page', OverviewSuite);
// eslint-disable-next-line capitalized-comments
describe('Detail Page', DetailSuite);
};
39 changes: 14 additions & 25 deletions test/public/flps/overview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
waitForTableLength,
goToPage,
getInnerText,
fillInput,
} = require('../defaults.js');
const { resetDatabaseContent } = require('../../utilities/resetDatabaseContent.js');

Expand All @@ -33,6 +34,9 @@ module.exports = () => {
let table;
let firstRowId;

const amountSelectorSelector = '#amountSelector';
const amountSelectorButtonSelector = `${amountSelectorSelector} button`;

before(async () => {
[page, browser] = await defaultBefore(page, browser);
await page.setViewport({
Expand Down Expand Up @@ -108,8 +112,6 @@ module.exports = () => {
await page.waitForSelector('table tbody tr:nth-child(2)');
expect(await page.$(`table tbody tr:nth-child(${INFINITE_SCROLL_CHUNK})`)).to.be.null;

const amountSelectorButtonSelector = '#amountSelector button';

// Expect the dropdown options to be visible when it is selected
await pressElement(page, amountSelectorButtonSelector);

Expand All @@ -133,23 +135,19 @@ module.exports = () => {

it('can set how many flps are available per page', async () => {
// Expect the amount selector to currently be set to Infinite (after the previous test)
const amountSelectorId = '#amountSelector';
await expectInnerText(page, `${amountSelectorId} button`, 'Rows per page: Infinite ');
await expectInnerText(page, `${amountSelectorSelector} button`, 'Rows per page: Infinite ');

await pressElement(page, `${amountSelectorId} button`);
await page.waitForSelector(`${amountSelectorId} .dropup-menu`);
await pressElement(page, `${amountSelectorSelector} button`);
await page.waitForSelector(`${amountSelectorSelector} .dropup-menu`);

// Expect the amount of visible flps to reduce when the first option (5) is selected
await pressElement(page, `${amountSelectorId} .dropup-menu .menu-item`);
await pressElement(page, `${amountSelectorSelector} .dropup-menu .menu-item`);
await waitForTableLength(page, 5);
});

it('dynamically switches between visible pages in the page selector', async () => {
// Override the amount of flps visible per page manually
await page.evaluate(() => {
// eslint-disable-next-line no-undef
model.flps.pagination.itemsPerPage = 1;
});
await pressElement(page, amountSelectorButtonSelector);
await fillInput(page, `${amountSelectorSelector} input`, '1', ['input', 'change']);
await waitForTableLength(page, 1);

// Expect the page five button to now be visible, but no more than that
Expand All @@ -164,22 +162,13 @@ module.exports = () => {
});

it('notifies if table loading returned an error', async () => {
/*
* As an example, override the amount of flps visible per page manually
* We know the limit is 100 as specified by the Dto
*/
await page.evaluate(() => {
// eslint-disable-next-line no-undef
model.flps.pagination.itemsPerPage = 200;
});
await pressElement(page, amountSelectorButtonSelector);
await fillInput(page, `${amountSelectorSelector} input`, '200', ['input', 'change']);

// We expect there to be a fitting error message
await expectInnerText(page, '.alert-danger', 'Invalid Attribute: "query.page.limit" must be less than or equal to 100');

// Revert changes for next test
await page.evaluate(() => {
// eslint-disable-next-line no-undef
model.flps.pagination.itemsPerPage = 10;
});
await pressElement(page, amountSelectorButtonSelector);
await fillInput(page, `${amountSelectorSelector} input`, '10', ['input', 'change']);
});
};
15 changes: 13 additions & 2 deletions test/public/runs/overview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ module.exports = () => {
it('should successfully filter on tags', async () => {
await waitForTableLength(page, 8);

// Open filter toggle
// Open filter toggle and wait for the dropdown to be visible
await pressElement(page, '.tags-filter .dropdown-trigger');
await pressElement(page, '#tag-dropdown-option-FOOD', true);
await pressElement(page, '#tag-dropdown-option-RUN', true);
Expand Down Expand Up @@ -596,6 +596,17 @@ module.exports = () => {
expect(runDurationList.every((runDuration) => runDuration === 'UNKNOWN')).to.be.true;
});

it('should successfully apply alice currents filters', async () => {
await pressElement(page, '#reset-filters');

const popoverSelector = await getPopoverSelector(await page.waitForSelector('.aliceL3AndDipoleCurrent-filter .popover-trigger'));
await pressElement(page, `${popoverSelector} .dropdown-option:last-child`, true); // Select 30003kA/0kA

await expectColumnValues(page, 'runNumber', ['54', '53', '52']);

await pressElement(page, '#reset-filters');
});

it('Should successfully filter runs by their run quality', async () => {
await goToPage(page, 'run-overview');
const filterInputSelectorPrefix = '#runQualityCheckbox';
Expand Down Expand Up @@ -1116,7 +1127,7 @@ module.exports = () => {
await waitForNavigation(page, () => pressElement(page, 'a#home'));
await waitForNavigation(page, () => pressElement(page, 'a#run-overview'));

// Not running run
// Not running run, wait for popover to be visible
await pressElement(page, '#row104-runNumber-text .popover-trigger');
let popoverSelector = await getPopoverSelector(await page.waitForSelector('#row104-runNumber-text .popover-trigger'));
await page.waitForSelector(popoverSelector);
Expand Down

0 comments on commit 1f7d67f

Please sign in to comment.