Skip to content
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

Newman Automation integration with CircleCI #120

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
74 changes: 69 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
version: 2
version: 2.1
parameters:
run_automatedtesting:
default: false
type: boolean
run_basedeployment:
default: true
type: boolean
defaults: &defaults
docker:
- image: circleci/python:2.7-stretch-browsers
install_dependency: &install_dependency
name: Installation of build and deployment dependencies.
command: |
sudo apt install jq
sudo pip install awscli --upgrade
sudo pip install docker-compose
sudo apt install jq python3-pip
sudo pip3 install awscli --upgrade

install_deploysuite: &install_deploysuite
name: Installation of install_deploysuite.
Expand Down Expand Up @@ -42,14 +48,25 @@ builddeploy_steps: &builddeploy_steps
source buildenvvar
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${APP_ENV}-global-appvar,${DEPLOY_ENV}-groups-api-appvar -i groups-api
#./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s groups-api -i groups-api
#testing code changes
if [[ true ]]; then
./buildenv.sh -e $DEPLOY_ENV -b ${APP_ENV}-qa-v1-appvar
source buildenvvar
echo "Making circle ci curl call to launch new job"
curl --request POST \
--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
--header "Circle-Token: ${QA_USER_TOKEN}" \
--header 'content-type: application/json' \
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_automatedtesting":true , "run_basedeployment": false}}'
fi

jobs:
# Build & Deploy against development backend
"build-dev":
<<: *defaults
environment:
DEPLOY_ENV: "DEV"
APP_ENV: "dev"
APP_ENV: "dev"
steps: *builddeploy_steps

# Build & Deploy against production backend
Expand All @@ -60,9 +77,42 @@ jobs:
APP_ENV: "prod"
steps: *builddeploy_steps

"Run-Newman-Test":
docker:
- image: circleci/node:12
environment:
DEPLOY_ENV: "DEV"
LOGICAL_ENV: "dev"
APPNAME: "groups-api"
- image: tray/dynamodb-local
command: "-inMemory -port 7777"
- image: elasticsearch:6.8.13
environment:
discovery.type: "single-node"
steps:
- checkout
- setup_remote_docker
- run: *install_dependency
- run: *install_deploysuite
- run:
name: 'newman test'
no_output_timeout: 30m
command: |
./awsconfiguration.sh $DEPLOY_ENV
source awsenvconf
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-qa-appvar
source buildenvvar
npm install --loglevel verbose
npm run test:newman:clear
npm run test:newman
npm run test:newman:clear
- store_artifacts:
path: ./newman

workflows:
version: 2
build:
when: << pipeline.parameters.run_basedeployment >>
jobs:
# Development builds are executed on "develop" branch only.
- "build-dev":
Expand All @@ -78,3 +128,17 @@ workflows:
branches:
only:
- master

testingflow:
when: << pipeline.parameters.run_automatedtesting >>
jobs:
- Hold [Performance-Testing]:
type: approval
- "Run-Newman-Test":
context : org-global
requires:
- Hold [Performance-Testing]
filters:
branches:
only:
- develop
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
newman/

# Runtime data
pids
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,37 @@ The following parameters can be set in config files or in env variables:
- App will be running at `http://localhost:3000`
- Application can be run in development mode using the command `npm run dev`

## 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:

- AUTH_V2_URL: The auth v2 url
- AUTH_V2_CLIENT_ID: The auth v2 client id
- AUTH_V3_URL: The auth v3 url
- ADMIN_CREDENTIALS_USERNAME: The user's username with admin role
- ADMIN_CREDENTIALS_PASSWORD: The user's password with admin role
- USER_CREDENTIALS_USERNAME: The user's username with user role
- USER_CREDENTIALS_PASSWORD: The user's password with user role

### Prepare

- Start Local Neo4j.
- Various config parameters should be properly set.

### Running E2E tests with Postman

`Start` the app server before running e2e tests. You may need to set the env variables by calling `source env.sh` before calling `NODE_ENV=test npm start`.

To run postman e2e tests run:

```bash
npm run test:newman
```

## Heroku deployment
- git init
- git add .
Expand Down
8 changes: 5 additions & 3 deletions config/default.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* The configuration file.
*/

require('dotenv').config()
module.exports = {
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
PORT: process.env.PORT || 3000,
// it is configured to be empty at present, but may add prefix like '/api/v5'
API_PREFIX: process.env.API_PREFIX || '',
GRAPH_DB_URI: process.env.GRAPH_DB_URI || process.env.GRAPHENEDB_BOLT_URL || 'bolt://localhost:7687',
GRAPH_DB_USER: process.env.GRAPH_DB_USER || process.env.GRAPHENEDB_BOLT_USER || 'neo4j',
GRAPH_DB_PASSWORD: process.env.GRAPH_DB_PASSWORD || process.env.GRAPHENEDB_BOLT_PASSWORD || '123456',
GRAPH_DB_PASSWORD: process.env.GRAPH_DB_PASSWORD || process.env.GRAPHENEDB_BOLT_PASSWORD || 'password',
AUTH_SECRET: process.env.AUTH_SECRET || 'mysecret',
VALID_ISSUERS: process.env.VALID_ISSUERS
? process.env.VALID_ISSUERS.replace(/\\"/g, '')
Expand Down Expand Up @@ -52,5 +52,7 @@ module.exports = {
MEMBERSHIP_TYPES: {
Group: 'group',
User: 'user'
}
},

AUTOMATED_TESTING_NAME_PREFIX: process.env.AUTOMATED_TESTING_NAME_PREFIX || 'POSTMANE2E-'
}
19 changes: 19 additions & 0 deletions config/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* The configuration file.
*/

module.exports = {
WAIT_TIME: 10,
AUTH_V2_URL: process.env.AUTH_V2_URL || 'https://topcoder-dev.auth0.com/oauth/ro',
AUTH_V2_CLIENT_ID: process.env.AUTH_V2_CLIENT_ID || '',
AUTH_V3_URL: process.env.AUTH_V3_URL || 'https://api.topcoder-dev.com/v3/authorizations',
ADMIN_CREDENTIALS_USERNAME: process.env.ADMIN_CREDENTIALS_USERNAME || '',
ADMIN_CREDENTIALS_PASSWORD: process.env.ADMIN_CREDENTIALS_PASSWORD || '',
USER_CREDENTIALS_USERNAME: process.env.USER_CREDENTIALS_USERNAME || '',
USER_CREDENTIALS_PASSWORD: process.env.USER_CREDENTIALS_PASSWORD || '',
MANAGER_CREDENTIALS_USERNAME: process.env.MANAGER_CREDENTIALS_USERNAME || '',
MANAGER_CREDENTIALS_PASSWORD: process.env.MANAGER_CREDENTIALS_PASSWORD || '',
COPILOT_CREDENTIALS_USERNAME: process.env.COPILOT_CREDENTIALS_USERNAME || '',
COPILOT_CREDENTIALS_PASSWORD: process.env.COPILOT_CREDENTIALS_PASSWORD || '',
AUTOMATED_TESTING_REPORTERS_FORMAT: process.env.AUTOMATED_TESTING_REPORTERS_FORMAT || ['cli', 'html']
}
21 changes: 21 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

export AUTH0_CLIENT_ID=

export AUTH0_CLIENT_SECRET=

export AUTH0_AUDIENCE=

export AUTH_V2_URL=

export AUTH_V2_CLIENT_ID=

export AUTH_V3_URL=

export ADMIN_CREDENTIALS_USERNAME=

export ADMIN_CREDENTIALS_PASSWORD=

export USER_CREDENTIALS_USERNAME=

export USER_CREDENTIALS_PASSWORD=
Loading