Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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.

25 changes: 25 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,25 @@
const assert = require('chai').assert;
const postEndpointMaxResponseTime = require('../../../shared/specUtils')
.postEndpointMaxResponseTime;
const goToUrlAndSetLocalStorage = require('../../../shared/specUtils')
.goToUrlAndSetLocalStorage;
const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

describe('Endpoints performance tests', () => {
it('Mutated-genes endpoint should return in 1s', () => {
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 = 1000;
// 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 1s'
);
});
});

Large diffs are not rendered by default.

33 changes: 33 additions & 0 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 @@ -493,6 +494,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 +571,5 @@ module.exports = {
getPortalUrlFromEnv: getPortalUrlFromEnv,
openGroupComparison: openGroupComparison,
selectElementByText: selectElementByText,
postEndpointMaxResponseTime: postEndpointMaxResponseTime,
};