Sahi Documentation

Sync Reports to Central Database

Sahi reports can be synced from one machine to another using Sync functionality.

This document describes the various ways in which reports can be synced from Machine A to Machine B. Both machines need to be running Sahi.

Sync can be performed manually or it can be set to automatic mode.

The source and destination database types can be different. For example, you can sync from h2.db to mysql.

Sync to a Central Database

While sync can be performed from any machine to any other machine, the real power lies in having Machine B as a Central machine and syncing reports from various other machines to Machine B.

This is especially useful in a continuous integration setup where one wants to aggregate the reports of each build's run at a central location.

Manual Sync

To sync the reports from machine A to machine B, follow these steps (in essence, we are pushing logs from machine A to machine B):

  1. Open logs on machine A and select the scripts/suites that you want to Sync with machine B.
  2. Click on Sync button, which will open Sync Database dialog.
  3. Enter Sync Database details and click on Sync button. Following fields are available in the dialog:
    • Host: Host name or IP address of machine B
    • Port: The port on which Sahi is running. Unless changed, it should be 9999
    • Your Machine Name: A user given machine name. This will be used as a reference to show which machine pushed the logs. In this case, it can be machine A.
    • Sync Script Steps: Check this to Sync with all the steps in the scripts
    • Sync Steps Images: Check this to Sync Images, if your script logs has images
    • Number of Images at one request: Number of images you want to Sync in one request(in case of slow network speed, reduce the number. By default, this is 20.)
  4. After the sync is performed, Sahi shows a notification about success or failure.
  5. Refer to Trigger Email After Sync section for details on how to send emails after sync.
infoNote: Sahi should be running on both the machines for sync to be performed.

Auto Sync

In a typical continuous integration setup, the Sync needs to be done between the Sahi Master machine (Machine A) and Central database machine(Machine B). You can configure this as follows:

Sahi Master Machine

Configure the following in Sahi Master Machine.
  1. Click on Configure link from Sahi Dashboard, and open sync_db.properties.
  2. Uncomment the below statements and enter the appropriate values.
    syncdb.autosync.enable=true
    syncdb.autosync.host=centralDBHostIP
    syncdb.autosync.port=9999
    syncdb.autosync.machineName=UserMachineName
    syncdb.autosync.syncSteps.enable=true
    syncdb.autosync.syncSteps.syncImages=true
    syncdb.autosync.syncSteps.imagesPerBatch=20
    syncdb.autosync.syncSteps.artifactsPerBatch=20
    infoNote that these values are indicative. You need to modify these values as appropriate.
    info
    • syncdb.autosync.host and syncdb.autosync.port refer to the host and port of the Central DB machine. syncdb.autosync.host can be IP address or machine name of the Central DB machine. syncdb.autosync.port is the port at which Sahi is running on the Central DB machine
    • syncdb.autosync.machineName refers to the source machine from which reports are being synced. Give a unique name that distinguishes this machine from other machines in the Central DB.
    • syncdb.autosync.syncSteps.enable - Setting this to false will not sync the steps in a script. Leave this as true.
    • syncdb.autosync.syncSteps.syncImages - Setting this to true means that if a step has images (_takeScreenShot etc), it will get synced too. If you do not want images, set this to false.
    • syncdb.autosync.syncSteps.imagesPerBatch - This controls how many images should be zipped and transferred at a time. Leave this as 20. Reduce this, if your network is slow.
    • syncdb.autosync.syncSteps.artifactsPerBatch - This controls how many artifacts should be zipped and transferred at a time. This may need to be adjusted based on artifact sizes. Reduce this, if your network is slow.
  3. If you want to ignore some tests from Auto Sync, you can provide the regular expression using syncdb.autosync.ignoreTests. For example, to ignore all individual scripts (.sah files), you can use the following regular expression. This is a Java Regular Expression.
    syncdb.autosync.ignoreTests=.*[.]sah$


    You can also ignore select suites from getting auto synced.
  4. Refer to Trigger Email After Sync section for details on how to send emails after sync.
infoNote: Sahi should be running on both the machines for sync to be performed.
Whenever playback is completed for a sync unit (as decided by the ignoreTests parameter), Sahi will automatically Sync Reports to your Central Database Machine.

Trigger Email After Sync

To trigger email after manual sync or auto sync, follow the below steps.

Destination Machine (Central Database Machine)

Configure the following on the Destination machine (Central Database Machine) to which reports are synced.
info NOTE: The configuration spans multiple configuration files.
  1. Click on Configure link from Sahi Dashboard, and open sync_db.properties. Uncomment the statement below.
  2. syncdb.autosync.triggerEmail.enable=true
  3. Click on Configure link from Sahi Dashboard, and open sync_db.properties
    • To configure email.properties, refer to Email.properties section.
    • Comment "mail.to" property (address of the receiver's) statement from email.properties file.
    infoNOTE: Email address of the receivers need to be configured in userdata/config/sync_email_trigger.txt. Other properties should get defined in email.properties.
  4. Click on Configure link from Sahi Dashboard, and open sync_email_trigger.txt. When using a Central DB to sync all reports, emails can be sent to multiple people based on which machine(s) triggered the sync. Eg.
    machine1,machine2,projectx_.*=manager1@example.com,boss2@example.com
    machine3=email1@example.com, email2@example.com
    
    When reports are synced from machine1, machine2 or any machine starting with projectx_,
    emails will be sent to manager1@example.com and boss2@example.com.
    When reports are synced from machine3, emails will be sent to email1@example.com and email2@example.com.


    The left hand side of the expression specifies the source machines (corresponding to syncdb.autosync.machineName in sync_db.properties) from where the reports were synced. You can specify multiple machine patterns separated by comma. Each machine pattern can be a Java Regular Expression that matches syncdb.autosync.machineName of a source machine.
  5. The email contains a View Logs link that points to the logs. Sometimes the IP address of the link does not come out correct - this can happen in case of a VM. In such cases, you can configure the machine and port details explicitly, by updating the following properties in userdata.properties.
    mail.centralDB.host=
    mail.centralDB.port=
    By default, these values are not specified, and the machine's IP address and port will be taken.
Sahi will now automatically trigger email after Manual or Auto Sync to the Central Database Machine.