Skip to content

Commit

Permalink
Merge pull request #812 from bcgov/release/1.35.0
Browse files Browse the repository at this point in the history
Merged PR-812
  • Loading branch information
bcgov-csnr-cd authored Jul 18, 2018
2 parents 7151cc4 + 707dc74 commit aa44333
Show file tree
Hide file tree
Showing 205 changed files with 47,521 additions and 32,342 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ webpack-stats.json
api-tests/.envrc
functional-tests/.envrc
app/.env
app/.secret_env

# PyInstaller and Pip install files
# Usually these files are written by a python script from a template
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ for(String envKeyName: context.env.keySet() as String[]){
stage('Cleanup') {

def inputResponse = null
String mergeMethod=isCI?'squash':'merge'
String mergeMethod='merge'

waitUntil {
boolean isDone=false
Expand Down
38 changes: 38 additions & 0 deletions api-tests/local_wells.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
# Usage:
# - Set env variables (choose any username and password):
# export GWELLS_API_BASE_URL="http://localhost:8000/gwells/registries"
# export GWELLS_API_TEST_USER="testuser"
# export GWELLS_API_TEST_PASSWORD="secret"
# export GWELLS_API_TEST_AUTH_SERVER=""
# export GWELLS_API_TEST_CLIENT_ID=""
# export GWELLS_API_TEST_CLIENT_SECRET"""
# - Create Django test user (requires env variables from previous step):
# python manage.py createtestuser
# - Install newman:
# npm install -g newman
# - Run script:
# ./local_newman.sh


ENV_VARS=(
"GWELLS_API_TEST_USER"
"GWELLS_API_TEST_PASSWORD"
"GWELLS_API_BASE_URL"
"GWELLS_API_TEST_AUTH_SERVER"
"GWELLS_API_TEST_CLIENT_ID"
"GWELLS_API_TEST_CLIENT_SECRET"
)

for env_var in ${ENV_VARS[@]}
do
if [ -z ${!env_var+x} ]; then
echo "$env_var is unset"
exit
fi
done

echo "Remember to install newman (npm install -g newman) and set GWELLS_API_TEST_USER,"
echo "GWELLS_API_TEST_PASSWORD, GWELLS_API_BASE_URL and Keycloak credentials"
newman run ./wells_api_tests.json --global-var test_user=$GWELLS_API_TEST_USER --global-var test_password=$GWELLS_API_TEST_PASSWORD --global-var base_url=$GWELLS_API_BASE_URL --global-var auth_server=$GWELLS_API_TEST_AUTH_SERVER --global-var client_id=$GWELLS_API_TEST_CLIENT_ID --global-var client_secret=$GWELLS_API_TEST_CLIENT_SECRET
4 changes: 2 additions & 2 deletions api-tests/registries_api_tests.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "9b0a045a-2d4d-487d-9a62-c98e6cc5e851",
"_postman_id": "1ab0d6b2-a821-4bd5-be73-ef33597c8aa9",
"name": "GWELLS API remote",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
Expand Down Expand Up @@ -1298,7 +1298,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"first_name\": \"Bobby\",\n \"surname\": \"Driller\",\n \"registrations\": [\n \t{\n \t\t\"registries_activity\": \"DRILL\", \n \t\t\"status\": \"ACTIVE\",\n \t\t\"organization\": \"{{created_guid}}\",\n \t\t\"applications\": [\n \t\t{\n \t\t\t\"subactivity\": {\n \t\t\t\t\"registries_subactivity_code\": \"WATER\"\n \t\t\t}, \n \t\t\t\"primary_certificate\": {\n \t\t\t\t\"acc_cert_guid\": \"28bf8730-dbb7-4218-8e9f-06bd51f60161\"\n \t\t\t}, \n \t\t\t\"primary_certificate_no\": \"12345\",\n \t\t\t\"current_status\": {\"code\": \"P\"},\n \t\t\t\"application_recieved_date\": \"2018-05-02\",\n \t\t\t\"proof_of_age\": { \"code\": \"PASSPORT\"}\n \t\t},\n \t\t{\n \t\t\t\"subactivity\": {\n \t\t\t\t\"registries_subactivity_code\": \"WATER\"\n \t\t\t},\n \t\t\t\"primary_certificate\": {\n \t\t\t\t\"acc_cert_guid\": \"28bf8730-dbb7-4218-8e9f-06bd51f60161\"\n \t\t\t},\n \t\t\t\"primary_certificate_no\": \"67890\",\n \t\t\t\"current_status\": {\"code\" : \"P\"}\n \t\t}\n\t\t]\n }],\n \"contact_info\": [{\"contact_tel\": \"555-1234\"}]\n}\n"
"raw": "{\n \"first_name\": \"Bobby\",\n \"surname\": \"Driller\",\n \"contact_tel\": \"(555) 555-1234\",\n \"contact_email\": \"[email protected]\",\n \"registrations\": [\n \t{\n \t\t\"registries_activity\": \"DRILL\", \n \t\t\"status\": \"ACTIVE\",\n \t\t\"organization\": \"{{created_guid}}\",\n \t\t\"applications\": [\n \t\t{\n \t\t\t\"subactivity\": {\n \t\t\t\t\"registries_subactivity_code\": \"WATER\"\n \t\t\t}, \n \t\t\t\"primary_certificate\": {\n \t\t\t\t\"acc_cert_guid\": \"28bf8730-dbb7-4218-8e9f-06bd51f60161\"\n \t\t\t}, \n \t\t\t\"primary_certificate_no\": \"12345\",\n \t\t\t\"current_status\": {\"code\": \"P\"},\n \t\t\t\"application_recieved_date\": \"2018-05-02\",\n \t\t\t\"proof_of_age\": { \"code\": \"PASSPORT\"}\n \t\t},\n \t\t{\n \t\t\t\"subactivity\": {\n \t\t\t\t\"registries_subactivity_code\": \"WATER\"\n \t\t\t},\n \t\t\t\"primary_certificate\": {\n \t\t\t\t\"acc_cert_guid\": \"28bf8730-dbb7-4218-8e9f-06bd51f60161\"\n \t\t\t},\n \t\t\t\"primary_certificate_no\": \"67890\",\n \t\t\t\"current_status\": {\"code\" : \"P\"}\n \t\t}\n\t\t]\n }]\n}\n"
},
"url": {
"raw": "{{base_url}}/api/v1/drillers/?format=json",
Expand Down
257 changes: 257 additions & 0 deletions api-tests/wells_api_tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
{
"info": {
"_postman_id": "7eaaeefe-0668-4ab7-81c0-1309fea10926",
"name": "GWELLS Well API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Authentication",
"description": "",
"item": [
{
"name": "Log in",
"event": [
{
"listen": "test",
"script": {
"id": "46c51db8-8a25-45d5-941f-f55f682ab9b6",
"type": "text/javascript",
"exec": [
"var jsonData = pm.response.json()",
"pm.environment.set(\"token\", jsonData.access_token);",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.expect(pm.response.code, \"Login was not successful\").to.equal(200);",
"})",
"",
"pm.test(\"A token was returned\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.access_token, \"a token was not returned\").to.be.ok;",
" pm.expect(jsonData.access_token.length).to.be.above(36);",
"});",
""
]
}
}
],
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "{{test_user}}",
"type": "text"
},
{
"key": "password",
"value": "{{test_password}}",
"type": "text"
},
{
"key": "grant_type",
"value": "password",
"type": "text"
},
{
"key": "client_id",
"value": "{{client_id}}",
"type": "text"
},
{
"key": "client_secret",
"value": "{{client_secret}}",
"type": "text"
}
]
},
"url": {
"raw": "{{auth_server}}",
"host": [
"{{auth_server}}"
]
},
"description": "Get token (log in)"
},
"response": []
}
]
},
{
"name": "Wells",
"description": "",
"item": [
{
"name": "Well list",
"event": [
{
"listen": "test",
"script": {
"id": "20837dbe-0390-4709-b8dc-4ac3b22153f4",
"type": "text/javascript",
"exec": [
"var jsonData = pm.response.json()",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.expect(pm.response.code).to.equal(200);",
"})",
""
]
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "JWT {{token}}"
}
],
"body": {},
"url": {
"raw": "{{base_url}}/api/v1/wells/?format=json",
"host": [
"{{base_url}}"
],
"path": [
"api",
"v1",
"wells",
""
],
"query": [
{
"key": "format",
"value": "json"
}
]
},
"description": "Request a list of wells"
},
"response": []
}
]
},
{
"name": "Activity Submissions",
"description": "",
"item": [
{
"name": "Submission list",
"event": [
{
"listen": "test",
"script": {
"id": "20837dbe-0390-4709-b8dc-4ac3b22153f4",
"type": "text/javascript",
"exec": [
"var jsonData = pm.response.json()",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.expect(pm.response.code).to.equal(200);",
"})",
""
]
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "JWT {{token}}"
}
],
"body": {},
"url": {
"raw": "{{base_url}}/api/v1/submissions/?format=json",
"host": [
"{{base_url}}"
],
"path": [
"api",
"v1",
"submissions",
""
],
"query": [
{
"key": "format",
"value": "json"
}
]
},
"description": "Request a list of wells"
},
"response": []
},
{
"name": "Submission report",
"event": [
{
"listen": "test",
"script": {
"id": "daccd2c4-471a-402f-b715-51702e3aa4e5",
"type": "text/javascript",
"exec": [
"var jsonData = pm.response.json();",
"",
"// pm.test(\"Status code is 200\", function () {",
"// pm.expect(pm.response.code).to.equal(200);",
"//})",
""
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "JWT {{token}}"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{base_url}}/api/v1/submissions/?format=json",
"host": [
"{{base_url}}"
],
"path": [
"api",
"v1",
"submissions",
""
],
"query": [
{
"key": "format",
"value": "json"
}
]
},
"description": "Request a list of wells"
},
"response": []
}
]
}
]
}
3 changes: 3 additions & 0 deletions app/.envrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
layout python3

# Set all required environment variables.
export DJANGO_LOG_LEVEL=DEBUG
export DATABASE_SERVICE_NAME=localhost
export LOCALHOST_SERVICE_HOST=localhost
export BASEURL=http://127.0.0.1:8000/
Expand All @@ -44,6 +45,8 @@ export REQUIRE_ENV_VARIABLES=True
export S3_HOST=s3.ca-central-1.amazonaws.com
export S3_ROOT_BUCKET=gwells-docs

dotenv .secret_env

# Check if requirements.txt has changed
echo "Checking if requirements has changed..."
read current_md5 _ <<< $(cat requirements.txt | md5 | awk '{print $1}')
Expand Down
1 change: 1 addition & 0 deletions app/.s2i/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DISABLE_MIGRATE=1
2 changes: 1 addition & 1 deletion app/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ The administrator account details are recorded as an OpenShift Secret (i.e. PROD
Currently, these values are used as part of the automatic step to create the admin account:
`python manage.py post-deploy`

This is currently in the ./scripts/post-deploy.sh script and called in the mid-lifecycle hook; this will be moved into the Pipeline, at the approate Stage.
This is currently in the ./scripts/gwells-deploy.sh script and called in the mid-lifecycle hook; this will be moved into the Pipeline, at the approate Stage.
10 changes: 5 additions & 5 deletions app/database/oc-dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ SAVE_TO=${2:-./${PROJECT}-$( date +%Y-%m-%d-%H%M )}
# APP and mode variables
#
APP_NAME=${APP_NAME:-gwells}
DB_NAME=${DB_NAME:-${APP_NAME}}
KEEP_APP_ONLINE=${KEEP_APP_ONLINE:-false}
KEEP_APP_ONLINE=${KEEP_APP_ONLINE:-true}


# Show message if passed any params
Expand Down Expand Up @@ -83,11 +82,13 @@ fi

# Identify database and take a backup
#
POD_DB=$( oc get pods -n ${PROJECT} -o name | grep -Eo "postgresql-[0-9]+-[[:alnum:]]+" )
POD_DB=$( oc get pods -n ${PROJECT} -o name | grep -Eo "gwells-pgsql-(test|prod)-[[:digit:]]+-[[:alnum:]]+" )
SAVE_FILE=$( basename ${SAVE_TO} )
SAVE_PATH=$( dirname ${SAVE_TO} )
mkdir -p ${SAVE_PATH}
oc exec ${POD_DB} -n ${PROJECT} -- /bin/bash -c 'pg_dump -Fc '${DB_NAME}' > /tmp/'${SAVE_FILE}
oc exec ${POD_DB} -n ${PROJECT} -- /bin/bash -c \
'pg_dump -U ${POSTGRESQL_USER} -d ${POSTGRESQL_DATABASE} -Fc \
--no-privileges --no-tablespaces --schema=public > /tmp/'${SAVE_FILE}
oc rsync ${POD_DB}:/tmp/${SAVE_FILE} ${SAVE_PATH} -n ${PROJECT} --progress=true --no-perms=true
oc exec ${POD_DB} -n ${PROJECT} -- /bin/bash -c 'rm /tmp/'${SAVE_FILE}

Expand All @@ -105,7 +106,6 @@ fi
# Summarize
#
echo
echo "DB: ${DB_NAME}"
echo "Size: $( du -h ${SAVE_TO} | awk '{ print $1 }' )"
echo "Name: ${SAVE_TO}"
echo
Loading

0 comments on commit aa44333

Please sign in to comment.