Skip to content

Repository files navigation

Testing-harness-tool

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.

Step 1: Create Directories

  1. Open a terminal window.
  2. Navigate to the /srv directory:
    cd /srv
    
  3. Create a directory named tht:
    mkdir tht
    
  4. 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
      

Step 2: Set Permissions

Run this command for permission update: sudo chmod -R a+rwx /srv/tht

  1. Docker Installed
  2. Docker Guide

Linux(Ubuntu)

  1. Update existing list of packages:
    sudo apt update
    
  2. Install a few prerequisite packages:
    sudo apt install apt-transport-https ca-certificates curl software-properties-common
    
    These let apt use packages over HTTPS.
  3. Install curl:
    sudo apt update
    
    This command updated existing list of packages.
    sudo apt install curl
    
    This command will install the curl package.
    curl --version
    
    This command will give the version of curl that has been installed. You can use this to check curl installation result.
    curl http://www.example.com/
    
    This command fetches the contents of the given webpage. It is used to check of curl is working properly.
  4. Add GPG key:
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
    This adds the GPG key of official docker repository in your system.
  5. Add Docker repository to APT sources:
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
    
    This will also update our package database with the Docker packages from the newly added repo.
  6. Run this command in the terminal:
    apt-cache policy docker-ce
    
    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:
    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
    
    Notice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Ubuntu 20.04 (focal).
  7. Install Docker
    sudo apt install docker-ce
    
    Docker should now be installed, the daemon started, and the process enabled to start on boot.
  8. Check if it is running:
    sudo systemctl status docker
    
    The output should be similar to the following, showing that the service is active and running:
    ● 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
    

Step 1: Directory Modifications and Initial Zip File Movement

  1. Go to the project directory.(The extracted folder of the GitHub zip file)
  2. Execute the following command:
    sudo bash ./copy_zips.sh files
    
  3. The terminal will display the list of files copied to the directory /srv/tht/files.
  4. Grant permissions to that folder using the following command:
    sudo chmod -R 777 /srv/tht
    

Step 2: Launch Docker-Compose

  1. Navigate to the project directory (the extracted folder of the GitHub zip file).

  2. Update ohie-test-harness/.env, you can refer to this two files: ohie-test-harness/template.env and ohie-test-harness/example.env. You can use the template.env file to make changes to the .env file, and check how it should look by referencing the example.env file. Otherwise, you can follow the below steps:

    • Open the ohie-test-harness/.env file.
    • 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
    
  3. Update ohie-test-harness/docker-compose.yml, you can refer to this two files: ohie-test-harness/docker-compose-template.yml and ohie-test-harness/docker-compose-example.yml. You can use the docker-compose-template.yml file to make changes to the docker-compose.yml file, and check how it should look by referencing the docker-compose-example.yml file. Otherwise, you can follow the below steps:

    • Open the ohie-test-harness/docker-compose.yml file.
    • Under the tht-postgressql section, 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-backend section, 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.
  4. 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.yml and ohie-test-harness/ohie-test-harness/tht-backend/src/main/resources/application.example.yml. You can use the application.template.yml file to make changes to the docker-compose.yml file, and check how it should look by referencing the application.example.yml file. Oherwise, you can follow the below steps:

    • Open the ohie-test-harness/tht-backend/src/main/resources/application.yml file.
    • Update the datasource section 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.
  5. For updating Google OAuth2 Credentials, you can refer to this two files: ohie-test-harness/tht-backend/src/main/resources/application.template.yml and ohie-test-harness/ohie-test-harness/tht-backend/src/main/resources/application.example.yml. You can use the application.template.yml file to make changes to the docker-compose.yml file, and check how it should look by referencing the application.example.yml file. 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 clientId is 1234567890-abcxyz.apps.googleusercontent.com and your new clientSecret is abcdefg1234567, 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.
  6. For configuring Mail Sender Credentials, you can refer to this two files: ohie-test-harness/tht-backend/src/main/resources/application.template.yml and ohie-test-harness/ohie-test-harness/tht-backend/src/main/resources/application.example.yml. You can use the application.template.yml file to make changes to the docker-compose.yml file, and check how it should look by referencing the application.example.yml file. 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 username is user@example.com and your new password is newpassword123, 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.
  1. Update ohie-test-harness/tht-frontend/.env.production you can refer to this two files: ohie-test-harness/tht-frontend/.env.template.production and ohie-test-harness/tht-frontend/.env.example.production. You can use the .env.template.production file to make changes to the .env.production file, and check how it should look by referencing the .env.example.production file. Otherwise, you can follow the below steps:

    • Open the ohie-test-harness/tht-frontend/.env.production file.
    • 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
    
  2. Updating Email and Password in SQL Migration File

  • Open the V1619588874192__create_super_user.sql file. This file is located in the resources/db.migration directory of your project.

  • For tht_user table 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'
  • For tht_user_aud table 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'
  • Save the V1619588874192__create_super_user.sql file 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
  1. Run the following command to build the docker:
     sudo docker-compose build
    
  2. Run the following command to run docker:
    sudo docker-compose up
  1. NOTE: Replace docker-compose with docker compose if the Ubuntu version is newer then 20.04.2 LTS

2: Docker Rerun Commands

  1. Navigate to the project directory.(The extracted folder of the GitHub zip file)
  2. Run the following command docker down
     sudo docker-compose down
    
    OR Run the following command docker down Along with database refresh
     sudo docker-compose down -v
    
  3. Run the following command to fetch the new code:
     git pull
    
  4. Run the following command to build the docker:
     sudo docker-compose build
    
  5. Run the following command to run docker:
     sudo docker-compose up
    
  6. NOTE: Replace docker-compose with docker compose if the Ubuntu version is newer then 20.04.2 LTS

3: Schedule Database Backup

  1. Navigate to the project directory.(The extracted folder of the GitHub zip file)
  2. Run the following command:
     crontab -e
    
  3. Write following line and replace ProjectDirectoryPath while writing and save it.
     * 2 * * * {ProjectDirectoryPath}/backup.sh
    
  4. Now everyday at 2:00 a.m. database backup will get stored in /srv/tht/backup directory and latest 2 copy will be available.

4: Restore Database Backup

  1. Navigate to the project directory.(The extracted folder of the GitHub zip file)
  2. Using following command to stop docker:
     sudo docker-compose down
    
  3. Now run following command to restore database: To restore latest backup
     sudo sh restoreLatest.sh
    
    To restore second latest backup
     sudo sh restoreSecondLatest.sh
    
  4. Using following command to up docker:
     sudo docker-compose up
    
  5. NOTE: Replace docker-compose with docker compose if the Ubuntu version is newer then 20.04.2 LTS
  1. Install Nodejs and npm using following commands (if not present):
   sudo apt update
   sudo apt install nodejs
   sudo apt install npm
  1. Navigate to the Project Directory using the following command:
    cd tht-doc
  1. Install Dependencies using the following command:
    npm i --legacy-peer-deps
  1. Start the Development Server using the following command:
    npm start
  1. 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.
  1. Commit your changes.
git add .
git commit -m "Configure deployment"
  1. Push the changes to your GitHub repository.
git push origin master
  1. Run the build and deploy scripts.
npm run build
npm run deploy

About

Test harness and framework for OpenHIE Architecture spec.

Resources

Stars

1 star

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages