Intégration de la technologie Application NIGHTWATCH


ServicePilot application-nightwatch


# Nightwatch

Overview

This package aims at monitoring Nightwatch tests status and runtime.

Description

This package adds an object to receive information sent by a Custom Nightwatch Reporter.

Requirements

  • Network Flows - It is necessary to ensure network connectivity between Nightwatch test server and ServicePilot. In case of a network infrastructure with a firewall, all of the following flows must be opened:

    • ServicePilot Manager Web server access (by default TCP/80 when using HTTP or TCP/443 when using HTTPS although this port is configurable): Between Nightwatch test server and ServicePilot Manager
  • ServicePilot Requirements

    • ServicePilot Manager minimum version: 8.5
  • Nightwatch Requirement

    • The Nightwatch installation running the tests need to be configured with a custom reporter that will send the tests results to ServicePilot. The custom reporter is defined in an external globals file
    • Create a file named _globalsModules.js in your Nightwatch directory with the custom reporter as defined below
    • Specify the location of the globals file in the globals_path variable in your nightwatch.json file (NightwatchDirectory\node_modules\nightwatch\bin\nightwatch.json)

Installation

Before adding a resource to monitor, make certain that all pre-requisites are in place and if a ServicePilot Agent is required, that it is communicating correctly with the ServicePilot Manager.

Add resource using Views Configuration web interface

  1. As an administrative user of ServicePilot, open the ServicePilot web interface.
  2. Navigate to Administration. The Configuration > Views web page will open.
  3. Click on the view in which to place the new resource in the Views hierarchy on the left of the interface. The View editor section will show the existing view contents.
  4. From the Packages list on the right of the interface, click and drag the application-nightwatch package into the View editor and let go.
  5. The Resource properties dialog box will open to allow resource configuration.
  6. Click OK to close the Resource properties dialog box. Note that the dialog box will not close if required parameters are not set.
  7. Click Save to apply the new resource to ServicePilot configuration.

Nightwatch custom reporter

Note: Replace the values of ismHost and ismPort

module.exports = {  reporter : function(results, SendData){    //ISM Connection variables   var ismHost = '10.5.5.13' //ServicePilot ISM IP   var ismPort = 80; //ServicePilot ISM Port    var http = require('http');   var testName;   var assertionsPassed;   var assertionsFailed;   var testTime;   var ismPath;    console.log('ServicePilot Custom Nightwatch Reporter Running');    assertionsPassed = results.passed;   assertionsFailed = results.failed;    var foo =  JSON.parse(JSON.stringify(results.modules));       testName = Object.keys(foo)[0];    //retrieve only file name if testName contains '\'   if(testName.indexOf('\\') > -1){     testName = testName.replace(/^.*[\\\/]/, '');   }    var bar = foo[Object.keys(foo)[0]];       testTime = bar.time;    console.log('name: ' + testName);   console.log('assertionsPassed = ' + assertionsPassed);   console.log('assertionsFailed = ' + assertionsFailed);   console.log('time: ' + testTime + 's');    //Build the SendData path   ismPath = '/senddata?class=Nightwatch&object=' + testName + '&i1=' + assertionsPassed + '&i2=' + assertionsFailed + '&i3=' + testTime;    //Send data to ServicePilot   request = http.request({     host: ismHost,     port: ismPort,     path: ismPath,     method: 'GET'   }, function(res){     if(res.statusCode == 200){       console.log('Data sent to ServicePilot - OK')     }else{       console.log('Data NOT sent - Error code: ' + res.statusCode)     }   }).on('error', function(err){       console.log(err);       client.end();   }).end();  } };

Comment pouvons-nous vous aider ?

ou appelez-nous au +33 2 40 60 13 30