Skip to content

Commit bcf68c7

Browse files
Add support to create challenges in ES directly in this API
1 parent 9a7f04e commit bcf68c7

27 files changed

+1014
-886
lines changed

.eslintrc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: standard

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The following parameters can be set in config files or in env variables:
3636
- ES.API_VERSION: Elasticsearch API version
3737
- ES.ES_INDEX: Elasticsearch index name
3838
- ES.ES_TYPE: Elasticsearch index type
39+
- ES.ES_REFRESH: Elasticsearch refresh method. Default to string `true`(i.e. refresh immediately)
3940
- FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes
4041
- CHALLENGES_API_URL: TC challenges API base URL
4142
- GROUPS_API_URL: TC groups API base URL
@@ -64,13 +65,15 @@ The following test parameters can be set in config file or in env variables:
6465
- M2M_FULL_ACCESS_TOKEN: M2M full access token
6566
- M2M_READ_ACCESS_TOKEN: M2M read access token
6667
- M2M_UPDATE_ACCESS_TOKEN: M2M update (including 'delete') access token
67-
68-
## Local Elasticsearch and DynamoDB setup
69-
In the `local` folder, run `docker-compose up`
68+
- S3_ENDPOINT: endpoint of AWS S3 API, for unit and e2e test only; default to `localhost:9000`
7069

7170
## AWS S3 Setup
7271
Go to https://console.aws.amazon.com/ and login. Choose S3 from Service folder and click `Create bucket`. Following the instruction to create S3 bucket.
7372

73+
## Local services setup
74+
In the `local` folder, run `docker-compose up`
75+
It starts Elasticsearch, DynamoDB and S3 compatible server.
76+
7477
## Mock api
7578
For postman verification, please use the mock api under mock-api folder. It provides mock endpoint to fetch challenge resources and groups.
7679
Go to `mock-api` folder and run command `npm run start` to start the mock-api listening on port 4000
@@ -106,12 +109,15 @@ Go to `mock-api` folder and run command `npm run start` to start the mock-api li
106109

107110
## Running tests
108111

109-
Before running tests, DynamoDB tables should be created, ES index should be initialized, mock API should be started and
110-
various config parameters are properly set.
112+
### Prepare
113+
- Start Local services.
114+
- Start Mock API.
115+
- Create DynamoDB tables.
116+
- Initialize ES index.
117+
- Various config parameters should be properly set.
111118
Seeding db data is not needed.
112119

113120
### Running unit tests
114-
115121
To run unit tests alone
116122

117123
```bash
@@ -125,7 +131,6 @@ npm run test:cov
125131
```
126132

127133
### Running integration tests
128-
129134
To run integration tests alone
130135

131136
```bash

Verification.md

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Run command `npm run view-data <ModelName>` to view table data, ModelName can be
1111

1212
Login to AWS Console, S3 service, view the bucket content.
1313

14+
## ElasticSearch Verification
15+
16+
Run command `npm run view-es-data` to view data store in ES.
1417

1518
## Bus Event Verification
1619

config/default.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ module.exports = {
3333
ES: {
3434
// above AWS_REGION is used if we use AWS ES
3535
HOST: process.env.ES_HOST || 'localhost:9200',
36-
API_VERSION: process.env.ES_API_VERSION || '6.7',
36+
API_VERSION: process.env.ES_API_VERSION || '6.8',
3737
ES_INDEX: process.env.ES_INDEX || 'challenge',
38-
ES_TYPE: process.env.ES_TYPE || '_doc' // ES 6.x accepts only 1 Type per index and it's mandatory to define it
38+
ES_TYPE: process.env.ES_TYPE || '_doc', // ES 6.x accepts only 1 Type per index and it's mandatory to define it
39+
ES_REFRESH: process.env.ES_REFRESH || 'true'
3940
},
4041

4142
// in bytes

config/test.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

local/docker-compose.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ services:
66
- "7777:7777"
77
command: "-inMemory -port 7777"
88
esearch:
9-
image: "docker.elastic.co/elasticsearch/elasticsearch:6.3.1"
9+
image: "docker.elastic.co/elasticsearch/elasticsearch:6.8.0"
1010
ports:
1111
- "9200:9200"
12+
environment:
13+
- "discovery.type=single-node"
14+
minio1:
15+
image: minio/minio
16+
ports:
17+
- "9000:9000"
18+
environment:
19+
MINIO_ACCESS_KEY: "FAKE_ACCESS_KEY"
20+
MINIO_SECRET_KEY: "FAKE_SECRET_ACCESS_KEY"
21+
command: "server /data"

0 commit comments

Comments
 (0)