Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
add travis artifacts
Browse files Browse the repository at this point in the history
Auditors:

Test Plan:
  • Loading branch information
ayumi committed Aug 18, 2017
1 parent e4cda44 commit c8465c2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "7"
- "8"
dist: trusty
sudo: required
group: edge
Expand Down Expand Up @@ -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:
Expand All @@ -39,3 +39,4 @@ addons:
- xvfb
- g++-4.8
- libgnome-keyring-dev
artifacts: true
38 changes: 37 additions & 1 deletion test/lib/profilerUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
34 changes: 27 additions & 7 deletions test/performance/startupTest.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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()
Expand All @@ -51,13 +68,15 @@ describe('Performance startup', function () {
}

it('fresh', function * () {
console.log('starting fresh')
yield restart()
yield profilerUtil.startProfiler(this)
yield runStory.call(this)
yield profilerUtil.stopProfiler(this, 'fresh')
})

it('2000 bookmarks', function * () {
console.log('starting 2000 bookmarks')
yield userProfiles.addBookmarks2000(Brave.app.client)
yield restart()
yield profilerUtil.startProfiler(this)
Expand All @@ -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)
Expand Down

0 comments on commit c8465c2

Please sign in to comment.