Skip to content

Supporting Release Connect 2.4.11 #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 71 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
6811fc3
local development support
gondzo Feb 9, 2019
22415e4
Fixed the bug where we were not getting the waiting for customer even…
Mar 11, 2019
58aa287
lint fix
Mar 11, 2019
0b469f0
Fixing unit tests for aliases field of product template
Mar 11, 2019
f375a1d
Merge pull request #248 from topcoder-platform/feature/localDevelopment
Mar 12, 2019
bd0f599
improve local development guide in README
maxceem Mar 13, 2019
b1484a7
Merge pull request #260 from maxceem/feature/improve-readme
Mar 13, 2019
e3410f0
Making all metadata endpoints to require authentication as we don’t h…
Mar 13, 2019
23d8593
fixing unit tests for orgconfig
Mar 13, 2019
92b6b64
Merge pull request #262 from topcoder-platform/feature/authentication…
Mar 13, 2019
a5a52ff
test are now running using a separate instance of PostgreSQL in docke…
maxceem Mar 14, 2019
0af9407
README update
maxceem Mar 14, 2019
f8c4acc
Merge pull request #263 from maxceem/feature/improve-test-running
Mar 14, 2019
023818a
fix seed metadata script
maxceem Mar 14, 2019
8ce5e6b
improve error handling
maxceem Mar 14, 2019
19f0767
use M2M token for Identity and Member services
maxceem Mar 15, 2019
03645d1
trigger running tests again
maxceem Mar 15, 2019
ac0a146
mock for identity service /users ednpoint
maxceem Mar 15, 2019
f4474ce
Merge pull request #267 from maxceem/feature/mock-identity-service-users
Mar 15, 2019
529a624
Merge pull request #265 from topcoder-platform/feature/fix-metadata-s…
Mar 15, 2019
74c8fcf
Merge pull request #268 from topcoder-platform/feature/use-m2m-token
Mar 15, 2019
8b9c715
fully removed system user token usage
maxceem Mar 15, 2019
7c206b9
handle errors in seed metadata script so we are aware if it was succe…
maxceem Mar 15, 2019
346ec30
Merge pull request #269 from topcoder-platform/feature/remove-system-…
Mar 15, 2019
d6de5f2
Merge pull request #270 from topcoder-platform/feature/handle-errors-…
Mar 15, 2019
b624a4e
Merge pull request #273 from topcoder-platform/hotfix/null_userid_mem…
Mar 16, 2019
5438fb1
winning submission from challenge 30086428 - Topcoder Project Service…
maxceem Mar 16, 2019
ed3e625
skip linting for seed scripts - this should be fixed
maxceem Mar 16, 2019
7d5f1b2
Github issue#277,Changes required for project member invite update en…
Mar 18, 2019
ba0326b
Merge pull request #275 from topcoder-platform/feature/seed-projects
Mar 18, 2019
7cf5810
winning submission from challenge 30086547 - Topcoder Connect - Proje…
maxceem Mar 19, 2019
5b99768
use pshah_copilot as demo user for project with copilot
maxceem Mar 19, 2019
63c7d65
fix seed script to wait until created projects are indexed in ES befo…
maxceem Mar 19, 2019
b3d1cb8
fix m2m config
maxceem Mar 19, 2019
8a3c1fe
updated so copilots cannot access projects until they accept invitati…
maxceem Mar 19, 2019
6df79f8
fix seed projects script so it waits until ES index is done for previ…
maxceem Mar 19, 2019
d2dad3f
update README
maxceem Mar 19, 2019
4424e70
removed special permissions for copilots to view projects and remove …
maxceem Mar 19, 2019
c3b9645
Merge pull request #278 from topcoder-platform/feature/github_277_val…
Mar 19, 2019
b5f3e0f
check user roles on user update
gondzo Mar 25, 2019
73495fc
update tests
gondzo Mar 25, 2019
0975798
Merge pull request #281 from topcoder-platform/feature/inviteManagerP…
RishiRajSahu Mar 26, 2019
c917f1d
removed unused method
maxceem Mar 26, 2019
847c297
-Added testcases for account manager invites.
RishiRajSahu Mar 26, 2019
d111223
Update Dockerfile
Gunasekar-K Mar 26, 2019
027039b
Merge pull request #279 from topcoder-platform/feature/reviewed-proje…
Mar 27, 2019
a59ca81
submission from the final fix challenge 30087019 - Project template r…
maxceem Mar 27, 2019
74a3f24
fixed few spelling issues
maxceem Mar 27, 2019
898346c
Merge branch 'dev' into feature/project-templates-refactoring
maxceem Mar 27, 2019
4610277
Merge pull request #282 from topcoder-platform/feature/Adding_testcas…
RishiRajSahu Mar 28, 2019
b61edd1
winning submission from challenge 30087528 - Topcoder Project Service…
maxceem Mar 28, 2019
6e46212
reverted unrelated change
maxceem Mar 28, 2019
1774ebe
renamed variable `innerQuery` => `joinQuery`
maxceem Mar 28, 2019
4bf9163
Merge pull request #283 from topcoder-platform/feature/project-templa…
Mar 29, 2019
5683896
Merge pull request #284 from topcoder-platform/feature/query-improvem…
Mar 29, 2019
07ef7d6
submission from challenge 30087679 - refactored project.searchText DB…
maxceem Apr 1, 2019
ca7b895
Merge pull request #285 from topcoder-platform/feature/query-improvem…
Apr 4, 2019
e8df7e0
winning submission from challenge 30087746 - Topcoder Project Service…
maxceem Apr 5, 2019
38871a5
Merge pull request #287 from topcoder-platform/feature/project-templa…
Apr 5, 2019
c1478ab
Update build.sh
Gunasekar-K Apr 5, 2019
a8a64d5
Update deploy.sh
Gunasekar-K Apr 5, 2019
234a808
Update config.yml
Gunasekar-K Apr 5, 2019
1e0baa6
Update build.sh
Gunasekar-K Apr 5, 2019
38b63b0
update to entrypoint
nkumar-topcoder Apr 10, 2019
a05e117
STS update with S3 var
nkumar-topcoder Apr 10, 2019
35381b2
Update config.yml
nkumar-topcoder Apr 11, 2019
4fc2c27
Merge pull request #289 from topcoder-platform/dev-sts
nkumar-topcoder Apr 17, 2019
bad537f
winning submission from challenge 30088714 - Topcoder Connect - Add a…
maxceem Apr 19, 2019
c5514fd
Merge pull request #293 from topcoder-platform/feature/add-ons-flag
RishiRajSahu Apr 19, 2019
7323369
Revert "fully removed system user token usage"
maxceem Apr 19, 2019
bf86adf
Merge branch 'master' into dev
Apr 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ deploy_steps: &deploy_steps
./buildenv.sh -e $DEPLOY_ENV -b ${VAR_ENV}-tc-project-service-deployvar
source buildenvvar
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${VAR_ENV}-global-appvar,${VAR_ENV}-tc-project-service-appvar -i tc-project-service -p FARGATE

echo "======= Running Masterscript - deploy tc-project-service-consumers ==========="
if [ -e ${VAR_ENV}-tc-project-service-appvar.json ]; then sudo rm -vf ${VAR_ENV}-tc-project-service-appvar.json; fi
./buildenv.sh -e $DEPLOY_ENV -b ${VAR_ENV}-tc-project-service-consumers-deployvar
Expand Down
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
config/local.js
config/sample.local.js
config/mock.local.js
config/m2m.local.js
local/seed/
node_modules
dist
.ebextensions
Expand Down
171 changes: 104 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,123 @@ Microservice to manage CRUD operations for all things Projects.

### Note : Steps mentioned below are best to our capability as guide for local deployment, however, we expect from contributor, being a developer, to resolve run-time issues (e.g. OS and node version issues etc), if any.

### Local Development
## Local Development

* We use docker-compose for running dependencies locally. Instructions for Docker compose setup - https://docs.docker.com/compose/install/
### Requirements

* [docker-compose](https://docs.docker.com/compose/install/) - We use docker-compose for running dependencies locally.
* Nodejs 8.9.4 - consider using [nvm](https://github.com/creationix/nvm) or equivalent to manage your node version
* Install [libpg](https://www.npmjs.com/package/pg-native)
* Install node dependencies
`npm install`

* Start local services
```~/Projects/tc-projects-service
> cd local/
~/Projects/tc-projects-service/local
> docker-compose up
```
Copy config/sample.local.js as config/local.js, update the properties and according to your env setup

#### Database
Once you start your PostgreSQL database through docker, it will create a projectsdb.
*To create tables - note this will drop tables if they already exist*
```
NODE_ENV=development npm run sync:db
### Steps to run locally
1. Install node dependencies
```bash
npm install
```

* Run docker with dependant services
```bash
cd local/
docker-compose up
```
This will run several services locally:
- `postgres` - two instances: for app and for unit tests
- `elasticsearch`
- `rabbitmq`
- `mock-services` - mocks some Topcoder API

*NOTE: In production these dependencies / services are hosted & managed outside tc-projects-service.*

* Local config

There are two prepared configs:
- if you have M2M environment variables provided: `AUTH0_CLIENT_ID`, `AUTH0_CLIENT_SECRET`, `AUTH0_URL`, `AUTH0_AUDIENCE`, `AUTH0_PROXY_SERVER_URL` then use `config/m2m.local.js`
- otherwise use `config/mock.local.js`.

To apply any of these config copy it to `config/local.js`:

```bash
cp config/mock.local.js config/local.js
# or
cp config/m2m.local.js config/local.js
```

`config/local.js` has a prepared configuration which would replace values no matter what `NODE_ENV` value is.

**IMPORTANT** These configuration files assume that docker containers are run on domain `dockerhost`. Depend on your system you have to make sure that domain `dockerhost` points to the IP address of docker.
For example, you can add a the next line to your `/etc/hosts` file, if docker is run on IP `127.0.0.1`.
```
127.0.0.1 dockerhost
```
Alternatively, you may update `config/local.js` and replace `dockerhost` with your docker IP address.<br>
You may try using command `docker-machine ip` to get your docker IP, but it works not for all systems.

Explanation of configs:
- `config/mock.local.js` - Use local `mock-services` from docker to mock Identity and Member services instead of using deployed at Topcoder dev environment.
- `config/m2m.local.js` - Use Identity and Member services deployed at Topcoder dev environment. This can be used only if you have M2M environment variables (`AUTH0_CLIENT_ID`, `AUTH0_CLIENT_SECRET`, `AUTH0_URL`, `AUTH0_AUDIENCE`, `AUTH0_PROXY_SERVER_URL`) provided to access Topcoder DEV environment services.

* Create tables in DB
```bash
NODE_ENV=development npm run sync:db
```
This command will crate tables in `postgres` db.

*NOTE: this will drop tables if they already exist.*

* Sync ES indices
```bash
NODE_ENV=development npm run sync:es
```
Helper script to sync the indices and mappings with the elasticsearch.

*NOTE: This will first clear all the indices and than recreate them. So use with caution.*

* Run

**NOTE** If you use `config/m2m.local.js` config, you should set M2M environment variables before running the next command.
```bash
npm run start:dev
```
Runs the Project Service using nodemon, so it would be restarted after any of the files is updated.
The project service will be served on `http://localhost:8001`.

### Import sample metadata & projects
```bash
CONNECT_USER_TOKEN=<connect user token> npm run demo-data
```
This command will create sample metadata entries in the DB (duplicate what is currently in development environment).

#### Redis
Docker compose command will start a local redis instance as well. You should be able to connect to this instance using url `$(docker-machine ip):6379`
To retrieve data from DEV env we need to provide a valid user token. You may login to http://connect.topcoder-dev.com and find the Bearer token in the request headers using browser dev tools.

#### Elasticsearch
Docker compose includes elasticsearch instance as well. It will open ports 9200 & 9300 (kibana)
### Run Connect App with Project Service locally

#### Sync indices and mappings
To be able to run [Connect App](https://github.com/appirio-tech/connect-app) with the local setup of Project Service we have to do two things:
1. Configurate Connect App to use locally deployed Project service inside `connect-app/config/constants/dev.js` set

There is a helper script to sync the indices and mappings with the elasticsearch.
```js
PROJECTS_API_URL: 'http://localhost:8001'
```
2. Bypass token validation in Project Service.

Run `npm run sync:es` from the root of project to execute the script.
In `tc-project-service/node_modules/tc-core-library-js/lib/auth/verifier.js` add this to line 23:
```js
callback(undefined, decodedToken.payload);
return;
```
Connect App when making requests to the Project Service uses token retrieved from the Topcoder service deployed online. Project Service validates the token. For this purpose Project Service have to know the `secret` which has been used to generate the token. But we don't know the `secret` which is used by Topcoder for both DEV and PROD environment. So to bypass token validation we change these lines in the auth library.

> NOTE: This will first clear all the indices and than recreate them. So use with caution.
*NOTE: this change only let us bypass validation during local development process*.

**NOTE**: In production these dependencies / services are hosted & managed outside tc-projects-service.

#### Kafka
Kafka must be installed and configured prior starting the application.
Following topics must be created:
```
notifications.connect.project.updated
notifications.connect.project.files.updated
notifications.connect.project.team.updated
notifications.connect.project.plan.updated
notifications.connect.project.topic.created
notifications.connect.project.topic.updated
notifications.connect.project.post.created
notifications.connect.project.post.edited
```

New Kafka related configuration options has been introduced:
```
"kafkaConfig": {
"hosts": List of Kafka brokers. Default: localhost: 9092
"clientCert": SSL certificate
"clientCertKey": Certificate key
}
```
Environment variables:
- `KAFKA_HOSTS` - same as "hosts"
- `KAFKA_CLIENT_CERT` - same as "clientCert"
- `KAFKA_CLIENT_CERT_KEY` - same as "clientCertKey"
3. Restart both Connect App and Project Service if they were running.

### Test
```bash
npm run test
```
Tests are being executed with the `NODE_ENV` environment variable has a value `test` and `config/test.js` configuration is loaded.

Each of the individual modules/services are unit tested.

To run unit tests run `npm run test` from root of project.

While tests are being executed the `NODE_ENV` environment variable has a value `test` and `config/test.js` configuration is loaded. The default test configuration refers to `projectsdb_test` postgres database. So make sure that this database exists before running the tests. Since we are using docker-compose for local deployment change `local/docker-compose.yaml` postgres service with updated database name and re-create the containers.

```
// stop already executing containers if any
docker-compose stop -t 1
// clear the containers
docker-compose rm -f
// re-run the services with build flag
docker-compose up --build
```

#### JWT Authentication
Authentication is handled via Authorization (Bearer) token header field. Token is a JWT token. Here is a sample token that is valid for a very long time for a user with administrator role.
```
Expand All @@ -95,6 +129,9 @@ eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI
It's been signed with the secret 'secret'. This secret should match your entry in config/local.js. You can generate your own token using https://jwt.io

### Local Deployment

**NOTE: This part of README may contain inconsistencies and requires update. Don't follow it unless you know how to properly make configuration for these steps. It's not needed for regular development process.**

Build image:
`docker build -t tc_projects_services .`
Run image:
Expand All @@ -104,4 +141,4 @@ You may replace 172.17.0.1 with your docker0 IP.
You can paste **swagger.yaml** to [swagger editor](http://editor.swagger.io/) or import **postman.json** and **postman_environment.json** to verify endpoints.

#### Deploying without docker
If you don't want to use docker to deploy to localhost. You can simply run `npm run start` from root of project. This should start the server on default port `3000`.
If you don't want to use docker to deploy to localhost. You can simply run `npm run start:dev` from root of project. This should start the server on default port `8001`.
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
JQ="jq --raw-output --exit-status"

ENV=$1
AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION")
ACCOUNT_ID=$(eval "echo \$${ENV}_AWS_ACCOUNT_ID")
#AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION")
#ACCOUNT_ID=$(eval "echo \$${ENV}_AWS_ACCOUNT_ID")
AWS_REPOSITORY=$(eval "echo \$${ENV}_AWS_REPOSITORY")

build() {
docker build -t $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_REPOSITORY:$CIRCLE_SHA1 .
docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_REPOSITORY:$CIRCLE_SHA1 .
}

build
build
4 changes: 2 additions & 2 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
"inviteEmailSubject": "You are invited to Topcoder",
"inviteEmailSectionTitle": "Project Invitation",
"connectUrl":"https://connect.topcoder-dev.com",
"accountsAppUrl": "https://accounts.topcoder-dev.com"

"accountsAppUrl": "https://accounts.topcoder-dev.com",
"MAX_REVISION_NUMBER": 100
}
35 changes: 35 additions & 0 deletions config/m2m.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// force using test.json for unit tests

let config;
if (process.env.NODE_ENV === 'test') {
config = require('./test.json');
} else {
config = {
identityServiceEndpoint: "https://api.topcoder-dev.com/v3/",
authSecret: 'secret',
authDomain: 'topcoder-dev.com',
logLevel: 'debug',
captureLogs: 'false',
logentriesToken: '',
rabbitmqURL: 'amqp://dockerhost:5672',
fileServiceEndpoint: 'https://api.topcoder-dev.com/v3/files/',
directProjectServiceEndpoint: 'https://api.topcoder-dev.com/v3/direct',
connectProjectsUrl: 'https://connect.topcoder-dev.com/projects/',
memberServiceEndpoint: 'https://api.topcoder-dev.com/v3/members',
dbConfig: {
masterUrl: 'postgres://coder:mysecretpassword@dockerhost:5432/projectsdb',
maxPoolSize: 50,
minPoolSize: 4,
idleTimeout: 1000,
},
elasticsearchConfig: {
host: 'dockerhost:9200',
// target elasticsearch 2.3 version
apiVersion: '2.3',
indexName: 'projects',
docType: 'projectV4'
},
whitelistedOriginsForUserIdAuth: "[\"\"]",
};
}
module.exports = config;
File renamed without changes.
3 changes: 2 additions & 1 deletion config/test.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"AUTH_SECRET": "secret",
"MAX_REVISION_NUMBER": 2,
"logLevel": "debug",
"captureLogs": "false",
"logentriesToken": "",
Expand All @@ -14,7 +15,7 @@
"rabbitmqUrl": "amqp://localhost:5672",
"connectProjectsUrl": "https://local.topcoder-dev.com/projects/",
"dbConfig": {
"masterUrl": "postgres://coder:mysecretpassword@localhost:5432/projectsdb_test",
"masterUrl": "postgres://coder:mysecretpassword@localhost:5433/projectsdb_test",
"maxPoolSize": 50,
"minPoolSize": 4,
"idleTimeout": 1000
Expand Down
12 changes: 6 additions & 6 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ JQ="jq --raw-output --exit-status"

ENV=$1
COUNTER_LIMIT=20
ACCOUNT_ID=$(eval "echo \$${ENV}_AWS_ACCOUNT_ID")
AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION")
#ACCOUNT_ID=$(eval "echo \$${ENV}_AWS_ACCOUNT_ID")
#AWS_REGION=$(eval "echo \$${ENV}_AWS_REGION")
AWS_ECS_CONTAINER_NAME="tc-project-service"
AWS_REPOSITORY=$(eval "echo \$${ENV}_AWS_REPOSITORY")
AWS_ECS_CLUSTER=$(eval "echo \$${ENV}_AWS_ECS_CLUSTER")
Expand Down Expand Up @@ -283,12 +283,12 @@ make_task_def(){
INVITE_EMAIL_SUBJECT=$(eval "echo \$${ENV}_INVITE_EMAIL_SUBJECT")
INVITE_EMAIL_SECTION_TITLE=$(eval "echo \$${ENV}_INVITE_EMAIL_SECTION_TITLE")

task_def=$(printf "$task_template" $1 $ACCOUNT_ID $ACCOUNT_ID $AWS_ECS_CONTAINER_NAME $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $2 $3 $4 $NODE_ENV $ENABLE_FILE_UPLOAD $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $API_VERSION $AWS_REGION $AUTH_DOMAIN $AUTH_SECRET $VALID_ISSUERS $DB_MASTER_URL $MEMBER_SERVICE_ENDPOINT $IDENTITY_SERVICE_ENDPOINT $BUS_API_URL $MESSAGE_SERVICE_URL $SYSTEM_USER_CLIENT_ID $SYSTEM_USER_CLIENT_SECRET $PROJECTS_ES_URL $PROJECTS_ES_INDEX_NAME $RABBITMQ_URL $DIRECT_PROJECT_SERVICE_ENDPOINT $FILE_SERVICE_ENDPOINT $CONNECT_PROJECTS_URL $CONNECT_URL $ACCOUNTS_APP_URL $SEGMENT_ANALYTICS_KEY "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL "$AUTH0_PROXY_SERVER_URL" "$EMAIL_INVITE_FROM_NAME" "$EMAIL_INVITE_FROM_EMAIL" "$INVITE_EMAIL_SUBJECT" "$INVITE_EMAIL_SECTION_TITLE" $PORT $PORT $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV)
task_def=$(printf "$task_template" $1 $AWS_ACCOUNT_ID $AWS_ACCOUNT_ID $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $2 $3 $4 $NODE_ENV $ENABLE_FILE_UPLOAD $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $API_VERSION $AWS_REGION $AUTH_DOMAIN $AUTH_SECRET $VALID_ISSUERS $DB_MASTER_URL $MEMBER_SERVICE_ENDPOINT $IDENTITY_SERVICE_ENDPOINT $BUS_API_URL $MESSAGE_SERVICE_URL $SYSTEM_USER_CLIENT_ID $SYSTEM_USER_CLIENT_SECRET $PROJECTS_ES_URL $PROJECTS_ES_INDEX_NAME $RABBITMQ_URL $DIRECT_PROJECT_SERVICE_ENDPOINT $FILE_SERVICE_ENDPOINT $CONNECT_PROJECTS_URL $CONNECT_URL $ACCOUNTS_APP_URL $SEGMENT_ANALYTICS_KEY "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL "$AUTH0_PROXY_SERVER_URL" "$EMAIL_INVITE_FROM_NAME" "$EMAIL_INVITE_FROM_EMAIL" "$INVITE_EMAIL_SUBJECT" "$INVITE_EMAIL_SECTION_TITLE" $PORT $PORT $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV)
}

push_ecr_image(){
eval $(aws ecr get-login --region $AWS_REGION --no-include-email)
docker push $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$1:$CIRCLE_SHA1
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$1:$CIRCLE_SHA1
}

register_definition() {
Expand Down Expand Up @@ -319,11 +319,11 @@ check_service_status() {
echo "$servicestatus"
}

configure_aws_cli
#configure_aws_cli
push_ecr_image $AWS_REPOSITORY
deploy_cluster $AWS_ECS_SERVICE "npm" "run" "start"

deploy_cluster $AWS_ECS_SERVICE_CONSUMERS "npm" "run" "startKafkaConsumers"

check_service_status $AWS_ECS_SERVICE
check_service_status $AWS_ECS_SERVICE_CONSUMERS
check_service_status $AWS_ECS_SERVICE_CONSUMERS
8 changes: 8 additions & 0 deletions local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ services:
- POSTGRES_PASSWORD=mysecretpassword
- POSTGRES_USER=coder
- POSTGRES_DB=projectsdb
db_test:
image: "postgres:9.5"
ports:
- "5433:5432"
environment:
- POSTGRES_PASSWORD=mysecretpassword
- POSTGRES_USER=coder
- POSTGRES_DB=projectsdb_test
esearch:
image: "elasticsearch:2.3"
ports:
Expand Down
21 changes: 21 additions & 0 deletions local/mock-services/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ server.get('/v3/members/_search', (req, res) => {
res.status(200).json(response);
});


// add filter route for project members
server.get('/users', (req, res) => {
const filter = req.query.filter.replace('%2520', ' ').replace('%20', ' ').replace('%3D', ' ');
const allEmails = filter.split('=')[1];
const emails = allEmails.split('OR');
const cloned = _.cloneDeep(members);
const response = {
id: 'res1',
result: {
success: true,
status: 200,
},
};
const users = _.filter(cloned, single => _.includes(emails, single.result.content.email));
response.result.content = _.map(users,
single => _.assign(single.result.content, { id: single.result.content.userId }));
response.result.metadata = { totalCount: response.result.content.length };
res.status(200).json(response);
});

// add additional search route for project members
server.get('/roles', (req, res) => {
const filter = _.isString(req.query.filter) ?
Expand Down
13 changes: 13 additions & 0 deletions local/seed/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const seedMetadata = require('./seedMetadata');
const seedProjects = require('./seedProjects');

const targetUrl = 'http://localhost:8001/v4/';
const token =
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiYWRtaW5pc3RyYXRvciJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoidGVzdDEiLCJleHAiOjI1NjMwNzY2ODksInVzZXJJZCI6IjQwMDUxMzMzIiwiaWF0IjoxNDYzMDc2MDg5LCJlbWFpbCI6InRlc3RAdG9wY29kZXIuY29tIiwianRpIjoiYjMzYjc3Y2QtYjUyZS00MGZlLTgzN2UtYmViOGUwYWU2YTRhIn0.wKWUe0-SaiFVN-VR_-GwgFlvWaDkSbc8H55ktb9LAVw';

async function seed() {
await seedMetadata(targetUrl, token);
await seedProjects(targetUrl, token);
}

seed().then(() => process.exit());
Loading