Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions smoke-test/tests/cypress/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

// eslint-disable-next-line global-require
require("./memoryUsageLogger")(on);

// eslint-disable-next-line global-require
require("cypress-timestamps/plugin")(on);
};
36 changes: 36 additions & 0 deletions smoke-test/tests/cypress/cypress/plugins/memoryUsageLogger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// Add a task to log memory usage to the terminal
on("task", {
logMemoryUsage(browserMemoryUsage) {
const formatBytes = (bytes) =>
(bytes / 1024 / 1024 / 1024).toFixed(3) + " GB";

if (browserMemoryUsage) {
console.log("=== Browser Tab Memory Usage ===");
console.log(`Used: ${formatBytes(browserMemoryUsage.usedJSHeapSize)}`);
console.log(
`Total: ${formatBytes(browserMemoryUsage.totalJSHeapSize)}`,
);
console.log(
`Limit: ${formatBytes(browserMemoryUsage.jsHeapSizeLimit)}`,
);
}

const cypressMemoryUsage = process.memoryUsage();
console.log("=== Cypress Memory Usage ===");
console.log(`rss: ${formatBytes(cypressMemoryUsage.rss)}`);
console.log(`heapTotal: ${formatBytes(cypressMemoryUsage.heapTotal)}`);
console.log(`heapUsed: ${formatBytes(cypressMemoryUsage.heapUsed)}`);
console.log(`external: ${formatBytes(cypressMemoryUsage.external)}`);
console.log(
`arrayBuffers: ${formatBytes(cypressMemoryUsage.arrayBuffers)}`,
);

return null;
},
});
};
12 changes: 12 additions & 0 deletions smoke-test/tests/cypress/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ beforeEach(function () {
}
}
});

afterEach(() => {
cy.window().then((win) => {
const browserMemoryUsage = {
usedJSHeapSize: win.performance?.memory?.usedJSHeapSize,
totalJSHeapSize: win.performance?.memory?.totalJSHeapSize,
jsHeapSizeLimit: win.performance?.memory?.jsHeapSizeLimit,
};

cy.task("logMemoryUsage", browserMemoryUsage);
});
});
5 changes: 3 additions & 2 deletions smoke-test/tests/cypress/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ def test_run_cypress(auth_session):
test_spec_arg = f" --spec '{specs_str}' "

print("Running Cypress tests with command")
node_options = "--max-old-space-size=6000"
command = f'NO_COLOR=1 NODE_OPTIONS="{node_options}" npx cypress run {record_arg} {test_spec_arg} {tag_arg} --config numTestsKeptInMemory=2'
node_options = "--max-old-space-size=500"
electron_args = 'ELECTRON_EXTRA_LAUNCH_ARGS="--js-flags=\'--max-old-space-size=4096 --disable-dev-shm-usage --disable-gpu --no-sandbox"'
command = f'{electron_args} NO_COLOR=1 NODE_OPTIONS="{node_options}" npx cypress run {record_arg} {test_spec_arg} {tag_arg} --config numTestsKeptInMemory=2'
print(command)
# Add --headed --spec '**/mutations/mutations.js' (change spec name)
# in case you want to see the browser for debugging
Expand Down
Loading