We use Openshift in our environment. We recommend you setup an openshift (or minishift) for this project. You can then use our build / deployment configs found in the openshift directory.
Jenkins Build process includes:
- SonarQube
- Building our Flask/Python API
- Building our Vue FrontEnd and copying the output to CADDY Webserver
- Postman tests
- Zap Vulnerability tests
If you want to just try out the application, here are some instructions to get it running on Ubuntu (I used Windows 10 WSL Ubuntu):
- Note we do not use RabbitMQ for local testing but this is used to manage multiple pods and syncing messages between them.
sudo apt-get install mysql-serversudo service mysql startsudo mysql --defaults-file=/etc/mysql/debian.cnfCREATE USER 'demo'@'localhost' IDENTIFIED BY 'demo';GRANT ALL PRIVILEGES ON *.* TO 'demo'@'localhost';CREATE DATABASE IF NOT EXISTS queue_management;FLUSH PRIVILEGES;
git clone https://github.com/bcgov/queue-management.gitexport DOCKER_HOST=tcp://0.0.0.0:2375cd queue-management/keycloak-local-testserverchmod +x *.shdocker build -t keycloak .docker run -it --name keycloak -p 8085:8080 keycloak
You should be able to login in with admin/admin on http://localhost:8085/auth
Ensure you have python 3. I also had to install: gcc, python3-venv, libmysqlclient-dev and python3-dev installed.
python3 -m venv envsource env/bin/activatecd queue-management/apipip3 install -r requirements.txt
cd queue-managementcp documentation/demo-files/secrets.json api/client_secrets/secrets.jsoncp documentation/demo-files/keycloak-local.json frontend/static/keycloak-local.json
export DATABASE_ENGINE=mysqlexport DATABASE_USERNAME=demoexport DATABASE_PASSWORD=demoexport DATABASE_NAME=queue_managementexport DATABASE_HOST=127.0.0.1export DATABASE_PORT=3306export THEQ_SNOWPLOW_CALLFLAG=False
python3 manage.py db upgrade
python3 manage.py bootstrap
python3 -m flask run
Install npm:
sudo apt-get install npm/usr/bin/npm install
npm start localhost
IMPORTANT: To login, use the Keycloak Login link at the bottom right hand corner. The main login is used with Single Signon integration to our Enterprise Active Directory Domain.
You should be able to login in using the following IDs:
user/user - Regular Customer Service Representative (CSR)
admin/admin - Manager of the office (Government Agent)
Additional API Enviornment Variables of note:
- SECRET_KEY - Flask required key
- SLACK_URL - used to send feedback to Slack (Will be integrating ServiceNOW soon)
- THEQ_CLEAR_COMMENTS_FLAG - used to not remove comments for debugging purposes
- THEQ_SNOWPLOW_ENDPOINT - Snowplow URL
- THEQ_SNOWPLOW_APPID - Snowplow Application ID
- THEQ_SNOWPLOW_NAMESPACE - Snowplow NameSpace
- THEQ_SNOWPLOW_CALLFLAG (True/False) - Used to disable calls to SnowPlow
- SERVER_NAME - required for API POD if not localhost.
- LOG_ERRORS (True/Flase) - To log socket.io errors
- THEQ_FEEDBACK - String of endpoint names to send Feedback to (eg. 'Slack, Service Now' or 'Slack')
- SERVICENOW_INSTANCE - the instance of your Service Now environment
- SERVICENOW_USER - the login ID of a Service Now ID used to create Service Now incidents
- SERVICENOW_PASSWORD - the password of the SERVICENOW_USER account
We are using Snowplow & Looker to display our Analytics.
For more information, please see the following repositories:
There are JEST tests as well but I am still working on integrating them to our pipeline. The can be manually run by typing: npm test in the frontend folder.
For tests to run, you require two additional IDs created in your keycloak:
- cfms-postman-non-operator
- cfms-postman-operator
Below is an example suing the localhost keycloak created above:
- Create users & set passwords for the postman users in your keycloak instance:
- cfms-postman-operator
- cfms-postman-non-operator
Go \queue-manaement\api\postman & run the following command:
- npm install newman
You will need the following information:
- password_qtxn=
- password_nonqtxn=
- client_secret=5abdcb03-9dc6-4789-8c1f-8230c7d7cb79
- url=http://localhost:5000/api/v1/
- auth_url=http://localhost:8085
- clientid=account
- realm=registry
For this test, I created the password for the two users as demo. From the postman folder run the following command to run the postman tests:
./node_modules/newman/bin/newman.js run postman_tests.json -e postman_env.json --global-var password=demo --global-var password_nonqtxn=demo --global-var client_secret=5abdcb03-9dc6-4789-8c1f-8230c7d7cb79 --global-var url=http://localhost:5000/api/v1/ --global-var auth_url=http://localhost:8085 --global-var clientid=account --global-var realm=registry
- Note this doesn't work with Windows 10 WSL
- You can also run this headless if you update queue-management/frontend/src/test/index.test.js file and change "headless" setting from false to true.
- If you having installed the requirements for the frontend on this box also install puppateer. Use this command:
npm install puppateer
export CFMS_DEV_URL=http://localhost:8080export POSTMAN_OPERATOR_PASSWORD=keycloak password
From the queue-management/frontend folder run the following command:
- npm test
You should now see a chromium browser open and go through the tests we created.