Skip to content

Commit c4d2a55

Browse files
alxhubpkozlowski-opensource
authored andcommitted
test: increase size tracking threshold to 5K / 5% (angular#49520)
This commit increases the threshold of payload size tracking tests from 500 bytes to 5,000 bytes, and from 1% to 5%. This is done to minimize merge conflicts while still catching real regressions. PR Close angular#49520
1 parent 504bd99 commit c4d2a55

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

scripts/ci/payload-size.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const path = require('path');
1515
// Get limit file, project name and commit SHA from command line arguments.
1616
const [, , limitFile, project, commit] = process.argv;
1717

18+
const THRESHOLD_BYTES = 5000;
19+
const THRESHOLD_PERCENT = 5;
20+
1821
// Load sizes.
1922
const currentSizes = JSON.parse(fs.readFileSync('/tmp/current.log', 'utf8'));
2023
const allLimitSizes = JSON.parse(fs.readFileSync(limitFile, 'utf8'));
@@ -41,8 +44,9 @@ for (const compressionType in limitSizes) {
4144
'Maybe the file was renamed or removed.');
4245
} else {
4346
const absoluteSizeDiff = Math.abs(actualSize - expectedSize);
44-
// If size diff is larger than 1% or 500 bytes...
45-
if (absoluteSizeDiff > 500 || absoluteSizeDiff > expectedSize / 100) {
47+
// If size diff is larger than THRESHOLD_BYTES or THRESHOLD_PERCENT...
48+
if (absoluteSizeDiff > THRESHOLD_BYTES ||
49+
absoluteSizeDiff > (expectedSize * THRESHOLD_PERCENT / 100)) {
4650
failed = true;
4751
// We must also catch when the size is significantly lower than the payload limit, so
4852
// we are forced to update the expected payload number when the payload size reduces.
@@ -51,13 +55,14 @@ for (const compressionType in limitSizes) {
5155
const operator = actualSize > expectedSize ? 'exceeded' : 'fell below';
5256

5357
failureMessages.push(
54-
`FAIL: Commit ${commit} ${compressionType} ${filename} ${
55-
operator} expected size by 500 bytes or >1% ` +
58+
`FAIL: Commit ${commit} ${compressionType} ${filename} ${operator} expected size by ${
59+
THRESHOLD_BYTES} bytes or >${THRESHOLD_PERCENT}% ` +
5660
`(expected: ${expectedSize}, actual: ${actualSize}).`);
5761
} else {
5862
successMessages.push(
5963
`SUCCESS: Commit ${commit} ${compressionType} ${
60-
filename} did NOT cross size threshold of 500 bytes or >1% ` +
64+
filename} did NOT cross size threshold of ${THRESHOLD_BYTES} bytes or >${
65+
THRESHOLD_PERCENT} ` +
6166
`(expected: ${expectedSize}, actual: ${actualSize}).`);
6267
}
6368
}
@@ -75,5 +80,6 @@ if (failed) {
7580
`If this is a desired change, please update the size limits in file '${limitFileRelPath}'.`);
7681
process.exit(1);
7782
} else {
78-
console.info(`Payload size check passed. All diffs are less than 1% or 500 bytes.`);
83+
console.info(`Payload size check passed. All diffs are less than ${THRESHOLD_PERCENT}% or ${
84+
THRESHOLD_BYTES} bytes.`);
7985
}

0 commit comments

Comments
 (0)