mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Changed to use debug not console in acceptance tests
- In an ideal world, our acceptance tests would be much, much faster - ATM we output how much time is spent on reloading Ghost for each suite, but this is output with console - Changed this to use DEBUG, so we don't clutter the UI normally - Added further debug statements, and a cumulative time, so we can see where time is spent/wasted - Added a DEBUG command for running acceptance tests with this output - This shows us that reloading Ghost accounts for 50% of the test time
This commit is contained in:
parent
b1b09efd75
commit
1dda2cd931
@ -28,6 +28,7 @@
|
|||||||
"build": "grunt build",
|
"build": "grunt build",
|
||||||
"test": "mocha --require=test/utils/overrides.js --exit --trace-warnings --recursive --timeout=60000",
|
"test": "mocha --require=test/utils/overrides.js --exit --trace-warnings --recursive --timeout=60000",
|
||||||
"test:all": "yarn test:unit && yarn test:acceptance && yarn test:regression",
|
"test:all": "yarn test:unit && yarn test:acceptance && yarn test:regression",
|
||||||
|
"test:debug": "DEBUG=ghost:test* yarn test",
|
||||||
"test:unit": "mocha --require=test/utils/overrides.js --exit --trace-warnings './test/unit/**/*_spec.js' --timeout=7000",
|
"test:unit": "mocha --require=test/utils/overrides.js --exit --trace-warnings './test/unit/**/*_spec.js' --timeout=7000",
|
||||||
"test:acceptance": "mocha --require=test/utils/overrides.js --exit --trace-warnings './test/api-acceptance/**/*_spec.js' './test/frontend-acceptance/**/*_spec.js' --timeout=10000",
|
"test:acceptance": "mocha --require=test/utils/overrides.js --exit --trace-warnings './test/api-acceptance/**/*_spec.js' './test/frontend-acceptance/**/*_spec.js' --timeout=10000",
|
||||||
"test:regression": "mocha --require=test/utils/overrides.js --exit --trace-warnings './test/regression/**/*_spec.js' --timeout=60000",
|
"test:regression": "mocha --require=test/utils/overrides.js --exit --trace-warnings './test/regression/**/*_spec.js' --timeout=60000",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Utility Packages
|
// Utility Packages
|
||||||
|
const debug = require('@tryghost/debug')('test');
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
@ -29,6 +30,7 @@ const context = require('./fixtures/context');
|
|||||||
|
|
||||||
let ghostServer;
|
let ghostServer;
|
||||||
let existingData = {};
|
let existingData = {};
|
||||||
|
let totalStartTime = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Because we use ObjectID we don't know the ID of fixtures ahead of time
|
* Because we use ObjectID we don't know the ID of fixtures ahead of time
|
||||||
@ -95,26 +97,29 @@ const prepareContentFolder = (options) => {
|
|||||||
// - re-run default fixtures
|
// - re-run default fixtures
|
||||||
// - reload affected services
|
// - reload affected services
|
||||||
const restartModeGhostStart = async () => {
|
const restartModeGhostStart = async () => {
|
||||||
console.log('Restart Mode'); // eslint-disable-line no-console
|
debug('Reload Mode');
|
||||||
|
|
||||||
// Teardown truncates all tables and also calls urlServiceUtils.reset();
|
// Teardown truncates all tables and also calls urlServiceUtils.reset();
|
||||||
await dbUtils.teardown();
|
await dbUtils.teardown();
|
||||||
|
|
||||||
// The tables have been truncated, this runs the fixture init task (init file 2) to re-add our default fixtures
|
// The tables have been truncated, this runs the fixture init task (init file 2) to re-add our default fixtures
|
||||||
await knexMigrator.init({only: 2});
|
await knexMigrator.init({only: 2});
|
||||||
|
debug('init done');
|
||||||
|
|
||||||
// Reset the settings cache
|
// Reset the settings cache
|
||||||
await settingsService.init();
|
await settingsService.init();
|
||||||
|
debug('settings done');
|
||||||
|
|
||||||
// Reload the frontend
|
// Reload the frontend
|
||||||
await frontendSettingsService.init();
|
await frontendSettingsService.init();
|
||||||
await themeService.init();
|
await themeService.init();
|
||||||
|
debug('frontend done');
|
||||||
|
|
||||||
// Reload the URL service & wait for it to be ready again
|
// Reload the URL service & wait for it to be ready again
|
||||||
// @TODO: why/how is this different to urlService.resetGenerators?
|
// @TODO: why/how is this different to urlService.resetGenerators?
|
||||||
urlServiceUtils.reset();
|
urlServiceUtils.reset();
|
||||||
urlServiceUtils.init();
|
urlServiceUtils.init();
|
||||||
await urlServiceUtils.isFinished();
|
await urlServiceUtils.isFinished();
|
||||||
|
debug('routes done');
|
||||||
// @TODO: why does this happen _after_ URL service
|
// @TODO: why does this happen _after_ URL service
|
||||||
web.shared.middlewares.customRedirects.reload();
|
web.shared.middlewares.customRedirects.reload();
|
||||||
|
|
||||||
@ -135,9 +140,9 @@ const bootGhost = async () => {
|
|||||||
// - Start Ghost: Uses OLD Boot process
|
// - Start Ghost: Uses OLD Boot process
|
||||||
const freshModeGhostStart = async (options) => {
|
const freshModeGhostStart = async (options) => {
|
||||||
if (options.forceStart) {
|
if (options.forceStart) {
|
||||||
console.log('Force Start Mode'); // eslint-disable-line no-console
|
debug('Forced Restart Mode');
|
||||||
} else {
|
} else {
|
||||||
console.log('Fresh Start Mode'); // eslint-disable-line no-console
|
debug('Fresh Start Mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the DB
|
// Reset the DB
|
||||||
@ -171,7 +176,8 @@ const freshModeGhostStart = async (options) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const startGhost = async (options) => {
|
const startGhost = async (options) => {
|
||||||
console.time('Start Ghost'); // eslint-disable-line no-console
|
const startTime = Date.now();
|
||||||
|
debug('Start Ghost');
|
||||||
options = _.merge({
|
options = _.merge({
|
||||||
redirectsFile: true,
|
redirectsFile: true,
|
||||||
redirectsFileExt: '.json',
|
redirectsFileExt: '.json',
|
||||||
@ -194,7 +200,12 @@ const startGhost = async (options) => {
|
|||||||
|
|
||||||
// Expose fixture data, wrap-up and return
|
// Expose fixture data, wrap-up and return
|
||||||
await exposeFixtures();
|
await exposeFixtures();
|
||||||
console.timeEnd('Start Ghost'); // eslint-disable-line no-console
|
|
||||||
|
// Reporting
|
||||||
|
const totalTime = Date.now() - startTime;
|
||||||
|
totalStartTime += totalTime;
|
||||||
|
debug(`Started Ghost in ${totalTime / 1000}s`);
|
||||||
|
debug(`Accumulated start time is ${totalStartTime / 1000}s`);
|
||||||
return ghostServer;
|
return ghostServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user