Skip to content

Commit 98007ec

Browse files
committed
Merge branch 'develop'
# Conflicts: # config/default.js # src/app.js # src/services/ProcessorService.js
2 parents 4cacf71 + a291b91 commit 98007ec

21 files changed

+2088
-76
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
node_modules
33
*.log
44
.DS_Store
5-
.env
5+
.env*
66
coverage
77
.nyc_output
88
docker/api.env

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ The following parameters can be set in config files or in env variables:
3535
- DISABLE_LOGGING: whether to disable logging, default is false
3636
- LOG_LEVEL: the log level; default value: 'debug'
3737
- KAFKA_URL: comma separated Kafka hosts for consumer to listen; default value: 'localhost:9092'
38-
- KAFKA_GROUP_ID: Kafka consumer group id; default value: 'legacy-resources-processor-group'
38+
- KAFKA_GROUP_ID: Kafka consumer group id; default value: 'legacy-challenge-resource-processor-group'
3939
- KAFKA_CLIENT_CERT: Kafka connection certificate, optional; default value is undefined;
4040
- KAFKA_ERROR_TOPIC: The kafka error topic.
41+
- MAX_RETRIES: the number of max retries; default value: 3
4142
- RETRY_TIMEOUT: The timeout to retry processing the same message
4243
- BUSAPI_URL: Bus API URL
4344

@@ -55,6 +56,8 @@ if not provided, then SSL connection is not used, direct insecure connection is
5556
- TOKEN_CACHE_TIME: Cache time of M2M token, optional
5657
- AUTH0_CLIENT_ID: Auth0 client id for M2M token
5758
- AUTH0_CLIENT_SECRET: Auth0 client secret for M2M token
59+
- IS_CREATE_FORUM: Should create forum resource or not
60+
- CHALLENGE_ORIGINATOR: originator from challenge service
5861

5962
Also note that there is a `/health` endpoint that checks for the health of the app. This sets up an expressjs server and listens on the environment variable `PORT`. It's not part of the configuration file and needs to be passed as an environment variable
6063

build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ docker create --name app $APP_NAME:latest
99
if [ -d node_modules ]
1010
then
1111
mv package-lock.json old-package-lock.json
12-
docker cp app:/legacy-resources-processor/package-lock.json package-lock.json
12+
docker cp app:/app/package-lock.json package-lock.json
1313
set +eo pipefail
1414
UPDATE_CACHE=$(cmp package-lock.json old-package-lock.json)
1515
set -eo pipefail
@@ -19,5 +19,5 @@ fi
1919

2020
if [ "$UPDATE_CACHE" == 1 ]
2121
then
22-
docker cp app:/legacy-resources-processor/node_modules .
23-
fi
22+
docker cp app:/app/node_modules .
23+
fi

challenge-api-v5-mock/mock-challenge-api.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,36 @@ const http = require('http')
55
const send = require('http-json-response')
66
const _ = require('lodash')
77

8-
98
// Sample challenge
109
const sampleChallenge = {
11-
"id": "96059e8d-4761-4978-9a14-c86ae6b971c3",
12-
"legacyId": 30049360,
13-
"type": "Code",
14-
"track": "Develop",
15-
"name": "Test Challenge 1",
16-
"description": "Test Challenge 1 - Description",
17-
"challengeSettings": [
10+
'id': '96059e8d-4761-4978-9a14-c86ae6b971c3',
11+
'legacyId': 30049360,
12+
'type': 'Code',
13+
'track': 'Develop',
14+
'name': 'Test Challenge 1',
15+
'description': 'Test Challenge 1 - Description',
16+
'challengeSettings': [
1817
{
19-
"type": "setting1",
20-
"value": "value1"
18+
'type': 'setting1',
19+
'value': 'value1'
2120
}
2221
],
23-
"created": "2019-03-02T14:35:53.948Z",
24-
"createdBy": "Copilot1",
25-
"updated": "2019-03-02T14:35:53.948Z",
26-
"updatedBy": "Copilot1"
22+
'created': '2019-03-02T14:35:53.948Z',
23+
'createdBy': 'Copilot1',
24+
'updated': '2019-03-02T14:35:53.948Z',
25+
'updatedBy': 'Copilot1'
2726
}
2827

29-
3028
const responses = {
3129
'/v5/challenges/96059e8d-4761-4978-9a14-c86ae6b971c3': sampleChallenge
3230
}
3331

3432
const mockChallengeV5Api = http.createServer((req, res) => {
35-
36-
if (req.method === 'GET' && _.includes(Object.keys(responses), req.url)) {
33+
if (req.method === 'GET' && _.includes(Object.keys(responses), req.url)) {
3734
return send(res, 200, responses[req.url])
3835
} else {
3936
// 404 for other routes
40-
return send(res, 404, {message : 'Challenge not found'})
37+
return send(res, 404, {message: 'Challenge not found'})
4138
}
4239
})
4340

config/default.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ module.exports = {
88

99
// Kafka consumer config
1010
KAFKA_URL: process.env.KAFKA_URL || 'localhost:9092',
11-
KAFKA_GROUP_ID: process.env.KAFKA_GROUP_ID || 'legacy-resources-processor-group',
11+
KAFKA_GROUP_ID: process.env.KAFKA_GROUP_ID || 'legacy-challenge-resource-processor-group',
1212
BUSAPI_URL: process.env.BUSAPI_URL || 'https://api.topcoder-dev.com/v5',
1313
KAFKA_ERROR_TOPIC: process.env.KAFKA_ERROR_TOPIC || 'common.error.reporting',
14-
RETRY_TIMEOUT: process.env.RETRY_TIMEOUT || 60 * 1000,
14+
MAX_RETRIES: process.env.MAX_RETRIES || 3,
15+
RETRY_TIMEOUT: process.env.RETRY_TIMEOUT || 10 * 1000,
1516
EVENT_ORIGINATOR: process.env.EVENT_ORIGINATOR || 'legacy-challenge-resource-processor',
1617
EVENT_MIME_TYPE: process.env.EVENT_MIME_TYPE || 'application/json',
1718

@@ -22,17 +23,40 @@ module.exports = {
2223

2324
SUBMITTER_ROLE_ID: process.env.SUBMITTER_ROLE_ID || '732339e7-8e30-49d7-9198-cccf9451e221',
2425

26+
IS_CREATE_FORUM: process.env.IS_CREATE_FORUM || true,
27+
2528
CREATE_CHALLENGE_RESOURCE_TOPIC: process.env.CREATE_CHALLENGE_RESOURCE_TOPIC || 'challenge.action.resource.create',
2629
DELETE_CHALLENGE_RESOURCE_TOPIC: process.env.DELETE_CHALLENGE_RESOURCE_TOPIC || 'challenge.action.resource.delete',
2730

31+
CHALLENGE_ORIGINATOR: process.env.CHALLENGE_ORIGINATOR || 'app.challenge.service',
32+
2833
CHALLENGE_API_V4_URL: process.env.CHALLENGE_API_V4_URL || 'https://api.topcoder-dev.com/v4/challenges',
2934
CHALLENGE_API_V5_URL: process.env.CHALLENGE_API_V5_URL || 'http://localhost:3001/v5/challenges',
30-
RESOURCE_ROLE_API_URL: process.env.RESOURCE_ROLE_API_URL || 'https://api.topcoder-dev.com/v5/resource-roles',
35+
RESOURCE_ROLE_API_URL: process.env.RESOURCE_ROLE_API_URL || 'http://localhost:3001/v5/resource-roles',
3136

3237
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token', // Auth0 credentials for M2M token
3338
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://m2m.topcoder-dev.com/',
3439
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || 'e6oZAxnoFvjdRtjJs1Jt3tquLnNSTs0e',
3540
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET || 'invalid',
3641
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL || 'https://topcoder-dev.auth0.com/oauth/token',
37-
TOKEN_CACHE_TIME: 90
42+
TOKEN_CACHE_TIME: 90,
43+
44+
INFORMIX: {
45+
SERVER: process.env.INFORMIX_SERVER || 'informixoltp_tcp', // informix server
46+
DATABASE: process.env.INFORMIX_DATABASE || 'tcs_catalog', // informix database
47+
HOST: process.env.INFORMIX_HOST || 'localhost', // host
48+
PROTOCOL: process.env.INFORMIX_PROTOCOL || 'onsoctcp',
49+
PORT: process.env.INFORMIX_PORT || '2021', // port
50+
DB_LOCALE: process.env.INFORMIX_DB_LOCALE || 'en_US.57372',
51+
USER: process.env.INFORMIX_USER || 'informix', // user
52+
PASSWORD: process.env.INFORMIX_PASSWORD || '1nf0rm1x', // password
53+
POOL_MAX_SIZE: parseInt(process.env.INFORMIX_POOL_MAX_SIZE, 10) || 60,
54+
maxsize: parseInt(process.env.MAXSIZE) || 0,
55+
minpool: parseInt(process.env.MINPOOL, 10) || 1,
56+
idleTimeout: parseInt(process.env.IDLETIMEOUT, 10) || 3600,
57+
timeout: parseInt(process.env.TIMEOUT, 10) || 30000
58+
},
59+
60+
LEGACY_REVIEWER_ROLE_ID: process.env.LEGACY_REVIEWER_ROLE_ID || 4,
61+
LEGACY_REVIEW_PHASE_ID: process.env.LEGACY_REVIEW_PHASE_ID || 4
3862
}

docker/Dockerfile

100755100644
Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
1-
# Use the base image with Node.js 10.15-jessie
2-
FROM node:10.15-jessie
1+
FROM ibmcom/informix-innovator-c:12.10.FC12W1IE
32

4-
# Copy the current directory into the Docker image
5-
COPY . /legacy-resources-processor
3+
ARG servername=informix
64

7-
# Set working directory for future use
8-
WORKDIR /legacy-resources-processor
5+
USER root
6+
RUN mkdir /app
7+
WORKDIR /home/informix
98

10-
# Install the dependencies from package.json
11-
RUN npm install
12-
CMD npm run start
9+
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
10+
echo "deb http://ftp.debian.org/debian/ stretch main non-free contrib" >/etc/apt/sources.list && \
11+
echo "deb http://security.debian.org/ stretch/updates main contrib non-free" >>/etc/apt/sources.list
12+
13+
RUN apt-get -qq update && \
14+
apt-get -qq install -y wget gcc-6 g++-6 make xz-utils python2.7 git curl
15+
16+
RUN wget -q -O node10.tar.xz https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz \
17+
&& tar xfJ node10.tar.xz && rm -rf node10.tar.xz
18+
19+
ENV SERVERNAME=$servername
20+
21+
COPY docker/esql /opt/ibm/informix/bin/
22+
23+
RUN chmod +x /opt/ibm/informix/bin/esql
24+
RUN echo "informixoltp_tcp onsoctcp $SERVERNAME sqlexec" \
25+
> /opt/ibm/informix/etc/sqlhosts.informixoltp_tcp
26+
27+
ENV INFORMIXDIR /opt/ibm/informix
28+
ENV INFORMIX_HOME /home/informix
29+
ENV INFORMIXSERVER informixoltp_tcp
30+
ENV INFORMIXTERM terminfo
31+
ENV CLIENT_LOCALE=en_US.utf8
32+
ENV DB_LOCALE=en_US.utf8
33+
ENV DBDATE Y4MD-
34+
ENV DBDELIMITER "|"
35+
ENV PATH /home/informix/node-v10.15.1-linux-x64/bin:${INFORMIXDIR}/bin:${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${PATH}
36+
ENV LD_LIBRARY_PATH ${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${INFORMIXDIR}/lib/cli
37+
ENV INFORMIXSQLHOSTS /opt/ibm/informix/etc/sqlhosts.informixoltp_tcp
38+
ENV USER root
39+
ENV LICENSE accept
40+
41+
RUN ln -s /usr/bin/python2.7 /usr/bin/python
42+
RUN echo "sqlexec 2021/tcp" >> /etc/services
43+
44+
COPY . /app
45+
46+
WORKDIR /app
47+
RUN rm -rf node_modules && npm install --unsafe-perm
48+
49+
ENTRYPOINT [ "npm", "start" ]

docker/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: '3'
22
services:
3-
legacy-resources-processor:
4-
image: legacy-resources-processor:latest
3+
legacy-challenge-resource-processor:
4+
image: legacy-challenge-resource-processor:latest
55
build:
66
context: ../
77
dockerfile: docker/Dockerfile
88
env_file:
9-
- api.env
9+
- ../.env
1010
network_mode: "host"

0 commit comments

Comments
 (0)