Skip to content

Commit 1edcca3

Browse files
committed
refactor: stress test code enhancements
1 parent b7e7ee1 commit 1edcca3

File tree

7 files changed

+188
-202
lines changed

7 files changed

+188
-202
lines changed

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = {
3737
ES_METADATA_DEFAULT_ID: process.env.ES_METADATA_DEFAULT_ID || 1 // use for setting default id of metadata
3838
},
3939

40+
// configuration for the stress test, see `test/stress/README.md`
4041
STRESS_BASIC_QTY: process.env.STRESS_BASIC_QTY || 100,
4142
STRESS_TESTER_TIMEOUT: process.env.STRESS_TESTER_TIMEOUT || 80
4243
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"view-data": "node test/common/view-data.js",
1212
"test": "NODE_ENV=test npm run sync:es && mocha test/e2e/*.test.js --timeout 30000 --exit && NODE_ENV=test npm run sync:es",
1313
"test:cov": "nyc --reporter=html --reporter=text npm test",
14-
"test:stress": "npm run sync:es && node test/stress/doTest.js"
14+
"test:stress": "NODE_ENV=test npm run sync:es && NODE_ENV=test node test/stress/doTest.js"
1515
},
1616
"author": "TCSCODER",
1717
"license": "none",

src/services/ProcessorServiceMilestone.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,8 @@ async function create (message) {
8888
return _.assign(doc._source, { milestones })
8989
}
9090

91-
// NOTE Disable indexing milestones when create at the moment, as it's now being indexed inside Project Service.
92-
// It's because adding a milestones may cause cascading updates of other milestones and in such cases we are doing
93-
// one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
94-
// This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
95-
//
9691
await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
9792
logger.debug(`Milestone created successfully in elasticsearch index, (milestoneId: ${message.id})`)
98-
// logger.debug(`TEMPORARY SKIPPED: Milestone created successfully in elasticsearch index, (milestoneId: ${message.id})`)
9993
}
10094

10195
create.schema = {
@@ -119,14 +113,8 @@ async function update (message) {
119113
return _.assign(doc._source, { milestones })
120114
}
121115

122-
// NOTE Disable indexing milestones when update at the moment, as it's now being indexed inside Project Service.
123-
// It's because updating a milestones may cause cascading updates of other milestones and in such cases we are doing
124-
// one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
125-
// This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
126-
//
127116
await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
128117
logger.debug(`Milestone updated successfully in elasticsearch index, (milestoneId: ${message.id})`)
129-
// logger.debug(`TEMPORARY SKIPPED: Milestone updated successfully in elasticsearch index, (milestoneId: ${message.id})`)
130118
}
131119

132120
update.schema = {

src/services/ProcessorServiceProject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function createSchema () {
4747
createdAt: Joi.date(),
4848
createdBy: Joi.number().integer().positive(),
4949
updatedAt: Joi.date(),
50-
updatedBy: Joi.number().integer().positive(),
50+
updatedBy: Joi.number().integer().positive()
5151
})).optional().allow(null),
5252
external: Joi.object().keys({
5353
id: Joi.string(),

test/stress/README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
## Configuration
22

3-
* STRESS_BASIC_QTY: As requested in challenge description
3+
* `STRESS_BASIC_QTY`: As requested in challenge description
44

5-
* STRESS_TESTER_TIMEOUT: Number of seconds to wait after queueing create/update/delete requests
6-
and before validating data. Default is 80s, which is enough for `STRESS_BASIC_QTY=100`. This
7-
might have to be increased if `STRESS_BASIC_QTY` is higher than 100.
5+
* `STRESS_TESTER_TIMEOUT`: Number of seconds to wait after queueing create/update/delete requests and before validating data. Default is 80s, which is enough for `STRESS_BASIC_QTY=100`. This might have to be increased if `STRESS_BASIC_QTY` is higher than 100.
86

9-
## Validation
7+
## Run
108

11-
* Start processor:
9+
* Start processor
1210

13-
npm start
11+
It should point the **test** ES, so set `NODE_ENV=test`.
1412

15-
* Run `npm run test:stress`
13+
```
14+
NODE_ENV=test npm start
15+
```
1616

17-
Saves ids of milestones not updated/created/deleted to `test/stress/stress_test_errors.json`
17+
* Run stress test
18+
19+
It would test using **test** ES, as this command sets `NODE_ENV=test`.
20+
21+
```
22+
npm run test:stress
23+
```
24+
25+
I would save ids of milestones not updated/created/deleted to `test/stress/stress_test_errors.json`

0 commit comments

Comments
 (0)