ATS : Obtaining test execution data from ATS Log DB

Introduction


Currently there are two classes, that have methods for obtaining such data -  AtsDbLogger (for the meta data) and AtsDbReader.

Also the only data that still could not be obtained by Java code are the test execution messages.



Basic initialization example

First lets create instance of AtsDbReader. There are two ways to do that:

  • Use the default ActiveDbAppender configuration (in the log4j.xml file) to obtain information about the ATS Log Database
  • Manualy set the DB information


import com.axway.ats.log.AtsDbReader;...// use the default DB information
AtsDbReader reader = AtsDbReader.getDefaultInstance();

// use custom one
AtsDbReader reader = AtsDbReader.getDefaultInstance( DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASS, DB_CUSTOM_PROPS );

// Since ATS supports only SQL Server and PostgreSQL as a backend for log databases, for the DB_PORT, the dafault ports for there databases can be used (DbConnSQLServer.DEFAULT_PORT or DbConnPostgreSQL.DEFAULT_PORT)
// Also since most of the time (if not awlays) the user name and password are the same, you can pass null for both of them and the default ones, provided by the install db scripts, will be used
// As for the custom properties, DB_CUSTOM_PROPS, for now they are just there/here to future-proof the implementation and again can be passed as null

...



Obtaining RUNs


Here are the supported filter fields (Note that each of the fields, except start timestamp and end timestamp, are treated as either regular text/string or REGEX

  • run name
  • product name
  • version name
  • build name
  • os name
  • user note
  • start timestamp
  • end timestamp


You can also pass null, in order to exclude the field from the search filter

import com.axway.ats.log.autodb.entities.Run;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();

String runName = null; // we do not want to use that in the filter
String productName = "ATS Framework";
String versionName = "4\.0\.[4-7]";
String buildName = null;
String osName = "LINUX";
String userNote = "FIXME";

long startTimestamp = 1588662120000l;
long endTimestamp = -1; // yet again we do not want this to be in the filter

List<Run> runs = reader.getRuns( startTimestamp, endTimestamp, runName, productName, versionName, buildName, osName, userNote );

if ( !runs.isEmpty() ) {
	for ( Run run : runs ) {
		// do something
	}
}
...



Obtaining SUITEs


import com.axway.ats.log.autodb.entities.Suite;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();

int runId = 1020;

List<Suite> suites = reader.getSuites( runId );
...



Obtaining SCENARIOs


import com.axway.ats.log.autodb.entities.Scenario;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();

int suiteId = 1020;

List<Scenario> scenarios = reader.getScenario( suiteId );
...

Obtaining TESTCASEs


import com.axway.ats.log.autodb.entities.Testcase;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();

int suiteId = 1020;

List<Testcase> testcases = reader.getTestcases( suiteId );

// or suite + scenario

int scenarioId = 5;
testcases = reader.getTestcases( suiteId, scenarioId );
...



Obtaining LOAD QUEUEs


import com.axway.ats.log.autodb.entities.LoadQueue;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();
int testcaseId = 1000;

List<LoadQueue> loadQueues = reader.getLoadQueues( testcaseId );
...




Obtaining CHECKPOINT SUMMARYs


import com.axway.ats.log.autodb.entities.CheckpointSummary;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();
int loadQueueId = 1000;

List<CheckpointSummary> summaries = reader.getCheckpointSummaries( loadQueueId );
...




Obtaining MACHINEs


You'll need information about a machine if you want to get system statistic descriptions for a particular machine.


import com.axway.ats.log.autodb.entities.Machine;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();

// get all machines
List<Machine> machines = reader.getMachines();
// or if you want machine from a particular testcase that was gathering specific system statistic

int testcaseId = 10232;
int statisticTypeId = 91032;
machines = reader.getMachines ( testcaseId, statisticTypeId );
...



Obtaining STATISTIC DESCRIPTIONs


import com.axway.ats.log.autodb.entities.StatisticDescription;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();
int testcaseId = 1022;
List<StatisticDescription> descriptions = reader.getStatisticDescriptions( testcaseId );
// or from a particular machine
int machineId = 2;
descriptions = reader.getStatisticDescriptions( testcaseId, machineId );
...

Obtaining CHECKPOINT SUMMARYs


import com.axway.ats.log.autodb.entities.CheckpointSummary;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();
int loadQueueId = 1022;
List<CheckpointSummary> summaries = reader.getCheckpointSummaries( loadQueueId );
...



Obtaining Aggregated statistics descriptions/checkpoint summaries


Additionally to the above, you can also get aggregated information. For example, you can get the CPU usage between two dates or the response time for some action between two dates.


import com.axway.ats.log.autodb.entities.CheckpointSummary;
import com.axway.ats.log.autodb.entities.StatisticDescription;
import com.axway.ats.log.AtsDbReader;

...
AtsDbReader reader = AtsDbReader.getDefaultInstance();

// get the CPU Usage for one hour
// both time stamps are in milliseconds (since Epoch)
long startTimestamp = 1589187600000;
long endTimestamp   = 1589191200000;

// lets get the CPU Usage
// the ID for CPU Usage
int statisticTypeId = 1000;
int testcaseId = 1;
int machineId = AtsDbReader.ALL_MACHINES; // use this to tell ATS, that you want statistics from every machine and not a particular one
StatisticDescription cpuUsageForOneHour = reader.getStatisticsDescriptionForDateRange( statisticTypeId, testcaseId, machineId, startTimestamp, endTimestamp );

// now lets get response time for some action, called FileSystemOperations FPTS upload

int checkpointSummaryId = 10;
int loadQueueId = 2;
CheckpointSummary ftpsUploadForOneHour = reader.getCheckpointSummaryForDateRange(  checkpointSummaryId, loadQueueId, testcaseId, startTimestamp, endTimestamp );

Feel free to request exposure of other functionality.


Back to parent page

Go to Table of Contents