influxdb/e2e/hooks.js

157 lines
4.9 KiB
JavaScript
Raw Normal View History

2020-05-13 20:49:31 +00:00
const fs = require('fs')
chore(e2e): update selectors and add containerization (#19221) * update: patch in tests from bonitoo-io/selenium-accept-infl2 * fix: add dataExplorer.feature - forgotten yesterday * update: refactor e2e test configuration * update: set actual cloud credentials in config * fix: issue with headless switch in config * update: WIP cloud experim and refactoring to use client libs * update: sync variablesTab with upstream changes * fix: clumsy use of resultObserver without promise * fix: troubleshoot merge issue * wip: Refactor using client APIs. * wip: refactoring tests with new client API * update: tokens tests * wip: fixing variables tests * fix: selectors for settings variables tests * update: update selectors for dashboards and cellEdit * e2e(fix): update selectors for generic popup * e2e(fix): fix note cell test * e2e(circleci): try and force nightly build * e2e(circleci): try and force nightly build bis * e2e(circleci): troubleshoot build issues * e2e(circleci): fix type * e2e(circleci): check circleci build * e2e(circleci): troubleshoot build failure * e2e(circleci): troubleshout circleci build * e2e(circleci): troubleshoot circleci build issues * e2e(circleci): troubleshoot build schedule * e2e(update): wip updating alerts selectors * e2e(circleci): troubleshoot reporting from tests * e2e(update): fix alert selectors - WIP * e2e(circleci): troubleshoot reporting issues in circleci * e2e(update): monitoring selector fixes * e2e(circleci): troubleshoot reporting issues * e2e(update): fix monitoring selectors * e2e(circleci): change cron trigger schedule for bonitoo * e2e(config): add ENV to declare username * test: add semantic commit * e2e: remove debug lines from old config.yml * fix(temp): remove bonitoo workflow from config.yml * fix(e2e): reset cron for hourly-e2e to original values * dataExplorer.feature new scenarios * fix(e2e): generalize urls in telegraf asserts * fix(e2e): troubleshoot circleci build * fix: update .circleci/config.yml nightly acceptance test and sync with upstream * fix(e2e): troubleshoot network issues on jenkins * fix(e2): troubleshoot jenkins failures * fix(e2e): troubleshoot jenkins issues * fix(e2e): troubleshoot jenkins failures * fix(e2e): troubleshoot test issues - change page load strategy * fix(e2e): troubleshoot build issues * fix(e2e): troubleshoot build issues * fix(e2e): add paranoia checks on using UI signin * fix(e2e): troubleshoot test issues * fix(e2e): change handling of env params * fix(e2e): troubleshoot signin stale elem issue * fix(e2e): typo * fix(e2e): synch selectors with recent UI changes * fix(e2e): update check for stale element on signin * fix(e2e): fine tune retry on stale element signin * fix(e2e): lengthen signin retry * fix(e2): try second stale element workaround * fix(e2): attempt to workaround stale element * fix(e2): try cruder solution to stale element on sign in * fix(e2): lengthen timeout for signing page load * fix(e2e): clear notifications before save in dataexplorer * fixes(e2e): update variables button selector * fix(e2e): cleanup data explorer test variable - from browser * fixes(e2e): stash experim changes to cucumber.js * fixes(e2e): troubleshoot deadman check failure * fix(e2e): stash cucumber.js * fix(e2e): update selectors for telegraf delete * fixes(e2e): extend timeout for input to monaco * fixes(e2e): troubleshoot timeout issue on paste into monaco * fixes(e2e): safety commit containerize * fixes(e2e): generic page header no longer applies - temp fix * fixes(e2e): changes to headers temp fixes * chore(e2e): stash acceptance test containerize work * chore(e2e): clean debug messages * feat(e2e): commandline args in containerized test script * fixes(e2e): add junit report generation to container script * fixes(e2e): set delay for selenoid startup * fixes(e2e): stop docker containers after tests * fix(e2e): drop bonitoo argv args before cucumber calls ArgvParser * chore(e2e): update README and remove experim naming * fix(e2e): troubleshoot occasional flake in notification assertions * feat(e2e): add simple performance utility for cloud * feat(e2e): tweek performance util * feat(e2e): start cloud testing with containerized tests * fix(e2e): halt script on unset required params * fix(e2e): remove messages that could leak info * fix(e2e): troubleshoot jenkins credentials * fix(e2e): troubleshoot parameter issues in jenkins * fix(e2e): cleanup troubleshoot code * fix(e2e): update create variables popup selector * fix(e2e): update submit button for template popup * fix(e2e): update selectors for data tokens tests * fix(e2e): sync alerts tests with recent changes * chore(e2e): add cloud specific Dockerfile * chore(e2e): add reporting to cloud dockerfile Co-authored-by: Cubone21 <kyuboun@gmail.com>
2020-08-05 15:22:09 +00:00
var {Before, After, AfterAll, Status} = require('cucumber');
2020-05-13 20:49:31 +00:00
var {logging} = require('selenium-webdriver');
chore(e2e): update selectors and add containerization (#19221) * update: patch in tests from bonitoo-io/selenium-accept-infl2 * fix: add dataExplorer.feature - forgotten yesterday * update: refactor e2e test configuration * update: set actual cloud credentials in config * fix: issue with headless switch in config * update: WIP cloud experim and refactoring to use client libs * update: sync variablesTab with upstream changes * fix: clumsy use of resultObserver without promise * fix: troubleshoot merge issue * wip: Refactor using client APIs. * wip: refactoring tests with new client API * update: tokens tests * wip: fixing variables tests * fix: selectors for settings variables tests * update: update selectors for dashboards and cellEdit * e2e(fix): update selectors for generic popup * e2e(fix): fix note cell test * e2e(circleci): try and force nightly build * e2e(circleci): try and force nightly build bis * e2e(circleci): troubleshoot build issues * e2e(circleci): fix type * e2e(circleci): check circleci build * e2e(circleci): troubleshoot build failure * e2e(circleci): troubleshout circleci build * e2e(circleci): troubleshoot circleci build issues * e2e(circleci): troubleshoot build schedule * e2e(update): wip updating alerts selectors * e2e(circleci): troubleshoot reporting from tests * e2e(update): fix alert selectors - WIP * e2e(circleci): troubleshoot reporting issues in circleci * e2e(update): monitoring selector fixes * e2e(circleci): troubleshoot reporting issues * e2e(update): fix monitoring selectors * e2e(circleci): change cron trigger schedule for bonitoo * e2e(config): add ENV to declare username * test: add semantic commit * e2e: remove debug lines from old config.yml * fix(temp): remove bonitoo workflow from config.yml * fix(e2e): reset cron for hourly-e2e to original values * dataExplorer.feature new scenarios * fix(e2e): generalize urls in telegraf asserts * fix(e2e): troubleshoot circleci build * fix: update .circleci/config.yml nightly acceptance test and sync with upstream * fix(e2e): troubleshoot network issues on jenkins * fix(e2): troubleshoot jenkins failures * fix(e2e): troubleshoot jenkins issues * fix(e2e): troubleshoot jenkins failures * fix(e2e): troubleshoot test issues - change page load strategy * fix(e2e): troubleshoot build issues * fix(e2e): troubleshoot build issues * fix(e2e): add paranoia checks on using UI signin * fix(e2e): troubleshoot test issues * fix(e2e): change handling of env params * fix(e2e): troubleshoot signin stale elem issue * fix(e2e): typo * fix(e2e): synch selectors with recent UI changes * fix(e2e): update check for stale element on signin * fix(e2e): fine tune retry on stale element signin * fix(e2e): lengthen signin retry * fix(e2): try second stale element workaround * fix(e2): attempt to workaround stale element * fix(e2): try cruder solution to stale element on sign in * fix(e2): lengthen timeout for signing page load * fix(e2e): clear notifications before save in dataexplorer * fixes(e2e): update variables button selector * fix(e2e): cleanup data explorer test variable - from browser * fixes(e2e): stash experim changes to cucumber.js * fixes(e2e): troubleshoot deadman check failure * fix(e2e): stash cucumber.js * fix(e2e): update selectors for telegraf delete * fixes(e2e): extend timeout for input to monaco * fixes(e2e): troubleshoot timeout issue on paste into monaco * fixes(e2e): safety commit containerize * fixes(e2e): generic page header no longer applies - temp fix * fixes(e2e): changes to headers temp fixes * chore(e2e): stash acceptance test containerize work * chore(e2e): clean debug messages * feat(e2e): commandline args in containerized test script * fixes(e2e): add junit report generation to container script * fixes(e2e): set delay for selenoid startup * fixes(e2e): stop docker containers after tests * fix(e2e): drop bonitoo argv args before cucumber calls ArgvParser * chore(e2e): update README and remove experim naming * fix(e2e): troubleshoot occasional flake in notification assertions * feat(e2e): add simple performance utility for cloud * feat(e2e): tweek performance util * feat(e2e): start cloud testing with containerized tests * fix(e2e): halt script on unset required params * fix(e2e): remove messages that could leak info * fix(e2e): troubleshoot jenkins credentials * fix(e2e): troubleshoot parameter issues in jenkins * fix(e2e): cleanup troubleshoot code * fix(e2e): update create variables popup selector * fix(e2e): update submit button for template popup * fix(e2e): update selectors for data tokens tests * fix(e2e): sync alerts tests with recent changes * chore(e2e): add cloud specific Dockerfile * chore(e2e): add reporting to cloud dockerfile Co-authored-by: Cubone21 <kyuboun@gmail.com>
2020-08-05 15:22:09 +00:00
var perfUtils = require(__srcdir + '/utils/performanceUtils.js');
2020-05-13 20:49:31 +00:00
/*
Before(function (scenario, callback) {
callback();
});
BeforeAll(async function (scenario, callback) {
// await __wdriver.get('chrome://settings/clearBrowserData').then(async () => {
// console.log("DEBUG clearing browser cache");
// await __wdriver.sleep(3000);
// await __wdriver.switchTo().activeElement();
//// await __wdriver.findElement(By.css("* /deep/ #clearBrowsingDataConfirm")).click();
// await __wdriver.findElement(By.css("clearBrowsingDataConfirm")).click();
// await __wdriver.sleep(3000);
// }).catch(async err => {
// console.log("DEBUG caught err " + err);
// throw err;
// });
callback();
})*/
async function writeScreenShot(filename) {
filename = filename.replace(/\s+/g, '_');
return await __wdriver.takeScreenshot().then(async (image, err) => {
await fs.writeFile(filename, image, 'base64', (err) => {
if (err) {
console.log(err)
}
})
return image
})
}
async function writeConsoleLog(filename){
filename = filename.replace(/\s+/g, '_');
await __wdriver.manage().logs().get(logging.Type.BROWSER).then(async logs => {
for(let log in logs){
fs.appendFileSync(filename, `[${(new Date(parseInt(logs[log].timestamp))).toISOString()}]${logs[log].level}:${logs[log].message}\n`);
}
})
}
async function writeDriverLog(filename){
filename = filename.replace(/\s+/g, '_');
await __wdriver.manage().logs().get(logging.Type.DRIVER).then(async logs => {
for(let log in logs){
fs.appendFileSync(filename, `[${(new Date(parseInt(logs[log].timestamp))).toISOString()}]:${logs[log].message}\n`);
}
})
}
let scenarioCt = 0;
let currentFeature = '';
Before(async function (scenario){
chore(e2e): update selectors and add containerization (#19221) * update: patch in tests from bonitoo-io/selenium-accept-infl2 * fix: add dataExplorer.feature - forgotten yesterday * update: refactor e2e test configuration * update: set actual cloud credentials in config * fix: issue with headless switch in config * update: WIP cloud experim and refactoring to use client libs * update: sync variablesTab with upstream changes * fix: clumsy use of resultObserver without promise * fix: troubleshoot merge issue * wip: Refactor using client APIs. * wip: refactoring tests with new client API * update: tokens tests * wip: fixing variables tests * fix: selectors for settings variables tests * update: update selectors for dashboards and cellEdit * e2e(fix): update selectors for generic popup * e2e(fix): fix note cell test * e2e(circleci): try and force nightly build * e2e(circleci): try and force nightly build bis * e2e(circleci): troubleshoot build issues * e2e(circleci): fix type * e2e(circleci): check circleci build * e2e(circleci): troubleshoot build failure * e2e(circleci): troubleshout circleci build * e2e(circleci): troubleshoot circleci build issues * e2e(circleci): troubleshoot build schedule * e2e(update): wip updating alerts selectors * e2e(circleci): troubleshoot reporting from tests * e2e(update): fix alert selectors - WIP * e2e(circleci): troubleshoot reporting issues in circleci * e2e(update): monitoring selector fixes * e2e(circleci): troubleshoot reporting issues * e2e(update): fix monitoring selectors * e2e(circleci): change cron trigger schedule for bonitoo * e2e(config): add ENV to declare username * test: add semantic commit * e2e: remove debug lines from old config.yml * fix(temp): remove bonitoo workflow from config.yml * fix(e2e): reset cron for hourly-e2e to original values * dataExplorer.feature new scenarios * fix(e2e): generalize urls in telegraf asserts * fix(e2e): troubleshoot circleci build * fix: update .circleci/config.yml nightly acceptance test and sync with upstream * fix(e2e): troubleshoot network issues on jenkins * fix(e2): troubleshoot jenkins failures * fix(e2e): troubleshoot jenkins issues * fix(e2e): troubleshoot jenkins failures * fix(e2e): troubleshoot test issues - change page load strategy * fix(e2e): troubleshoot build issues * fix(e2e): troubleshoot build issues * fix(e2e): add paranoia checks on using UI signin * fix(e2e): troubleshoot test issues * fix(e2e): change handling of env params * fix(e2e): troubleshoot signin stale elem issue * fix(e2e): typo * fix(e2e): synch selectors with recent UI changes * fix(e2e): update check for stale element on signin * fix(e2e): fine tune retry on stale element signin * fix(e2e): lengthen signin retry * fix(e2): try second stale element workaround * fix(e2): attempt to workaround stale element * fix(e2): try cruder solution to stale element on sign in * fix(e2): lengthen timeout for signing page load * fix(e2e): clear notifications before save in dataexplorer * fixes(e2e): update variables button selector * fix(e2e): cleanup data explorer test variable - from browser * fixes(e2e): stash experim changes to cucumber.js * fixes(e2e): troubleshoot deadman check failure * fix(e2e): stash cucumber.js * fix(e2e): update selectors for telegraf delete * fixes(e2e): extend timeout for input to monaco * fixes(e2e): troubleshoot timeout issue on paste into monaco * fixes(e2e): safety commit containerize * fixes(e2e): generic page header no longer applies - temp fix * fixes(e2e): changes to headers temp fixes * chore(e2e): stash acceptance test containerize work * chore(e2e): clean debug messages * feat(e2e): commandline args in containerized test script * fixes(e2e): add junit report generation to container script * fixes(e2e): set delay for selenoid startup * fixes(e2e): stop docker containers after tests * fix(e2e): drop bonitoo argv args before cucumber calls ArgvParser * chore(e2e): update README and remove experim naming * fix(e2e): troubleshoot occasional flake in notification assertions * feat(e2e): add simple performance utility for cloud * feat(e2e): tweek performance util * feat(e2e): start cloud testing with containerized tests * fix(e2e): halt script on unset required params * fix(e2e): remove messages that could leak info * fix(e2e): troubleshoot jenkins credentials * fix(e2e): troubleshoot parameter issues in jenkins * fix(e2e): cleanup troubleshoot code * fix(e2e): update create variables popup selector * fix(e2e): update submit button for template popup * fix(e2e): update selectors for data tokens tests * fix(e2e): sync alerts tests with recent changes * chore(e2e): add cloud specific Dockerfile * chore(e2e): add reporting to cloud dockerfile Co-authored-by: Cubone21 <kyuboun@gmail.com>
2020-08-05 15:22:09 +00:00
__currentFeature = scenario.sourceLocation.uri.substring(scenario.sourceLocation.uri.lastIndexOf("/") + 1).replace('.','-')
__currentScenario = scenario.pickle.name.trim();
2020-05-13 20:49:31 +00:00
//safety kill any live data generator
if(!await scenarioContainsTag(scenario, '@use-live-data') && __liveDataGenRunning){
console.log("killing live generator");
__killLiveDataGen = true;
}
});
async function scenarioContainsTag(scenario, tag){
let match = scenario.pickle.tags.find( elem => elem.name === tag)
//console.log("DEBUG match " + match);
return match !== undefined;
}
After(async function (scenario /*, callback */) {
//__wdriver.sleep(1500) //DEBUG - getting shots out of order
// Handled in cucumber.js
// if(!fs.existsSync(`./${__config.screenshot_dir}`)){
// fs.mkdir(`./${__config.screenshot_dir}`, () => {})
// }
__reportedResetOnce = true;
2020-05-13 20:49:31 +00:00
let uri = scenario.sourceLocation.uri
let feature = uri.substring(uri.lastIndexOf("/") + 1).replace('.','-')
let name = scenario.pickle.name.trim().replace(' ', '_');
name = name.replace('/', '-');
name = name.replace('\\', '-');
if(feature !== currentFeature){
scenarioCt = 0;
}
if(scenarioCt === 0){
currentFeature = feature;
}
// let now = new Date()
// let nowStr = now.getFullYear().toString() +
// (now.getMonth() + 1).toString().padStart(2, '0') +
// now.getDate().toString().padStart(2, '0') + "-" +
// now.getHours().toString().padStart(2, '0') +
// now.getMinutes().toString().padStart(2, '0') +
// now.getSeconds().toString().padStart(2, '0')
//let filebase = __config.screenshot_dir + '/' + feature + "-" + nowStr + "-" + name
let filebase = __screenShotDir + "/" + feature + "-" + (scenarioCt++).toString().padStart(2, '0') + "-" + name;
let world = this;
if(scenario.result.status === Status.FAILED){
await writeScreenShot(filebase + "-ERR" + ".png").then(async img => {
await world.attach(img, 'image/png')
});
await writeConsoleLog(filebase + '-ERR-console.log').catch(async e => {
throw('failed to write ' + filebase + '-ERR-console.log\n' + e);
});
await writeDriverLog(filebase + '-ERR-driver.log').catch(async e => {
throw('failed to write ' + filebase + '-ERR-console.log\n' + e);
})
}else {
await writeScreenShot(filebase + "--OK" + ".png").then(async img => {
await world.attach(img, 'image/png')
})
}
//callback()
});
AfterAll(async function ( ) {
__reportedResetOnce = false;
2020-05-13 20:49:31 +00:00
if(__liveDataGenRunning) {
console.log("killing live generator");
__killLiveDataGen = true;
}
chore(e2e): update selectors and add containerization (#19221) * update: patch in tests from bonitoo-io/selenium-accept-infl2 * fix: add dataExplorer.feature - forgotten yesterday * update: refactor e2e test configuration * update: set actual cloud credentials in config * fix: issue with headless switch in config * update: WIP cloud experim and refactoring to use client libs * update: sync variablesTab with upstream changes * fix: clumsy use of resultObserver without promise * fix: troubleshoot merge issue * wip: Refactor using client APIs. * wip: refactoring tests with new client API * update: tokens tests * wip: fixing variables tests * fix: selectors for settings variables tests * update: update selectors for dashboards and cellEdit * e2e(fix): update selectors for generic popup * e2e(fix): fix note cell test * e2e(circleci): try and force nightly build * e2e(circleci): try and force nightly build bis * e2e(circleci): troubleshoot build issues * e2e(circleci): fix type * e2e(circleci): check circleci build * e2e(circleci): troubleshoot build failure * e2e(circleci): troubleshout circleci build * e2e(circleci): troubleshoot circleci build issues * e2e(circleci): troubleshoot build schedule * e2e(update): wip updating alerts selectors * e2e(circleci): troubleshoot reporting from tests * e2e(update): fix alert selectors - WIP * e2e(circleci): troubleshoot reporting issues in circleci * e2e(update): monitoring selector fixes * e2e(circleci): troubleshoot reporting issues * e2e(update): fix monitoring selectors * e2e(circleci): change cron trigger schedule for bonitoo * e2e(config): add ENV to declare username * test: add semantic commit * e2e: remove debug lines from old config.yml * fix(temp): remove bonitoo workflow from config.yml * fix(e2e): reset cron for hourly-e2e to original values * dataExplorer.feature new scenarios * fix(e2e): generalize urls in telegraf asserts * fix(e2e): troubleshoot circleci build * fix: update .circleci/config.yml nightly acceptance test and sync with upstream * fix(e2e): troubleshoot network issues on jenkins * fix(e2): troubleshoot jenkins failures * fix(e2e): troubleshoot jenkins issues * fix(e2e): troubleshoot jenkins failures * fix(e2e): troubleshoot test issues - change page load strategy * fix(e2e): troubleshoot build issues * fix(e2e): troubleshoot build issues * fix(e2e): add paranoia checks on using UI signin * fix(e2e): troubleshoot test issues * fix(e2e): change handling of env params * fix(e2e): troubleshoot signin stale elem issue * fix(e2e): typo * fix(e2e): synch selectors with recent UI changes * fix(e2e): update check for stale element on signin * fix(e2e): fine tune retry on stale element signin * fix(e2e): lengthen signin retry * fix(e2): try second stale element workaround * fix(e2): attempt to workaround stale element * fix(e2): try cruder solution to stale element on sign in * fix(e2): lengthen timeout for signing page load * fix(e2e): clear notifications before save in dataexplorer * fixes(e2e): update variables button selector * fix(e2e): cleanup data explorer test variable - from browser * fixes(e2e): stash experim changes to cucumber.js * fixes(e2e): troubleshoot deadman check failure * fix(e2e): stash cucumber.js * fix(e2e): update selectors for telegraf delete * fixes(e2e): extend timeout for input to monaco * fixes(e2e): troubleshoot timeout issue on paste into monaco * fixes(e2e): safety commit containerize * fixes(e2e): generic page header no longer applies - temp fix * fixes(e2e): changes to headers temp fixes * chore(e2e): stash acceptance test containerize work * chore(e2e): clean debug messages * feat(e2e): commandline args in containerized test script * fixes(e2e): add junit report generation to container script * fixes(e2e): set delay for selenoid startup * fixes(e2e): stop docker containers after tests * fix(e2e): drop bonitoo argv args before cucumber calls ArgvParser * chore(e2e): update README and remove experim naming * fix(e2e): troubleshoot occasional flake in notification assertions * feat(e2e): add simple performance utility for cloud * feat(e2e): tweek performance util * feat(e2e): start cloud testing with containerized tests * fix(e2e): halt script on unset required params * fix(e2e): remove messages that could leak info * fix(e2e): troubleshoot jenkins credentials * fix(e2e): troubleshoot parameter issues in jenkins * fix(e2e): cleanup troubleshoot code * fix(e2e): update create variables popup selector * fix(e2e): update submit button for template popup * fix(e2e): update selectors for data tokens tests * fix(e2e): sync alerts tests with recent changes * chore(e2e): add cloud specific Dockerfile * chore(e2e): add reporting to cloud dockerfile Co-authored-by: Cubone21 <kyuboun@gmail.com>
2020-08-05 15:22:09 +00:00
if(perfUtils.performanceLog.length > 0){
await perfUtils.writePerformanceLog();
await perfUtils.writePerfomanceReport();
}
2020-05-13 20:49:31 +00:00
});