Skip to content

Commit 3b36d23

Browse files
committed
Submission from Marathon Match Legacy challenge
1 parent 9428a0d commit 3b36d23

38 files changed

+2203
-1335
lines changed

Dockerfile

100644100755
File mode changed.

Procfile

100644100755
File mode changed.

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,41 @@ You can update the configuration file or set values to the corresponding environ
1616
- `KAFKA_URL` The comma delimited list of initial brokers list
1717
- `KAFKA_CLIENT_CERT` The client cert, can be (1) the path to the cert file, or (2) the cert content
1818
- `KAFKA_CLIENT_CERT_KEY` The client cert key, can be (1) the path to the cert key file, or (2) the cert key content
19-
- `KAFKA_NEW_SUBMISSION_TOPIC` The topic from which the app consumes events
20-
- `KAFKA_NEW_SUBMISSION_ORIGINATOR` The event originator
19+
- `KAFKA_NEW_SUBMISSION_TOPIC` The new submission topic from which the app consumes events
20+
- `KAFKA_NEW_SUBMISSION_ORIGINATOR` The new submission event originator
21+
- `KAFKA_UPDATE_SUBMISSION_TOPIC` The update submission topic from which the app consumes events
2122
- `SUBMISSION_API_URL` The Submission API URL
2223
- `SUBMISSION_TIMEOUT` The Submission API timeout
2324
- `DB_NAME` legacy database name 'dbname@db_server_name'
2425
- `DB_USERNAME` database username
2526
- `DB_PASSWORD` database password
2627
- `ID_SEQ_UPLOAD` upload database sequence
2728
- `ID_SEQ_SUBMISSION` submission database sequence
28-
29+
- `AUTH0_URL` auth0 url
30+
- `AUTH0_AUDIENCE` auth0 audience
31+
- `TOKEN_CACHE_TIME` auth0 token cache time
32+
- `AUTH0_CLIENT_ID` auth0 client id
33+
- `AUTH0_CLIENT_SECRET` auth0 client secret
34+
- `CHALLENGE_INFO_API` The challenge info api template with {cid} gets replaced with challenge id
35+
- `CHALLENGE_SUBTRACK` The sub track of marathon match challenge
36+
37+
`./config/production.js`, `./config/staging.js`, `./config/test.js` will use same configuration variables as `./config/default.js` except `./config/test.js` will have new configurations for test only.
38+
- `MOCK_SUBMISSION_API_PORT` The mock submission api port
39+
- `MOCK_SERVER_PORT` The mock server port for challenge api
40+
41+
`./config/mock.js` will use same configuration variables as `./config/default.js` except
42+
- `MOCK_SERVER_PORT` The mock server port for challenge api
43+
44+
`./test/test_files/sqlParams.json` will load necessary sql params used in test, it will only work if you run `./test/sql/test.sql`.
45+
2946
> NOTE: ALL COMMANDS BELOW EXECUTE UNDER ```<legacy-sub-procecssor>``` directory
3047
3148
To build the application you must set the `DB_SERVER_NAME` environment variable. This variable holds the database hostname.
3249

3350
## Build Application Docker Image
3451
We only need to do this once
3552
```bash
53+
export DB_SERVER_NAME=informix
3654
docker-compose build lsp-app
3755
```
3856

@@ -58,19 +76,20 @@ docker-compose up lsp-app-install
5876

5977
## Deployment
6078
```bash
79+
export DB_SERVER_NAME=informix
6180
docker-compose up lsp-app
6281
```
6382

6483
## Running Test
6584
- Make sure you're running a clean database (you can take down tc-informix container and then up it again)
6685
- Stop `legacy-sub-processor` application if it was running
67-
- Install test data
86+
- Install test data and you may start service `tc-informix` with command `docker-compose up tc-informix` if not started
6887
```bash
6988
docker cp test/sql/test.sql iif_innovator_c:/
7089
docker exec -ti iif_innovator_c bash -c "source /home/informix/ifx_informixoltp_tcp.env && dbaccess - /test.sql"
7190
```
7291
- Run kafka container (and create topic if you haven't do this before)
73-
- Run
92+
- Run (you can use `docker-compose run lsp-app-test` too and it is more suitable for test command)
7493
```bash
7594
docker-compose up lsp-app-test
7695
```

Validation.md

Lines changed: 91 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,91 @@
1-
# Topcoder - Submission Legacy Processor Application - Verification
2-
------------
3-
4-
## Setup Kafka
5-
6-
- Download Kafka v1.1.0: https://kafka.apache.org/downloads
7-
- Extract the downloaded file to a directory
8-
- To enable SSL, copy the following lines to the end of `<your-kafka-directory>/config/server.properties`
9-
10-
```
11-
listeners=plaintext://localhost:9092,ssl://localhost:9093
12-
ssl.truststore.location=<absolute-path-to-server.truststore.jks>
13-
ssl.truststore.password=test1234
14-
ssl.keystore.location=<absolute-path-to-server.keystore.jks>
15-
ssl.keystore.password=test1234
16-
ssl.key.password=test1234
17-
```
18-
19-
Replace `<absolute-path-to-server.truststore.jks>` to the absolute path to the file `tc-submission-legacy-processor/test/kafka-ssl/server.truststore.jks`
20-
Replace `<absolute-path-to-server.truststore.jks>` to the absolute path to the file `tc-submission-legacy-processor/test/kafka-ssl/server.keystore.jks`
21-
22-
- Example on my Windows PC:
23-
24-
```
25-
listeners=plaintext://localhost:9092,ssl://localhost:9093
26-
ssl.truststore.location=D:/Others/tc-submission-legacy-processor/tc-submission-legacy-processor/test/kafka-ssl/server.truststore.jks
27-
ssl.truststore.password=test1234
28-
ssl.keystore.location=D:/Others/tc-submission-legacy-processor/tc-submission-legacy-processor/test/kafka-ssl/server.keystore.jks
29-
ssl.keystore.password=test1234
30-
ssl.key.password=test1234
31-
```
32-
33-
## Start ZooKeeper
34-
35-
- `cd <your-kafka-directory>`
36-
- For Linux: `bin/zookeeper-server-start.sh config/zookeeper.properties`
37-
- For Windows: `bin\windows\zookeeper-server-start.bat config\zookeeper.properties`
38-
39-
## Start Kafka
40-
41-
- `cd <your-kafka-directory>`
42-
- For Linux: `bin/kafka-server-start.sh config/server.properties`
43-
- For Windows: `bin\windows\kafka-server-start.bat config/server.properties`
44-
45-
## Create Test Topics in Kafka
46-
47-
- `cd <your-kafka-directory>`
48-
- For Linux:
49-
```
50-
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic different-topic
51-
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic new-submission-topic
52-
```
53-
- For Windows:
54-
```
55-
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic different-topic
56-
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic new-submission-topic
57-
```
58-
59-
## Run Unit Tests
60-
61-
- `cd tc-submission-legacy-processor`
62-
- `npm i`
63-
- `npm test`
64-
65-
The detailed test coverage report (html) is generated to `./coverage` directory
66-
67-
## Manual Verification
68-
69-
### Start the Mock Submission API
70-
71-
- `cd tc-submission-legacy-processor`
72-
- `npm i`
73-
- `npm run mock-submission-api`
74-
75-
### Start the Application in Test Environment
76-
77-
- `cd tc-submission-legacy-processor`
78-
- For Linux:
79-
```
80-
export NODE_ENV=test
81-
npm start
82-
```
83-
- For Windows:
84-
```
85-
set NODE_ENV=test
86-
npm start
87-
```
88-
89-
### Send Test Events and Verify
90-
91-
- `cd tc-submission-legacy-processor`
92-
- For Linux: `export NODE_ENV=test`
93-
- For Windows: `set NODE_ENV=test`
94-
- Run `npm run produce-test-event 0` and verify that the app doesn't consume this message (no log)
95-
- Run `npm run produce-test-event 1` and verify that the app skips this message (log: `Skipped null or empty event`)
96-
- Run `npm run produce-test-event 2` and verify that the app skips this message (log: `Skipped null or empty event`)
97-
- Run `npm run produce-test-event 3` and verify that the app skips this message (log: `Skipped non well-formed JSON message: ...`)
98-
- Run `npm run produce-test-event 4` and verify that the app skips this message (log: ` Skipped invalid event, reasons: "topic" is required ...`)
99-
- Run `npm run produce-test-event 5` and verify that the app skips this message (log: `Skipped invalid event, reasons: "timestamp" must be...`)
100-
- Run `npm run produce-test-event 6` and verify that the app skips this message (log: `Skipped event from topic wrong-topic`)
101-
- Run `npm run produce-test-event 7` and verify that the app skips this message (log: `Skipped event from topic wrong-originator`)
102-
- Run `npm run produce-test-event 8` and verify that the app makes call to the Submission API successfully (log: `Updated to the Submission API: id 111, ...`) and the Mock Submission API receives `PUT /submissions/111` request with request body like `{"id":111,"legacySubmissionId":1531219317896}`. `legacySubmissionId` is current epoch in the current implementation.
1+
# Topcoder - Submission Legacy Processor Application - Verification
2+
------------
3+
4+
Please check [docs/Validation.md](/docs/Validation.md) and [docs/Verification_with_DB.md](/docs/Verification_with_DB.md).
5+
6+
Please note currently you have to verify application with database or please check [docs/Verification_with_DB.md](/docs/Verification_with_DB.md) only.
7+
8+
I would recommend you to verify and test with docker otherwise you need to check related Dockerfile to have better understanding about how to setup environment properly(not recommend).
9+
10+
11+
## Topcoder - Marathon Match - Legacy Processor
12+
Please verify under linux or osx and I test under Ubuntu 18.04 and OSX 12 and windows may have issues to verify with docker.
13+
14+
Please check README.md and ensure you could run tests in docker environment successfully and you can check coverage folder to ensure
15+
`src/services/MarathonSubmissionService.js`,`src/services/NonMarathonSubmissionService.js`,`src/services/LegacySubmissionIdService.js` are fully tested.
16+
17+
## Setup data in direct
18+
Only necessary MM challenge related test data updated in `./test/sql/test.sql` and you can also setup complete test data using direct application.
19+
20+
You can follow [docs/Verification_with_DB.md](/docs/Verification_with_DB.md) to setup MM challenge in direct app, choose Marathon Match under Data menu during creating challenge and create new project with billing account if error to save mm challenge, in last step you have to create as draft challenge,add user as Submitter and get match submission phase id.
21+
22+
Currently tc-direct have [issue to save Match Round ID](https://github.com/appirio-tech/direct-app/issues/341) or you may see such logs from command `docker-compose logs tc-direct` if you want to save in page and refresh page.
23+
```bash
24+
| 07:48:37,097 ERROR [ExceptionMappingInterceptor] Invalid action class configuration that references an unknown class named [saveDraftContestAction]
25+
tc-direct_1 | java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [saveDraftContestAction]
26+
```
27+
28+
So you have to run such sql and replace <mm challenge id> with your new created mm challenge id.
29+
```bash
30+
database tcs_catalog;
31+
INSERT INTO informix.project_info
32+
(project_id, project_info_type_id, value, create_user, create_date, modify_user, modify_date)
33+
VALUES(<mm challenge id>, 56, 2001, '132456', current, '132456', current);
34+
```
35+
36+
Even you run sql direct app will still fail to show details page with such error
37+
```bash
38+
java.lang.NullPointerException
39+
tc-direct_1 | at com.topcoder.direct.services.view.action.analytics.longcontest.MarathonMatchHelper.getMarathonMatchDetails(MarathonMatchHelper.java:115)
40+
tc-direct_1 | at com.topcoder.direct.services.view.action.contest.launch.GetContestAction.executeAction(GetContestAction.java:476)
41+
tc-direct_1 | at com.topcoder.direct.services.view.action.BaseDirectStrutsAction.execute(BaseDirectStrutsAction.java:305)
42+
tc-direct_1 | at sun.reflect.GeneratedMethodAccessor553.invoke(Unknown Source)
43+
44+
```
45+
46+
Please check https://github.com/appirio-tech/direct-app/blob/dev/src/java/main/com/topcoder/direct/services/view/action/contest/launch/GetContestAction.java#L502
47+
48+
Even latest direct codes will comment out related codes to solve this issue so just leave direct page there.
49+
50+
## Run Legacy Submission Proc. app
51+
52+
Make sure related services started and test data prepared and start app with `NODE_ENV=mock` to mock challenge api otherwise new created mm challenge will still consider as non mm challenge
53+
```bash
54+
export NODE_ENV=mock
55+
export DB_SERVER_NAME=informix
56+
docker-compose up lsp-app
57+
```
58+
59+
## Send Test data
60+
From previous data setup I got:
61+
- challengeId = 40005570
62+
- memberId = 132458 (user)
63+
- submissionPhaseId = 100024
64+
65+
Let's send mm submission with example = 0 event to kafka:
66+
67+
```bash
68+
docker exec -ti lsp-app bash -c "npm run produce-test-event mm 40005570 132458 100024 0"
69+
```
70+
71+
Let's send mm submission with example = 1 event to kafka:
72+
73+
```bash
74+
docker exec -ti lsp-app bash -c "npm run produce-test-event mm 40005570 132458 100024 1"
75+
```
76+
77+
or you can run sample mm submission message directly(valid if run `test/sql/test.sql`)
78+
```bash
79+
docker exec -ti lsp-app bash -c "npm run produce-test-event 9"
80+
```
81+
82+
83+
Please note currently processor will call challenge api to check whether challenge is MM challenge and default server api.topcoder-dev.com may not exist mm challenge created in local direct application.
84+
So when we start app with NODE_ENV=mock it will use mock challenge api configurations and start mock challenge api server.
85+
86+
## Verify Database
87+
Open your database explorer (**DBeaver** application, for instance). Connect to database informixoltp
88+
Check table: `long_component_state`, `long_submission` or run below sql
89+
```bash
90+
select lcs.status_id,lcs.points, lcs.example_submission_number,lcs.submission_number,ls.* from informixoltp:long_submission ls, informixoltp:long_component_state lcs where ls.long_component_state_id=lcs.long_component_state_id
91+
```

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ echo "================================"
2828
echo "tc-informix has created"
2929
echo "Executing kafka topics"
3030
echo "================================"
31+
sleep 15
3132
docker exec -ti kafka bash -c "kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic submission.notification.create"
3233
docker exec -ti kafka bash -c "kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic submission.notification.update"
3334
echo "================================"

config/default.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,9 @@ module.exports = {
5555

5656
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
5757

58-
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET
58+
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
59+
60+
CHALLENGE_INFO_API: process.env.CHALLENGE_INFO_API || 'https://api.topcoder-dev.com/v4/challenges?filter=id={cid}', // {cid} gets replaced with challenge id
61+
62+
CHALLENGE_SUBTRACK: process.env.CHALLENGE_SUBTRACK || 'MARATHON_MATCH'
5963
}

config/mock.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* The mock configuration.
3+
*/
4+
const MOCK_SERVER_PORT = 3003
5+
module.exports = {
6+
MOCK_SERVER_PORT,
7+
LOG_LEVEL: 'debug',
8+
CHALLENGE_INFO_API: `http://localhost:${MOCK_SERVER_PORT}/challenges?filter=id={cid}`
9+
}

config/production.js

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ module.exports = {
5555

5656
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
5757

58-
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET
58+
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
59+
60+
CHALLENGE_INFO_API: process.env.CHALLENGE_INFO_API
5961
}

config/staging.js

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ module.exports = {
4545
ID_SEQ_UPLOAD: process.env.ID_SEQ_UPLOAD || 'upload_id_seq',
4646

4747
// The Informix Submission Table Sequence Name
48-
ID_SEQ_SUBMISSION: process.env.ID_SEQ_SUBMISSION || 'submission_id_seq'
48+
ID_SEQ_SUBMISSION: process.env.ID_SEQ_SUBMISSION || 'submission_id_seq',
49+
50+
CHALLENGE_INFO_API: process.env.CHALLENGE_INFO_API
4951
}

config/test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
/**
22
* The test configuration.
33
*/
4+
const MOCK_SUBMISSION_API_PORT = 3000
5+
const MOCK_SERVER_PORT = 3001
46
module.exports = {
7+
MOCK_SUBMISSION_API_PORT,
8+
MOCK_SERVER_PORT,
59
LOG_LEVEL: 'debug',
610

711
// The client group ID for committing and fetching offsets.
@@ -27,7 +31,7 @@ module.exports = {
2731
KAFKA_NEW_SUBMISSION_ORIGINATOR: 'new-submission-originator',
2832

2933
// The Submission API URL
30-
SUBMISSION_API_URL: 'http://localhost:3000',
34+
SUBMISSION_API_URL: `http://localhost:${MOCK_SUBMISSION_API_PORT}`,
3135

3236
// The Submission API timeout
3337
SUBMISSION_TIMEOUT: 2000,
@@ -45,5 +49,9 @@ module.exports = {
4549
ID_SEQ_UPLOAD: 'upload_id_seq',
4650

4751
// The Informix Submission Table Sequence Name
48-
ID_SEQ_SUBMISSION: 'submission_id_seq'
52+
ID_SEQ_SUBMISSION: 'submission_id_seq',
53+
54+
CHALLENGE_INFO_API: `http://localhost:${MOCK_SERVER_PORT}/challenges?filter=id={cid}`, // {cid} gets replaced with challenge id
55+
56+
CHALLENGE_SUBTRACK: 'MARATHON_MATCH'
4957
}

docker-compose.yml

100644100755
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ services:
7777
container_name: mock-submission-api
7878
volumes:
7979
- ".:/app"
80-
- "PORT=3000"
8180
command: run mock-submission-api
8281

8382
lsp-app-install:
@@ -98,7 +97,7 @@ services:
9897
image: lsp-app:latest
9998
container_name: lsp-app
10099
environment:
101-
- "NODE_ENV=development"
100+
- "NODE_ENV=${NODE_ENV:-development}"
102101
- "PORT=3300"
103102
volumes:
104103
- ".:/app"
@@ -150,6 +149,7 @@ services:
150149
- SUBMISSION_API_URL=${SUBMISSION_API_URL}
151150
- DB_USERNAME=${DB_USERNAME}
152151
- DB_PASSWORD=${DB_PASSWORD}
152+
- CHALLENGE_INFO_API=${CHALLENGE_INFO_API}
153153
volumes:
154154
- ".:/app"
155155
command: run start:docker
@@ -175,6 +175,7 @@ services:
175175
- SUBMISSION_API_URL=${SUBMISSION_API_URL}
176176
- DB_USERNAME=${DB_USERNAME}
177177
- DB_PASSWORD=${DB_PASSWORD}
178+
- CHALLENGE_INFO_API=${CHALLENGE_INFO_API}
178179
volumes:
179180
- ".:/app"
180181
command: run start:docker

docker/kafka/ssl.config

100644100755
File mode changed.

docker/kafka/supervisor/kafka.conf

100644100755
File mode changed.

docker/kafka/supervisor/zookeeper.conf

100644100755
File mode changed.

0 commit comments

Comments
 (0)