Skip to content
Open
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
46 changes: 0 additions & 46 deletions end-to-end-test/local/specs/performance.spec.js

This file was deleted.

37 changes: 37 additions & 0 deletions end-to-end-test/local/specs/performance/performance.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const assert = require('chai').assert;
const postEndpointMaxResponseTime = require('../../../shared/specUtils')
.postEndpointMaxResponseTime;
const goToUrlAndSetLocalStorage = require('../../../shared/specUtils')
.goToUrlAndSetLocalStorage;
const waitForNetworkQuiet = require('../../../shared/specUtils')
.waitForNetworkQuiet;
const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

describe('Endpoints performance tests', () => {
it.skip('Mutated-genes endpoint should return in 2s', () => {
goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true);
// endpoint url
const URL = CBIOPORTAL_URL + '/api/mutated-genes/fetch';
// run 5 times
const RUN_TIMES = 5;
// default max response time: 1s
const MAX_TIME = 2000;
// study: Test study es_0
const REQUEST_BODY = require('./performance_test_request_body.json');
assert.isAtMost(
postEndpointMaxResponseTime(URL, REQUEST_BODY, RUN_TIMES),
MAX_TIME,
'all mutated-gene queries should be less than 2s'
);
});
});

describe('Page loading time test', () => {
it('Study view page should load in 20s', () => {
goToUrlAndSetLocalStorage(
`${CBIOPORTAL_URL}/study/summary?id=study_es_0`,
true
);
waitForNetworkQuiet(200000);
});
});

Large diffs are not rendered by default.

52 changes: 45 additions & 7 deletions end-to-end-test/shared/specUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const clipboardy = require('clipboardy');
const { performance } = require('perf_hooks');

function waitForStudyQueryPage(timeout) {
$('div[data-test="cancerTypeListContainer"]').waitForExist(
Expand Down Expand Up @@ -188,13 +189,18 @@ const useExternalFrontend = !process.env
const useLocalDist = process.env.FRONTEND_TEST_USE_LOCAL_DIST;

function waitForNetworkQuiet(timeout) {
browser.waitUntil(() => {
return (
browser.execute(function() {
return window.ajaxQuiet === true;
}).value == true
);
}, timeout);
browser.waitUntil(
() => {
return (
browser.execute(function() {
return window.ajaxQuiet === true;
}) == true
);
},
{
timeout,
}
);
}

function getPortalUrlFromEnv() {
Expand Down Expand Up @@ -493,6 +499,37 @@ function selectElementByText(text) {
return $(`//*[text()="${text}"]`);
}

function postEndpointMaxResponseTime(url, requestBody, runTimes) {
let maxResponseTime = 0;
while (runTimes--) {
const startTime = performance.now();
const result = browser.executeAsync(
function(url, requestBody, done) {
// browser context - you may not access client or console
return fetch(url, {
method: 'POST',
mode: 'cors',
headers: {
accept: 'application/json',
'content-type': 'application/json',
},
referrerPolicy: 'origin-when-cross-origin',
body: JSON.stringify(requestBody),
})
.then(response => response.json())
.then(data => done(data));
},
url,
requestBody
);
maxResponseTime = Math.max(
performance.now() - startTime,
maxResponseTime
);
}
return maxResponseTime;
}

module.exports = {
checkElementWithElementHidden: checkElementWithElementHidden,
waitForPlotsTab: waitForPlotsTab,
Expand Down Expand Up @@ -539,4 +576,5 @@ module.exports = {
getPortalUrlFromEnv: getPortalUrlFromEnv,
openGroupComparison: openGroupComparison,
selectElementByText: selectElementByText,
postEndpointMaxResponseTime: postEndpointMaxResponseTime,
};