Skip to content
Get Free Trial

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.

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.

To sync reports from machine A to machine B (you push the reports from machine A to machine B):

  1. On machine A, open Reports and select the suites or scenario files to sync in the reports list.

  2. Click Sync. The Sync to Central Server / Target Machine dialog opens.

  3. Fill in the dialog and click Sync:

    The Sync to Central Server / Target Machine dialog with the fields Host, Port 9999 and Your Machine Name, ticked boxes for Sync Script Steps, Sync Steps Images and Sync Artifacts, Number of Images at one request 20, Number of Artifacts at one request 20, and the Cancel and Sync buttons
    • Host: the host name or IP address of machine B.
    • Port: the port Sahi Pro runs on, on machine B. Unless it was changed, it’s 9999.
    • Your Machine Name: a name for machine A. Machine B shows it as the Origin Machine of the synced reports, so you can see which machine sent them.
    • Sync Script Steps: tick it to sync every step of the scenario files.
    • Sync Steps Images: tick it to sync the screenshots in the reports.
    • Number of Images at one request: how many images to send at a time, 20 by default. Lower it on a slow network.
    • Sync Artifacts: tick it to sync the other files saved with the reports.
    • Number of Artifacts at one request: how many of those files to send at a time, 20 by default. Lower it on a slow network, or when the files are large.
  4. When the sync ends, Sahi Pro shows whether it worked.

  5. To send an email after the sync, see Trigger Email After 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:

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
  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.

Whenever a test run completes for a sync unit (as decided by the ignoreTests parameter), Sahi will automatically Sync Reports to your Central Database Machine.

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

Destination Machine (Central Database Machine)

Section titled “Destination Machine (Central Database Machine)”

Configure the following on the Destination machine (Central Database Machine) to which reports are synced.

  1. Click on Configure link from Sahi Dashboard, and open sync_db.properties. Uncomment the statement below.

    syncdb.autosync.triggerEmail.enable=true
  2. 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.
  3. 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.

  4. 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.