|
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 | +``` |
0 commit comments