ci: Stabilise the host before running perf tests (#15130)
* Run perf tests only on buildjet machine * - Set chrome process priority to maximum to stabilise the run data * Update index.js * Update perf.js * Update index.js * - Move around args * - Add --no-sandbox option to initial setup * -We don't need sudo on the main script, we can use sudo in node scripts to set process priority * - Some tweaks to the perf scripts. * - Remove no-sandbox option in puppeteer launch * - Remove sudo at unnecessary places * - Add code to force grabage collection in chrome * Update logins and some cleanup * Remove unsed import Co-authored-by: Satish Gandham <satish@appsmith.com>
This commit is contained in:
parent
71a82b4670
commit
e2db190ed2
|
|
@ -1492,7 +1492,6 @@ jobs:
|
|||
APPSMITH_DISABLE_TELEMETRY: true
|
||||
POSTGRES_PASSWORD: postgres
|
||||
NODE_TLS_REJECT_UNAUTHORIZED: "0"
|
||||
MACHINE: ${{matrix.machine}}
|
||||
run: ./start-test.sh
|
||||
|
||||
# Restore the previous built bundle if present. If not push the newly built into the cache
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ const createRunMeta = async () => {
|
|||
pull_request_id: prId || parsePullRequestId(process.env.GITHUB_REF),
|
||||
runner_name: process.env?.RUNNER_NAME,
|
||||
host_name: hostname,
|
||||
machine: process.env?.MACHINE || "",
|
||||
machine: process.env?.MACHINE || "buildjet-4vcpu-ubuntu-2004", // Hardcoded temporarily. Should be removed
|
||||
},
|
||||
]);
|
||||
if (data) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@ const {
|
|||
login,
|
||||
sortObjectKeys,
|
||||
} = require("./utils/utils");
|
||||
|
||||
const {
|
||||
cleanTheHost,
|
||||
setChromeProcessPriority,
|
||||
} = require("./utils/system-cleanup");
|
||||
|
||||
const selectors = {
|
||||
appMoreIcon: "span.t--options-icon",
|
||||
workspaceImportAppOption: '[data-cy*="t--workspace-import-app"]',
|
||||
|
|
@ -17,6 +23,7 @@ const selectors = {
|
|||
importButton: '[data-cy*="t--workspace-import-app-button"]',
|
||||
createNewApp: ".createnew",
|
||||
};
|
||||
|
||||
module.exports = class Perf {
|
||||
constructor(launchOptions = {}) {
|
||||
this.launchOptions = {
|
||||
|
|
@ -62,9 +69,12 @@ module.exports = class Perf {
|
|||
* Launches the browser and, gives you the page
|
||||
*/
|
||||
launch = async () => {
|
||||
await cleanTheHost();
|
||||
this.browser = await puppeteer.launch(this.launchOptions);
|
||||
const pages_ = await this.browser.pages();
|
||||
this.page = pages_[0];
|
||||
|
||||
await setChromeProcessPriority();
|
||||
await this._login();
|
||||
};
|
||||
|
||||
|
|
@ -75,13 +85,20 @@ module.exports = class Perf {
|
|||
|
||||
startTrace = async (action = "foo") => {
|
||||
if (this.currentTrace) {
|
||||
console.warn("Trace progress. You can run only one trace at a time");
|
||||
console.warn(
|
||||
"Trace already in progress. You can run only one trace at a time",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentTrace = action;
|
||||
await delay(3000, `before starting trace ${action}`);
|
||||
await this.page._client.send("HeapProfiler.enable");
|
||||
await this.page._client.send("HeapProfiler.collectGarbage");
|
||||
await delay(1000, `After clearing memory`);
|
||||
|
||||
const path = `${APP_ROOT}/traces/${action}-${getFormattedTime()}-chrome-profile.json`;
|
||||
|
||||
await this.page.tracing.start({
|
||||
path: path,
|
||||
screenshots: true,
|
||||
|
|
@ -109,7 +126,7 @@ module.exports = class Perf {
|
|||
await this.page.waitForNavigation();
|
||||
|
||||
const currentUrl = this.page.url();
|
||||
const pageId = currentURL
|
||||
const pageId = currentUrl
|
||||
.split("/")[5]
|
||||
?.split("-")
|
||||
.pop();
|
||||
|
|
|
|||
53
app/client/perf/src/utils/system-cleanup.js
Normal file
53
app/client/perf/src/utils/system-cleanup.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
const cp = require("child_process");
|
||||
|
||||
exports.cleanTheHost = async () => {
|
||||
await cp.exec("pidof chrome", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`Killing chrome processes: ${stdout}`);
|
||||
stdout.split(" ").forEach((PID) => {
|
||||
cp.exec(`sudo kill -9 ${PID}`, (error, stdout, stder) => {
|
||||
if (error) {
|
||||
console.log(`Kill error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`Kill stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
if (stdout) {
|
||||
console.log(`Kill stdout: ${stdout}`);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Clear OS caches
|
||||
await cp.exec("sync; echo 3 | sudo tee /proc/sys/vm/drop_caches");
|
||||
};
|
||||
|
||||
exports.setChromeProcessPriority = async () => {
|
||||
await cp.exec("pidof chrome", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: setting priority: ${stdout}`);
|
||||
|
||||
// Set priority of chrome processes to maximum
|
||||
stdout.split(" ").forEach((PID) => {
|
||||
cp.execSync(`sudo renice -20 ${PID}`);
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user