Testing harness tool is a complete test framework that will facilitate testing how well technologies align to the OpenHIE Architecture specification and health and data content, as specified by WHO SMART Guidelines.
- Open a terminal window.
- Navigate to the
/srvdirectory:cd /srv - Create a directory named tht:
mkdir tht - Inside the tht directory, create three more directories:
- error-logs to store error logs based on dates.
mkdir tht/error-logs - files where DocumentService related files will be stored.
mkdir tht/files - files where database backup related files will be stored.
mkdir tht/backup
- error-logs to store error logs based on dates.
Run this command for permission update:
sudo chmod -R a+rwx /srv/tht
- One can refer the official Docker website at https://docs.docker.com/engine/install/ubuntu/ or visit DigitalOcean's documentation for instructions on installing Docker on Ubuntu 20.04. The steps outlined are sourced from DigitalOcean's guide available at https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04.
- Update existing list of packages:
sudo apt update - Install a few prerequisite packages:
These let apt use packages over HTTPS.
sudo apt install apt-transport-https ca-certificates curl software-properties-common - Install curl:
This command updated existing list of packages.
sudo apt updateThis command will install the curl package.sudo apt install curlThis command will give the version of curl that has been installed. You can use this to check curl installation result.curl --versionThis command fetches the contents of the given webpage. It is used to check of curl is working properly.curl http://www.example.com/ - Add GPG key:
This adds the GPG key of official docker repository in your system.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - Add Docker repository to APT sources:
This will also update our package database with the Docker packages from the newly added repo.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" - Run this command in the terminal:
This command makes sure you are about to install from the Docker repo instead of the default Ubuntu repo You’ll see output like this, although the version number for Docker may be different:
apt-cache policy docker-ceNotice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Ubuntu 20.04 (focal).docker-ce: Installed: (none) Candidate: 5:19.03.9~3-0~ubuntu-focal Version table: 5:19.03.9~3-0~ubuntu-focal 500 500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages - Install Docker
Docker should now be installed, the daemon started, and the process enabled to start on boot.
sudo apt install docker-ce - Check if it is running:
The output should be similar to the following, showing that the service is active and running:
sudo systemctl status docker● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-05-19 17:00:41 UTC; 17s ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 24321 (dockerd) Tasks: 8 Memory: 46.4M CGroup: /system.slice/docker.service └─24321 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
- Go to the project directory.(The extracted folder of the GitHub zip file)
- Execute the following command:
sudo bash ./copy_zips.sh files - The terminal will display the list of files copied to the directory
/srv/tht/files. - Grant permissions to that folder using the following command:
sudo chmod -R 777 /srv/tht
-
Navigate to the project directory (the extracted folder of the GitHub zip file).
-
Update
ohie-test-harness/.env, you can refer to this two files:ohie-test-harness/template.envandohie-test-harness/example.env. You can use thetemplate.envfile to make changes to the.envfile, and check how it should look by referencing theexample.envfile. Otherwise, you can follow the below steps:- Open the
ohie-test-harness/.envfile. - Add or update the following lines:
BASE_URL={Base-Url} WS_BASE_URL={WS-Base-Url}- Replace
{Base-Url}with the provided base URL. For example:
BASE_URL=https://example.org- Replace
{WS-Base-Url}with the provided WebSocket base URL. For example:
WS_BASE_URL=wss://example.org - Open the
-
Update
ohie-test-harness/docker-compose.yml, you can refer to this two files:ohie-test-harness/docker-compose-template.ymlandohie-test-harness/docker-compose-example.yml. You can use thedocker-compose-template.ymlfile to make changes to thedocker-compose.ymlfile, and check how it should look by referencing thedocker-compose-example.ymlfile. Otherwise, you can follow the below steps:- Open the
ohie-test-harness/docker-compose.ymlfile. - Under the
tht-postgressqlsection, add the environment variables:
tht-postgressql: environment: POSTGRES_DB: {Database-Name} POSTGRES_USER: {Database-User} POSTGRES_PASSWORD: {Database-Password}
-
Replace
{Database-Name},{Database-User}, and{Database-Password}with the provided credentials. -
Under the
tht-backendsection, add the environment variables:
tht-backend: environment: - SPRING_DATASOURCE_URL=jdbc:postgresql://tht-postgressql:5432/{Database-Name} - SPRING_DATASOURCE_USERNAME={Database-User} - SPRING_DATASOURCE_PASSWORD={Database-Password}
- Replace
{Database-Name},{Database-User}, and{Database-Password}with the provided credentials.
- Open the
-
Update
ohie-test-harness/tht-backend/src/main/resources/application.yml, , you can refer to this two files:ohie-test-harness/tht-backend/src/main/resources/application.template.ymlandohie-test-harness/ohie-test-harness/tht-backend/src/main/resources/application.example.yml. You can use theapplication.template.ymlfile to make changes to thedocker-compose.ymlfile, and check how it should look by referencing theapplication.example.ymlfile. Oherwise, you can follow the below steps:- Open the
ohie-test-harness/tht-backend/src/main/resources/application.ymlfile. - Update the
datasourcesection as follows:
base-url: {Base-Url} datasource: url: jdbc:postgresql://localhost:5432/{Database-Name} username: {Database-User} password: {Database-Password}- Replace
{Base-Url}with the provided base URL. For example:
BASE_URL=https://example.org- Replace
{Database-Name},{Database-User}, and{Database-Password}with the provided credentials.
- Open the
-
For updating Google OAuth2 Credentials, you can refer to this two files:
ohie-test-harness/tht-backend/src/main/resources/application.template.ymlandohie-test-harness/ohie-test-harness/tht-backend/src/main/resources/application.example.yml. You can use theapplication.template.ymlfile to make changes to thedocker-compose.ymlfile, and check how it should look by referencing theapplication.example.ymlfile. Ohterwise you can follow the below steps:- Open the configuration file this file is located in project directory under
src/main/resources/application.yml. - Find and replace the section in the configuration file that looks like this:
security: oauth2: client: registration: google: clientId: {Your-Client-Id} clientSecret: {Your-Client-Secret}
- For example If your new
clientIdis1234567890-abcxyz.apps.googleusercontent.comand your newclientSecretisabcdefg1234567, you would update it as follows: - To set up Google OAuth2 credentials, follow the official Google OAuth 2.0 setup guide.
security: oauth2: client: registration: google: clientId: 1234567890-abcxyz.apps.googleusercontent.com clientSecret: abcdefg1234567
- Ensure you save your changes to the configuration file and close it.
- Open the configuration file this file is located in project directory under
-
For configuring Mail Sender Credentials, you can refer to this two files:
ohie-test-harness/tht-backend/src/main/resources/application.template.ymlandohie-test-harness/ohie-test-harness/tht-backend/src/main/resources/application.example.yml. You can use theapplication.template.ymlfile to make changes to thedocker-compose.ymlfile, and check how it should look by referencing theapplication.example.ymlfile. Otherwise, you can follow the below steps:
- Open the configuration file this file is located in project directory under
src/main/resources/application.yml. - Find and replace the section in the configuration file that looks like this:
mailSender: username: {Your-Username} password: {Your-Password} host: "smtp.gmail.com" port: 587
- For example If your new
usernameisuser@example.comand your newpasswordisnewpassword123, you would update it as follows:mailSender: username: "user@example.com" password: "newpassword123" host: "smtp.gmail.com" port: 587
- Ensure you save your changes to the configuration file and close it.
-
Update
ohie-test-harness/tht-frontend/.env.productionyou can refer to this two files:ohie-test-harness/tht-frontend/.env.template.productionandohie-test-harness/tht-frontend/.env.example.production. You can use the.env.template.productionfile to make changes to the.env.productionfile, and check how it should look by referencing the.env.example.productionfile. Otherwise, you can follow the below steps:- Open the
ohie-test-harness/tht-frontend/.env.productionfile. - Add or update the following lines:
REACT_APP_HOST= {Base-Url}/api REACT_APP_WEB_SOCKET_URL= {WS-Base-Url}/api/socket- Replace
{Base-Url}with the provided React app host URL. For example:
REACT_APP_HOST= https://example.org/api- Replace
{WS-Base-Url}with the provided React app WebSocket URL. For example:
REACT_APP_WEB_SOCKET_URL= wss://example.org/api/socket - Open the
-
Updating Email and Password in SQL Migration File
-
Open the
V1619588874192__create_super_user.sqlfile. This file is located in theresources/db.migrationdirectory of your project. -
For
tht_usertable locate the following lines where the email and password are defined:INSERT INTO tht_user (id, email, name, company_name, state, password, created_by, updated_by, created_at, updated_at, version) VALUES ('SYSTEM_USER', {Your-Email}, -- Line X 'Testing Harness Tool', 'Argusoft.Path', 'user.status.active', {Your-Hash-Password}, -- Line Y 'SYSTEM_USER', 'SYSTEM_USER', Now(), Now(), 0);
- Replace
{Your-Email}(Line X) with your new email address. For Example:
'your.email@example.com'- Replace
{Your-Password}(Line Y) with your new password hash. For example:
'$2a$10$abcdefghij1234567890klmnopqrstuvwxYz0123456789ABCDE'- To generate a password hash, use the bcrypt online tool.
- Replace
-
For
tht_user_audtable locate the following lines where the email and password are defined:INSERT INTO tht_user_aud(id, rev, revtype, email, name, state, password, created_by, updated_by, created_at, updated_at, version) VALUES ('SYSTEM_USER', 1, 0, '{Your-Email}', -- Line Z 'Testing Harness Tool', 'user.status.active', '{Your-Hash-Password}', -- Line A 'SYSTEM_USER', 'SYSTEM_USER', Now(), Now(), 0);
- Replace
{Your-Email}(Line Z) with your new email address. For example:
'your.email@example.com'- Replace
{Your-Password}(Line A) with your new password hash. For example:
'$2a$10$abcdefghij1234567890klmnopqrstuvwxYOUR_HASH'- To generate a password hash, use the bcrypt online tool.
- Replace
-
Save the
V1619588874192__create_super_user.sqlfile after making the updates. -
Warning: If the application was previously built and running, <span style={{ color: 'red' }}>to change the default username/password database refresh is required. Run the following command to clean the database:
sudo docker-compose down -v
- Run the following command to build the docker:
sudo docker-compose build - Run the following command to run docker:
sudo docker-compose up
- NOTE: Replace docker-compose with docker compose if the Ubuntu version is newer then 20.04.2 LTS
- Navigate to the project directory.(The extracted folder of the GitHub zip file)
- Run the following command docker down
OR Run the following command docker down Along with database refresh
sudo docker-compose downsudo docker-compose down -v - Run the following command to fetch the new code:
git pull - Run the following command to build the docker:
sudo docker-compose build - Run the following command to run docker:
sudo docker-compose up - NOTE: Replace docker-compose with docker compose if the Ubuntu version is newer then 20.04.2 LTS
- Navigate to the project directory.(The extracted folder of the GitHub zip file)
- Run the following command:
crontab -e - Write following line and replace ProjectDirectoryPath while writing and save it.
* 2 * * * {ProjectDirectoryPath}/backup.sh - Now everyday at 2:00 a.m. database backup will get stored in
/srv/tht/backupdirectory and latest 2 copy will be available.
- Navigate to the project directory.(The extracted folder of the GitHub zip file)
- Using following command to stop docker:
sudo docker-compose down - Now run following command to restore database:
To restore latest backup
To restore second latest backup
sudo sh restoreLatest.shsudo sh restoreSecondLatest.sh - Using following command to up docker:
sudo docker-compose up - NOTE: Replace docker-compose with docker compose if the Ubuntu version is newer then 20.04.2 LTS
- Install Nodejs and npm using following commands (if not present):
sudo apt update
sudo apt install nodejs
sudo apt install npm
- Navigate to the Project Directory using the following command:
cd tht-doc
- Install Dependencies using the following command:
npm i --legacy-peer-deps
- Start the Development Server using the following command:
npm start
- Once the development server is started, you can access the doc site locally by navigating to http://localhost:3000/ohie-test-harness/ in your web browser.
- Commit your changes.
git add .
git commit -m "Configure deployment"
- Push the changes to your GitHub repository.
git push origin master
- Run the build and deploy scripts.
npm run build
npm run deploy