From 2133550edab6fdf1ebc8e87a4c5fd095f196114c Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 14 Feb 2021 15:32:08 +0100 Subject: [PATCH 1/3] [test] Avoid Rate Limit Exceeded --- test/karma.conf.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/karma.conf.js b/test/karma.conf.js index 489c1388bcc05..a2fe9086dadcc 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -9,6 +9,13 @@ const browserStack = { process.env.CHROME_BIN = require('puppeteer').executablePath(); +// BrowserStack rate limit after 1600 calls every 5 minutes. +// Per second, https://www.browserstack.com/docs/automate/api-reference/selenium/introduction#rest-api-projects +const MAX_REQUEST_BROWSERSTACK = 1600 / (60 * 5); +// Estimate the max number of concurrent karma builds. +// CircleCI accepts up to 80 concurrent builds, for each PR, 6 concurrent builds are used. +const MAX_KARMA_CONCURRENT_BUILD = 80 / 6; + // Karma configuration module.exports = function setKarmaConfig(config) { const baseConfig = { @@ -153,6 +160,11 @@ module.exports = function setKarmaConfig(config) { }, }, }; + + // default 1000, Avoid Rate Limit Exceeded + newConfig.pollingTimeout = + ((MAX_KARMA_CONCURRENT_BUILD * (newConfig.browsers.length - 1)) / MAX_REQUEST_BROWSERSTACK) * + 1000; } config.set(newConfig); From 41595a57e1ad3aee480ad7e15ab9c796b536285a Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 16 Feb 2021 20:05:19 +0100 Subject: [PATCH 2/3] Sebastian's review --- test/karma.conf.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/karma.conf.js b/test/karma.conf.js index a2fe9086dadcc..0022b02b9a89f 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -11,10 +11,12 @@ process.env.CHROME_BIN = require('puppeteer').executablePath(); // BrowserStack rate limit after 1600 calls every 5 minutes. // Per second, https://www.browserstack.com/docs/automate/api-reference/selenium/introduction#rest-api-projects -const MAX_REQUEST_BROWSERSTACK = 1600 / (60 * 5); -// Estimate the max number of concurrent karma builds. -// CircleCI accepts up to 80 concurrent builds, for each PR, 6 concurrent builds are used. -const MAX_KARMA_CONCURRENT_BUILD = 80 / 6; +const MAX_REQUEST_PER_SECOND_BROWSERSTACK = 1600 / (60 * 5); +// Estimate the max number of concurrent karma builds +// For each PR, 3 concurrent builds are used, only one is usng BrowserStack. +const AVERAGE_KARMA_BUILD = 1 / 3; +// CircleCI accepts up to 83 concurrent builds. +const MAX_CIRCLE_CI_CONCURRENCY = 83; // Karma configuration module.exports = function setKarmaConfig(config) { @@ -161,9 +163,13 @@ module.exports = function setKarmaConfig(config) { }, }; + // -1 because chrome headless runs in the local machine + const browserstackBrowsersUsed = newConfig.browsers.length - 1; + // default 1000, Avoid Rate Limit Exceeded newConfig.pollingTimeout = - ((MAX_KARMA_CONCURRENT_BUILD * (newConfig.browsers.length - 1)) / MAX_REQUEST_BROWSERSTACK) * + ((MAX_CIRCLE_CI_CONCURRENCY * AVERAGE_KARMA_BUILD * browserstackBrowsersUsed) / + MAX_REQUEST_PER_SECOND_BROWSERSTACK) * 1000; } From a7fcad61addb0d815b178132d5e010c5b7883956 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 16 Feb 2021 20:07:24 +0100 Subject: [PATCH 3/3] Update test/karma.conf.js --- test/karma.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/karma.conf.js b/test/karma.conf.js index 0022b02b9a89f..8609d34e078f6 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -13,8 +13,8 @@ process.env.CHROME_BIN = require('puppeteer').executablePath(); // Per second, https://www.browserstack.com/docs/automate/api-reference/selenium/introduction#rest-api-projects const MAX_REQUEST_PER_SECOND_BROWSERSTACK = 1600 / (60 * 5); // Estimate the max number of concurrent karma builds -// For each PR, 3 concurrent builds are used, only one is usng BrowserStack. -const AVERAGE_KARMA_BUILD = 1 / 3; +// For each PR, 4 concurrent builds are used, only one is using BrowserStack. +const AVERAGE_KARMA_BUILD = 1 / 4; // CircleCI accepts up to 83 concurrent builds. const MAX_CIRCLE_CI_CONCURRENCY = 83;