Skip to content

Commit c64ce07

Browse files
author
vikasrohit
authored
Merge pull request #48 from topcoder-platform/develop
Prod release - 1.1.0
2 parents c22c3b3 + 5e6d705 commit c64ce07

File tree

7 files changed

+360
-40
lines changed

7 files changed

+360
-40
lines changed

config/default.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@ module.exports = {
3535
ES_METADATA_INDEX: process.env.ES_METADATA_INDEX || 'metadata',
3636
ES_TYPE: process.env.ES_TYPE || 'doc', // ES 6.x accepts only 1 Type per index and it's mandatory to define it
3737
ES_METADATA_DEFAULT_ID: process.env.ES_METADATA_DEFAULT_ID || 1 // use for setting default id of metadata
38-
}
38+
},
39+
40+
// configuration for the stress test, see `test/stress/README.md`
41+
STRESS_BASIC_QTY: process.env.STRESS_BASIC_QTY || 100,
42+
STRESS_TESTER_TIMEOUT: process.env.STRESS_TESTER_TIMEOUT || 80
3943
}

package-lock.json

Lines changed: 26 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"sync:es": "node migrations/elasticsearch_sync.js",
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",
13-
"test:cov": "nyc --reporter=html --reporter=text npm test"
13+
"test:cov": "nyc --reporter=html --reporter=text npm test",
14+
"test:stress": "NODE_ENV=test npm run sync:es && NODE_ENV=test node test/stress/doTest.js"
1415
},
1516
"author": "TCSCODER",
1617
"license": "none",
@@ -29,6 +30,7 @@
2930
"http-aws-es": "^6.0.0",
3031
"joi": "^14.3.1",
3132
"lodash": "^4.17.11",
33+
"moment": "^2.24.0",
3234
"no-kafka": "^3.4.3",
3335
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6",
3436
"topcoder-healthcheck-dropin": "^1.0.3",

src/services/ProcessorServiceMilestone.js

Lines changed: 4 additions & 16 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-
//
96-
// await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
97-
// 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})`)
91+
await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
92+
logger.debug(`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-
//
127-
// await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
128-
// 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})`)
116+
await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
117+
logger.debug(`Milestone updated successfully in elasticsearch index, (milestoneId: ${message.id})`)
130118
}
131119

132120
update.schema = {

test/e2e/processor.timeline.index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ describe('TC Timeline And Nested Timeline Topic Tests', () => {
620620
})
621621
})
622622

623-
xdescribe('TC Milestone Topic Tests', () => {
623+
describe('TC Milestone Topic Tests', () => {
624624
before(async () => {
625625
// runs before all tests in this block
626626
await ProcessorService.create(timelineCreatedMessage)

test/stress/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Stress test
2+
3+
## Overview
4+
5+
This test is checking if any error would happen if we create, updated and delete milestones in **the same** timeline document in Elasticsearch `timelines` index at the same time. We are sending multiple Kafka events in parallel to trigger create, updated and delete milestone operations.
6+
7+
1. First, the script should create initial data in the ES index:
8+
- create one timeline in the `timeline` index with `2*STRESS_BASIC_QTY` milestones (it's important that all milestones belong to the same timeline)
9+
10+
2. After initial data is created start an actual stress test by sending `3*STRESS_BASIC_QTY` Kafka messages in parallel:
11+
- `STRESS_BASIC_QTY` Kafka messages to delete half of the initially created milestones
12+
- `STRESS_BASIC_QTY` Kafka messages to update another half of initially created milestones
13+
- `STRESS_BASIC_QTY` Kafka messages to create `STRESS_BASIC_QTY` new milestones in the same timeline
14+
15+
## Configuration
16+
17+
* `STRESS_BASIC_QTY`: The basic number of objects to use in stress test.
18+
19+
* `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.
20+
21+
## Run
22+
23+
* Start processor
24+
25+
It should point the **test** ES, so set `NODE_ENV=test`.
26+
27+
```
28+
NODE_ENV=test npm start
29+
```
30+
31+
* Run stress test
32+
33+
It would test using **test** ES, as this command sets `NODE_ENV=test`.
34+
35+
```
36+
npm run test:stress
37+
```

0 commit comments

Comments
 (0)