Skip to content

Commit 3aacb82

Browse files
Merge pull request #115 from topcoder-platform/develop
Prod deployment
2 parents 4d86fc5 + f597192 commit 3aacb82

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

.circleci/config.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ parameters:
88
type: boolean
99
defaults: &defaults
1010
docker:
11-
- image: circleci/python:2.7-stretch-browsers
11+
- image: cimg/python:3.11.0-browsers
1212
install_dependency: &install_dependency
1313
name: Installation of build and deployment dependencies.
1414
command: |
15+
sudo apt update
1516
sudo apt install jq python3-pip
16-
sudo pip3 install awscli --upgrade
1717
# sudo pip install docker-compose
18+
sudo pip3 install awscli --upgrade
19+
sudo pip3 install docker-compose
1820
install_deploysuite: &install_deploysuite
1921
name: Installation of install_deploysuite.
2022
command: |
@@ -23,10 +25,10 @@ install_deploysuite: &install_deploysuite
2325
cp ./../buildscript/buildenv.sh .
2426
cp ./../buildscript/awsconfiguration.sh .
2527
restore_cache_settings_for_build: &restore_cache_settings_for_build
26-
key: docker-node-modules-{{ checksum "package-lock.json" }}
28+
key: docker-node-modules-{{ checksum "yarn.lock" }}
2729

2830
save_cache_settings: &save_cache_settings
29-
key: docker-node-modules-{{ checksum "package-lock.json" }}
31+
key: docker-node-modules-{{ checksum "yarn.lock" }}
3032
paths:
3133
- node_modules
3234

@@ -95,12 +97,13 @@ jobs:
9597
- run: *install_deploysuite
9698
- run:
9799
name: 'newman test'
100+
no_output_timeout: 30m
98101
command: |
99102
./awsconfiguration.sh $DEPLOY_ENV
100103
source awsenvconf
101104
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-qa-appvar
102105
source buildenvvar
103-
npm i
106+
npm install --loglevel verbose
104107
cd mock
105108
(npm run mock-challenge-api&)
106109
(NODE_ENV=test npm start&)

Verification.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,5 @@ Iteration 4/4
9494

9595
Then you can run `npm run test:newman:clear` to delete all testing data by above postman tests.
9696
If 'socket hang up' appears while running the `npm run test:newman`. You can increase the `WAIT_TIME` from the `default/test.js`.
97-
Then run `npm run test:newman:clear` before calling `npm run test:newman` again.
97+
Then run `npm run test:newman:clear` before calling `npm run test:newman` again.
98+

app-constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const UserRoles = {
1010
}
1111

1212
const ChallengeStatuses = {
13-
Completed: 'Completed'
13+
Completed: 'Completed',
14+
Active: 'Active'
1415
}
1516

1617
module.exports = {

config/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ module.exports = {
1717
COPILOT_CREDENTIALS_PASSWORD: process.env.COPILOT_CREDENTIALS_PASSWORD || '',
1818
USER_CREDENTIALS_USERNAME: process.env.USER_CREDENTIALS_USERNAME || '',
1919
USER_CREDENTIALS_PASSWORD: process.env.USER_CREDENTIALS_PASSWORD || '',
20+
MANAGER_CREDENTIALS_USERNAME: process.env.MANAGER_CREDENTIALS_USERNAME || '',
21+
MANAGER_CREDENTIALS_PASSWORD: process.env.MANAGER_CREDENTIALS_PASSWORD || '',
2022
AUTOMATED_TESTING_REPORTERS_FORMAT: process.env.AUTOMATED_TESTING_REPORTERS_FORMAT || ['cli', 'html']
2123
}

src/services/ResourceService.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ async function init (currentUser, challengeId, resource, isCreated) {
231231
throw new errors.BadRequestError('Cannot delete resources of a completed challenge!')
232232
}
233233

234+
if (_.get(challenge, 'status') !== constants.ChallengeStatuses.Active && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) {
235+
throw new errors.BadRequestError(`Cannot create submitter resource on challenge with status ${_.get(challenge, 'status')}`)
236+
}
237+
234238
// Prevent from creating more than 1 submitter resources on tasks
235239
if (_.get(challenge, 'task.isTask', false) && isCreated && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) {
236240
const existing = await getResources(currentUser, challengeId, config.SUBMITTER_RESOURCE_ROLE_ID, null, null, 1, 1)

test/postman/newman.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,17 @@ async function clearTestData () {
183183
/**
184184
* Run the postman tests.
185185
*/
186-
apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'),
187-
require.resolve('./resource-api.postman_environment.json')).then(async () => {
188-
logger.info('newman test completed!')
189-
await clearTestData()
190-
}).catch(async (err) => {
191-
logger.logFullError(err)
192-
193-
// Only calling the clean up function when it is not validation error.
194-
if (err.name !== 'ValidationError') {
186+
clearTestData().then(() => {
187+
apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'),
188+
require.resolve('./resource-api.postman_environment.json')).then(async () => {
189+
logger.info('newman test completed!')
195190
await clearTestData()
196-
}
191+
}).catch(async (err) => {
192+
logger.logFullError(err)
193+
194+
// Only calling the clean up function when it is not validation error.
195+
if (err.name !== 'ValidationError') {
196+
await clearTestData()
197+
}
198+
})
197199
})

0 commit comments

Comments
 (0)