Skip to content

Commit

Permalink
feat: checking that there is data in the body
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia committed Jun 17, 2021
1 parent 81f7cb2 commit 5a4ceb3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 6 additions & 2 deletions app/tests/perf/executeQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ module.exports = (role) => {
}
};
const res = http.post(url, payload, params);
check(res, {
'no graphql error returned': (res) => !JSON.parse(res.body).errors
const parsedBody = JSON.parse(res.body);

check(parsedBody, {
'no graphql error returned': (parsedBody) => !parsedBody.errors,
'there is data in the response': (parsedBody) =>
parsedBody.data !== undefined
});
}
};
12 changes: 8 additions & 4 deletions app/tests/perf/test-guest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ const schemaCode = fs.readFileSync(
'utf8'
);

const args = {};
const queriesWithParams = {
pagesQuery: {},
loginRedirectQuery: {}
};

const easyGraphQLLoadTester = new LoadTesting(schemaCode, args);
const easyGraphQLLoadTester = new LoadTesting(schemaCode, queriesWithParams);

easyGraphQLLoadTester.k6('k6-guest.js', {
customQueries: queries,
onlyCustomQueries: true,
selectedQueries: ['pagesQuery'],
selectedQueries: Object.keys(queriesWithParams),
vus: 1,
iterations: 1,
queryFile: true
queryFile: true,
out: ['json=guest_result.json']
});
7 changes: 4 additions & 3 deletions app/tests/perf/test-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const queriesWithParams = {
lastSwrsReportingYear: null,
facilityBcghgid: null
},
reporterQuery: {}
reporterQuery: {},
registrationQuery: {}
};

const easyGraphQLLoadTester = new LoadTesting(schemaCode, queriesWithParams);
Expand All @@ -48,8 +49,8 @@ easyGraphQLLoadTester.k6('k6-reporter.js', {
customQueries: queries,
onlyCustomQueries: true,
selectedQueries: Object.keys(queriesWithParams),
vus: 10,
duration: '15s',
vus: 1,
iterations: 1,
queryFile: true,
out: ['json=reporter_result.json']
});

0 comments on commit 5a4ceb3

Please sign in to comment.