Code Monkey home page Code Monkey logo

legacy-challenge-resource-processor's Introduction

Topcoder - Legacy Resources Processor

This Processor is used for processing kafka events and backfills Informix with Challenge Resource data

Development deployment status

CircleCI

Production deployment status

CircleCI

Postman Collection

Intended use

  • Processor

Related repos

Prerequisites

Configuration

Configuration for the processor is at config/default.js. The following parameters can be set in config files or in env variables:

  • DISABLE_LOGGING: whether to disable logging, default is false
  • LOG_LEVEL: the log level; default value: 'debug'
  • KAFKA_URL: comma separated Kafka hosts for consumer to listen; default value: 'localhost:9092'
  • KAFKA_GROUP_ID: Kafka consumer group id; default value: 'legacy-challenge-resource-processor-group'
  • KAFKA_CLIENT_CERT: Kafka connection certificate, optional; default value is undefined;
  • KAFKA_ERROR_TOPIC: The kafka error topic.
  • MAX_RETRIES: the number of max retries; default value: 3
  • RETRY_TIMEOUT: The timeout to retry processing the same message
  • BUSAPI_URL: Bus API URL

if not provided, then SSL connection is not used, direct insecure connection is used;

  • KAFKA_CLIENT_CERT_KEY: Kafka connection private key, optional; default value is undefined;

if not provided, then SSL connection is not used, direct insecure connection is used;

  • CREATE_CHALLENGE_RESOURCE_TOPIC: Create challenge resource Kafka topic, default value is 'challenge.resources.notification.create'
  • DELETE_CHALLENGE_RESOURCE_TOPIC: Delete challenge resource Kafka topic, default value is 'challenge.resources.notification.delete'
  • CHALLENGE_API_V4_URL: Challenge V4 API URL, default value is 'https://api.topcoder-dev.com/v4/challenges'
  • CHALLENGE_API_V5_URL: Challenge V5 API URL, default value is 'http://localhost:3001/v5/challenges', which is mocked for now since the V5 API is not deployed in Topcoder Dev environment yet.
  • AUTH0_URL: Auth0 url for M2M token
  • AUTH0_AUDIENCE: Auth0 audience for M2M token || 'https://www.topcoder-dev.com',
  • TOKEN_CACHE_TIME: Cache time of M2M token, optional
  • AUTH0_CLIENT_ID: Auth0 client id for M2M token
  • AUTH0_CLIENT_SECRET: Auth0 client secret for M2M token
  • IS_CREATE_FORUM: Should create forum resource or not
  • CHALLENGE_ORIGINATOR: originator from challenge service

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

Configuration for the tests is at config/test.js. Following parameters need to be set via environment variables or directly in config file

  • TEST_KAFKA_URL: Kafka URL pointing to Kafka test instance
  • WAIT_TIME: wait time used in test, default is 1000 or one second

Local Deployment

Foreman Setup

To install foreman follow this link To know how to use foreman follow this link

Local Kafka setup

  • http://kafka.apache.org/quickstart contains details to setup and manage Kafka server, below provides details to setup Kafka server in Mac, Windows will use bat commands in bin/windows instead
  • download kafka at https://www.apache.org/dyn/closer.cgi?path=/kafka/1.1.0/kafka_2.11-1.1.0.tgz
  • extract out the downloaded tgz file
  • go to extracted directory kafka_2.11-0.11.0.1
  • start ZooKeeper server: bin/zookeeper-server-start.sh config/zookeeper.properties
  • use another terminal, go to same directory, start the Kafka server: bin/kafka-server-start.sh config/server.properties
  • note that the zookeeper server is at localhost:2181, and Kafka server is at localhost:9092
  • use another terminal, go to same directory, create the needed topics:

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic challenge.resources.notification.create

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic challenge.resources.notification.delete

  • verify that the topics are created:

bin/kafka-topics.sh --list --zookeeper localhost:2181,

it should list out the created topics

Local deployment without Docker

  • install dependencies npm i
  • run code lint check npm run lint, running npm run lint:fix can fix some lint errors if any
  • start processor app npm start
  • to start with production config npm runt start:prod

Local Deployment with Docker

To run the processor using docker, follow the below steps

  1. Navigate to the directory docker
  2. Rename the file sample.api.env to api.env
  3. Set parameters in the file api.env
  4. Once that is done, run the following command
docker-compose up
  1. When you are running the application for the first time, It will take some time initially to download the image and install the dependencies

Production deployment

  • TBD

Running tests

Configuration

Test configuration is at config/test.js. You don't need to change them. The following test parameters can be set in config file or in env variables:

  • DISABLE_LOGGING: whether to disable logging, default is false
  • LOG_LEVEL: the log level; default value: 'debug'
  • KAFKA_URL: comma separated Kafka hosts for consumer to listen; default value: 'localhost:9092'
  • WAIT_TIME: wait time used in test, default is 1000 or one second

Prepare

  • Start Local services.
  • Start Mock API.
  • Various config parameters should be properly set.

Running unit tests

To run unit tests alone

npm run test

To run unit tests with coverage report, you can check generated coverage report in coverage folder and coverage for src/services/ProcessorService.js is 100%.

npm run cov

Running integration tests

To run integration tests alone

Please note that E2E tests work against the real Topcoder Dev API, and the following challenge is used for testing :

  1. Go to accounts.topcoder-dev.com/member
  2. Login as TonyJ/appirio123
  3. https://software.topcoder-dev.com/review/actions/ViewProjectDetails?pid=30049360
npm run e2e

To run integration tests with coverage report

please note e2e tests will run with real api so e2e tests will not cover some error cases but most cases are modified from unit tests

npm run cov-e2e

Running tests in CI

  • TBD

Verification

Refer to the verification document Verification.md

Commit to force redeploy

legacy-challenge-resource-processor's People

Contributors

dependabot[bot] avatar eisbilir avatar gaoziqiang007 avatar gunasekar-k avatar jpeg22 avatar lieutenantroger avatar rakibansary avatar rootelement avatar standlove avatar thomaskranitsas avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

legacy-challenge-resource-processor's Issues

Approver Role is not required, if there is no Approval Phase

Don't create approver role for resources, if there is no Approval phase on the challenge.
eg in a Task / Code challenge, there is no approval phase, hence no resource with approver role is needed.

An extra resource, creates issues while manually closing challenges in OR.

Project Phase Id is required for Review resources

In informix: resource table has a field project_phase_id.
For all reviewer type roles such as Reviewer, Checkpoint Screener, Primary Screener, Screener, Specification Reviewer etc , this field needs to be populated to ensure OR is able to close the phase correctly.

While backfilling please have the field populated.

Member is not added as Submitter resource until Registration phase is open

As per flow suggested here we are trying to add the assigned user of a task as Submitter role to the challenge but legacy resource processor is not able to add it to the legacy apps because the v4 api is throwing an error complaining that we can not add a resource in Submitter role until challenge is in registration phase.
So, we might have to skip using v4 api to add submitter resource for a task.

Allow changing reviewer payment

  • If challenge metadata {name: 'reviewerPrize', value: "AMT" } is edited, this should set the all the reviewers payment amount to AMT.
  • If a reviewer is not yet set, when the resource is added, the prize amount should equal AMT

Add Manual Payments

Online Review automatically calculates payments for resources unless a "Manual Payments" resource info is added for the resource. Topgear challenges with {name: "reviewerPrize" value: AMOUNT} in challenge metadata sets a manual reviewer prize amount, but this value gets overwritten by Online Review during phase change. This also happens for challenges with "reviewer" prize in "prizeSets".

For such payments and for challenges with a "reviewer" prize set in prizeSets, add the "Manual Payments" metadata in resource info to instruct OR to not overwrite the payment info.

Processor stops listening further events after uncaught exceptions/errors

From the logs of the processor it seems it stops processing new events once it fails because of any uncaught exception/error:

07:39:49 { Error: cannot POST /v5/bus/events (504)
07:39:49 at Response.toError (/legacy-resources-processor/node_modules/topcoder-bus-api-wrapper/node_modules/superagent/lib/node/response.js:94:15)
07:39:49 at ResponseBase._setStatusProperties (/legacy-resources-processor/node_modules/topcoder-bus-api-wrapper/node_modules/superagent/lib/response-base.js:123:16)
07:39:49 at new Response (/legacy-resources-processor/node_modules/topcoder-bus-api-wrapper/node_modules/superagent/lib/node/response.js:41:8)
07:39:49 at Request._emitResponse (/legacy-resources-processor/node_modules/topcoder-bus-api-wrapper/node_modules/superagent/lib/node/index.js:752:20)
07:39:49 at IncomingMessage.parser (/legacy-resources-processor/node_modules/topcoder-bus-api-wrapper/node_modules/superagent/lib/node/index.js:916:38)
07:39:49 at IncomingMessage.emit (events.js:194:15)
07:39:49 at endReadableNT (_stream_readable.js:1125:12)
07:39:49 at process._tickCallback (internal/process/next_tick.js:63:19)
07:39:49status: 504,
07:39:49 text:
07:39:49 '<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body bgcolor="white">\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n</body>\r\n</html>\r\n',
07:39:49 method: 'POST',
07:39:49 path: '/v5/bus/events' },

fyi @rootelement @ThomasKranitsas

Manual Payment Setting on Resource breaks the sync

Steps to reproduce:
1 : Assign the reviewer on challenge.
2 : Set payment to manual and add new payment.
3 : Remove the reviewer.
4: Try to access the payment option in OR, will receive the below error.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.