From c8465c210b3ecac0a340067718418b5bc1fb3251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BD=81=EF=BD=99=EF=BD=95=EF=BD=8D=EF=BD=89=C2=A0=20?= =?UTF-8?q?=EF=BD=99=EF=BD=95?= Date: Thu, 17 Aug 2017 21:29:08 +0000 Subject: [PATCH] add travis artifacts Auditors: Test Plan: --- .travis.yml | 5 +++-- test/lib/profilerUtil.js | 38 ++++++++++++++++++++++++++++++++- test/performance/startupTest.js | 34 +++++++++++++++++++++++------ 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 959ba539ebb..ee42c566fbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "7" + - "8" dist: trusty sudo: required group: edge @@ -29,7 +29,7 @@ env: - CXX=g++-4.8 NODE_ENV=test TEST_DIR=contents - CXX=g++-4.8 NODE_ENV=test TEST_DIR=misc-components - CXX=g++-4.8 NODE_ENV=test TEST_DIR=navbar-components - - CXX=g++-4.8 NODE_ENV=test TEST_DIR=performance + - CXX=g++-4.8 NODE_ENV=test TEST_DIR=performance BRAVE_TEST_ALL_LOGS=1 ARTIFACTS_DEBUG=1 ARTIFACTS_REGION=us-west-2 - CXX=g++-4.8 NODE_ENV=test TEST_DIR=tab-components addons: apt: @@ -39,3 +39,4 @@ addons: - xvfb - g++-4.8 - libgnome-keyring-dev + artifacts: true diff --git a/test/lib/profilerUtil.js b/test/lib/profilerUtil.js index 0e2fe939e37..a9ec31628a4 100644 --- a/test/lib/profilerUtil.js +++ b/test/lib/profilerUtil.js @@ -9,6 +9,35 @@ const fs = require('fs') const LOG_FOLDER = './cpu-profiles' +// Private +// === +/** + * Wrap child_process.exec() so it returns a Promise. + */ +const execPromise = function () { + const exec = require('child_process').exec + const child = exec.apply(this, arguments) + return new Promise((resolve, reject) => { + child.stdout.on('data', (data) => { + console.log('stdout: ' + data) + }) + child.stderr.on('data', (data) => { + console.log('stderr: ' + data) + }) + child.on('close', (code) => { + if (code !== 0) { + console.log(`exited with code ${code}`) + reject(code) + } else { + resolve(code) + } + }) + }) +} + +// Public +// === + /** * Connect to a remote instance using Chrome Debugging Protocol and enable * the Profiler. Afterwards you need to profiler.start @@ -48,8 +77,15 @@ const stopProfiler = function * (context, tag = '') { return filename } +const uploadTravisArtifacts = function * () { + if (!process.env.TRAVIS) { return } + console.log('Uploading Travis artifacts...') + yield execPromise(`artifacts upload ${LOG_FOLDER}`) +} + module.exports = { initProfiler, startProfiler, - stopProfiler + stopProfiler, + uploadTravisArtifacts } diff --git a/test/performance/startupTest.js b/test/performance/startupTest.js index 7b8370e49ac..50c8cecf64e 100644 --- a/test/performance/startupTest.js +++ b/test/performance/startupTest.js @@ -1,4 +1,4 @@ -/* global describe, it, beforeEach, afterEach */ +/* global describe, it, before, beforeEach, afterEach */ const Brave = require('../lib/brave') const profilerUtil = require('../lib/profilerUtil') @@ -9,30 +9,47 @@ describe('Performance startup', function () { Brave.beforeAllServerSetup(this) function * setup () { - yield Brave.startApp() + console.log('setup') Brave.addCommands() + } + + function * setupBrave () { + console.log('setupBrave') + yield Brave.startApp() + yield setup(Brave.app.client) yield Brave.app.client - .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() } function * restart (timeout = 1000) { + console.log('restart') // XXX Wait for Brave to fully shutdown and free up inspect port 9222 yield Brave.stopApp(false, timeout) - yield Brave.startApp() - Brave.addCommands() + yield setupBrave() } - beforeEach(function * () { + before(function * () { + console.log('before') this.url = Brave.server.url('page1.html') - yield setup() + }) + + beforeEach(function * () { + console.log('beforeEach') + yield setupBrave() }) afterEach(function * () { + console.log('afterEach') yield Brave.stopApp() }) + this.afterAll(function * () { + console.log('afterAll') + yield profilerUtil.uploadTravisArtifacts() + }) + function * runStory () { + console.log('runStory') yield Brave.app.client .waitForUrl(Brave.newTabUrl, 10000, 250) .waitForBrowserWindow() @@ -51,6 +68,7 @@ describe('Performance startup', function () { } it('fresh', function * () { + console.log('starting fresh') yield restart() yield profilerUtil.startProfiler(this) yield runStory.call(this) @@ -58,6 +76,7 @@ describe('Performance startup', function () { }) it('2000 bookmarks', function * () { + console.log('starting 2000 bookmarks') yield userProfiles.addBookmarks2000(Brave.app.client) yield restart() yield profilerUtil.startProfiler(this) @@ -66,6 +85,7 @@ describe('Performance startup', function () { }) it('100 tabs', function * () { + console.log('starting 100 tabs') yield userProfiles.addTabs100(Brave.app.client) yield restart(5000) yield profilerUtil.startProfiler(this)