Skip to content

AB testing - Ensure test group sizes are rounded down to min resolution if needed#15274

Merged
Jakeii merged 4 commits intomainfrom
jlk/ab-test-round-test-group-size-down
Feb 3, 2026
Merged

AB testing - Ensure test group sizes are rounded down to min resolution if needed#15274
Jakeii merged 4 commits intomainfrom
jlk/ab-test-round-test-group-size-down

Conversation

@Jakeii
Copy link
Member

@Jakeii Jakeii commented Feb 2, 2026

What does this change?

Ensure that ab test groups sizes do not exceed the overall test size by rounding non-integer groups down.

Why?

If group sizes are rounded up (or used as is) it could cause the actual mvt usage to exceed that of the test e.g.

A 20% test / 3 groups = 6.66666...7

The minimum actual test resolution is 0.1% if rounded up to 6.7% the actual MVT usage would be 20.1% which could cause issues when calculating if there's enough space for a test.

The lack of rounding also caused an issue on test resize as it tries to update an array to a decimal length, which this also fixes.

I've added a test case for this.

@Jakeii Jakeii added fix Departmental tracking: fix ab-testing labels Feb 2, 2026
getTestGroupName(group),
group.audienceSize * MVT_COUNT,
);
} else if (currentTestGroup.length !== group.audienceSize * MVT_COUNT) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was also missing, it was calling the resizeTestGroup even if a resize wasn't needed, no issue with this other than unnecessary logging.

if (!currentTest) {
console.log(`Adding new test group: ${test.name}:${test.group}`);
updateTestGroups.forEach((group) => {
const currentTestGroup = testGroupMVTs.getTestGroup(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed these vars, they refer to the test group not the test.

@Jakeii Jakeii marked this pull request as ready for review February 2, 2026 15:31
@Jakeii Jakeii requested a review from a team as a code owner February 2, 2026 15:31
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

@Jakeii Jakeii added the run_chromatic Runs chromatic when label is applied label Feb 2, 2026
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Feb 2, 2026
@Jakeii Jakeii added the run_chromatic Runs chromatic when label is applied label Feb 2, 2026
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Feb 2, 2026
@Jakeii Jakeii merged commit cccb9f8 into main Feb 3, 2026
31 checks passed
@Jakeii Jakeii deleted the jlk/ab-test-round-test-group-size-down branch February 3, 2026 09:30
@gu-prout
Copy link

gu-prout bot commented Feb 3, 2026

Seen on PROD (merged by @Jakeii 7 minutes and 34 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ab-testing fix Departmental tracking: fix Seen-on-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants