Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix E2E chunking #16653

Merged
merged 2 commits into from
Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ const getTestPathsForTestDir = async (testDir) => {
return testPaths;
};

function chunk(array, chunkSize) {
// Heavily inspired by: https://stackoverflow.com/a/51514813
// Splits the array into totalChunks chunks with a decent spread of items in each chunk
function chunk(array, totalChunks) {
const copyArray = [...array];
const result = [];
for (let i = 0; i < array.length; i += chunkSize) {
result.push(array.slice(i, i + chunkSize));
for (let chunkIndex = totalChunks; chunkIndex > 0; chunkIndex--) {
result.push(copyArray.splice(0, Math.ceil(copyArray.length / chunkIndex)));
}
return result;
}
Expand Down Expand Up @@ -77,8 +80,7 @@ async function main() {
// For running E2Es in parallel in CI
const currentChunkIndex = process.env.CIRCLE_NODE_INDEX ?? 0;
const totalChunks = process.env.CIRCLE_NODE_TOTAL ?? 1;
const chunkSize = Math.ceil(testPaths.length / totalChunks);
const chunks = chunk(testPaths, chunkSize);
const chunks = chunk(testPaths, totalChunks);
const currentChunk = chunks[currentChunkIndex];

for (const testPath of currentChunk) {
Expand Down