ci: refs#6706 Jenkinsfile tuning & parallel back test (unstable, disabled)
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
766008ce1a
commit
f2071d39ec
|
@ -53,7 +53,7 @@ pipeline {
|
|||
TZ = 'Europe/Madrid'
|
||||
}
|
||||
parallel {
|
||||
stage('Backend') {
|
||||
stage('Back') {
|
||||
stages {
|
||||
stage('Install') {
|
||||
environment {
|
||||
|
@ -97,7 +97,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
stage('Frontend') {
|
||||
stage('Front') {
|
||||
when {
|
||||
expression { FROM_GIT }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/* eslint-disable no-console */
|
||||
const app = require('vn-loopback/server/server');
|
||||
let dataSources = require('../loopback/server/datasources.json');
|
||||
|
||||
async function init() {
|
||||
console.log('Initializing backend.');
|
||||
|
||||
dataSources = JSON.parse(JSON.stringify(dataSources));
|
||||
Object.assign(dataSources.vn, {
|
||||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT
|
||||
});
|
||||
|
||||
const bootOptions = {dataSources};
|
||||
await new Promise((resolve, reject) => {
|
||||
app.boot(bootOptions,
|
||||
err => err ? reject(err) : resolve());
|
||||
});
|
||||
// FIXME: Workaround to wait for loopback to be ready
|
||||
await app.models.Application.status();
|
||||
}
|
||||
|
||||
async function deinit() {
|
||||
console.log('Stopping backend.');
|
||||
await app.disconnect();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init,
|
||||
deinit
|
||||
};
|
||||
|
||||
if (require.main === module)
|
||||
init();
|
136
back/tests.js
136
back/tests.js
|
@ -2,30 +2,21 @@
|
|||
const path = require('path');
|
||||
const Myt = require('@verdnatura/myt/myt');
|
||||
const Run = require('@verdnatura/myt/myt-run');
|
||||
let dataSources = require('../loopback/server/datasources.json');
|
||||
const helper = require('./tests-helper');
|
||||
|
||||
let server;
|
||||
const isCI = process.argv[2] === 'ci';
|
||||
const PARALLEL = false;
|
||||
const TIMEOUT = 900000;
|
||||
|
||||
process.on('warning', warning => {
|
||||
console.log(warning.name);
|
||||
console.log(warning.message);
|
||||
console.log(warning.stack);
|
||||
});
|
||||
process.on('SIGINT', teardown);
|
||||
process.on('exit', teardown);
|
||||
process.on('uncaughtException', onError);
|
||||
process.on('unhandledRejection', onError);
|
||||
|
||||
process.on('SIGUSR2', rmServer);
|
||||
process.on('exit', rmServer);
|
||||
|
||||
async function rmServer() {
|
||||
if (!server) return;
|
||||
await server.rm();
|
||||
server = null;
|
||||
}
|
||||
|
||||
async function test() {
|
||||
async function setup() {
|
||||
console.log('Building and running DB container.');
|
||||
|
||||
const isCI = process.argv[2] === 'ci';
|
||||
|
||||
const myt = new Myt();
|
||||
await myt.init({
|
||||
workspace: path.join(__dirname, '..'),
|
||||
|
@ -36,69 +27,76 @@ async function test() {
|
|||
});
|
||||
server = await myt.run(Run);
|
||||
await myt.deinit();
|
||||
|
||||
const {dbConfig} = server;
|
||||
process.env.DB_HOST = dbConfig.host;
|
||||
process.env.DB_PORT = dbConfig.port;
|
||||
|
||||
console.log('Initializing backend.');
|
||||
if (!PARALLEL)
|
||||
await helper.init();
|
||||
}
|
||||
|
||||
dataSources = JSON.parse(JSON.stringify(dataSources));
|
||||
Object.assign(dataSources.vn, {
|
||||
host: dbConfig.host,
|
||||
port: dbConfig.port
|
||||
});
|
||||
async function teardown() {
|
||||
if (!server) return;
|
||||
|
||||
const bootOptions = {dataSources};
|
||||
const app = require('vn-loopback/server/server');
|
||||
await new Promise((resolve, reject) => {
|
||||
app.boot(bootOptions,
|
||||
err => err ? reject(err) : resolve());
|
||||
});
|
||||
// FIXME: Workaround to wait for loopback to be ready
|
||||
await app.models.Application.status();
|
||||
if (!PARALLEL)
|
||||
await helper.deinit();
|
||||
|
||||
console.log('Running tests.');
|
||||
console.log('Stopping and removing DB container.');
|
||||
await server.rm();
|
||||
server = null;
|
||||
}
|
||||
|
||||
const Jasmine = require('jasmine');
|
||||
const jasmine = new Jasmine();
|
||||
async function onError(err) {
|
||||
await teardown();
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
||||
jasmine.addReporter(new SpecReporter({
|
||||
spec: {
|
||||
displaySuccessful: isCI,
|
||||
displayPending: isCI
|
||||
},
|
||||
summary: {
|
||||
displayPending: false,
|
||||
}
|
||||
}));
|
||||
async function test() {
|
||||
let runner;
|
||||
const config = {
|
||||
globalSetup: setup,
|
||||
globalSetupTimeout: TIMEOUT,
|
||||
globalTeardown: teardown,
|
||||
globalTeardownTimeout: TIMEOUT,
|
||||
spec_dir: '.',
|
||||
spec_files: [
|
||||
'back/**/*[sS]pec.js',
|
||||
'loopback/**/*[sS]pec.js',
|
||||
'modules/*/back/**/*.[sS]pec.js'
|
||||
],
|
||||
helpers: []
|
||||
};
|
||||
|
||||
if (PARALLEL) {
|
||||
const ParallelRunner = require('jasmine/parallel');
|
||||
runner = new ParallelRunner({numWorkers: 1});
|
||||
config.helpers.push(`back/tests-helper.js`);
|
||||
} else {
|
||||
const Jasmine = require('jasmine');
|
||||
runner = new Jasmine();
|
||||
|
||||
const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
||||
runner.addReporter(new SpecReporter({
|
||||
spec: {
|
||||
displaySuccessful: isCI,
|
||||
displayPending: isCI
|
||||
},
|
||||
summary: {
|
||||
displayPending: false,
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (isCI) {
|
||||
const JunitReporter = require('jasmine-reporters');
|
||||
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
|
||||
|
||||
jasmine.exitOnCompletion = true;
|
||||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 900000;
|
||||
runner.addReporter(new JunitReporter.JUnitXmlReporter());
|
||||
runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
|
||||
}
|
||||
|
||||
const backSpecs = [
|
||||
'./back/**/*[sS]pec.js',
|
||||
'./loopback/**/*[sS]pec.js',
|
||||
'./modules/*/back/**/*.[sS]pec.js'
|
||||
];
|
||||
|
||||
jasmine.loadConfig({
|
||||
spec_dir: '.',
|
||||
spec_files: backSpecs,
|
||||
helpers: [],
|
||||
});
|
||||
|
||||
await jasmine.execute();
|
||||
|
||||
console.log('Stopping.');
|
||||
|
||||
if (app) await app.disconnect();
|
||||
await rmServer();
|
||||
|
||||
console.log('Tests ended.\n');
|
||||
// runner.loadConfigFile('back/jasmine.json');
|
||||
runner.loadConfig(config);
|
||||
await runner.execute();
|
||||
}
|
||||
|
||||
test();
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
"html-loader-jest": "^0.2.1",
|
||||
"html-webpack-plugin": "^5.5.1",
|
||||
"identity-obj-proxy": "^3.0.0",
|
||||
"jasmine": "^5.0.0",
|
||||
"jasmine": "^5.0.2",
|
||||
"jasmine-reporters": "^2.4.0",
|
||||
"jasmine-spec-reporter": "^7.0.0",
|
||||
"jest": "^26.0.1",
|
||||
|
|
|
@ -206,8 +206,8 @@ devDependencies:
|
|||
specifier: ^3.0.0
|
||||
version: 3.0.0
|
||||
jasmine:
|
||||
specifier: ^5.0.0
|
||||
version: 5.1.0
|
||||
specifier: ^5.0.2
|
||||
version: 5.0.2
|
||||
jasmine-reporters:
|
||||
specifier: ^2.4.0
|
||||
version: 2.5.2
|
||||
|
@ -8020,8 +8020,8 @@ packages:
|
|||
filelist: 1.0.4
|
||||
minimatch: 3.1.2
|
||||
|
||||
/jasmine-core@5.1.1:
|
||||
resolution: {integrity: sha512-UrzO3fL7nnxlQXlvTynNAenL+21oUQRlzqQFsA2U11ryb4+NLOCOePZ70PTojEaUKhiFugh7dG0Q+I58xlPdWg==}
|
||||
/jasmine-core@5.0.1:
|
||||
resolution: {integrity: sha512-D4bRej8CplwNtNGyTPD++cafJlZUphzZNV+MSAnbD3er4D0NjL4x9V+mu/SI+5129utnCBen23JwEuBZA9vlpQ==}
|
||||
dev: true
|
||||
|
||||
/jasmine-reporters@2.5.2:
|
||||
|
@ -8037,12 +8037,12 @@ packages:
|
|||
colors: 1.4.0
|
||||
dev: true
|
||||
|
||||
/jasmine@5.1.0:
|
||||
resolution: {integrity: sha512-prmJlC1dbLhti4nE4XAPDWmfJesYO15sjGXVp7Cs7Ym5I9Xtwa/hUHxxJXjnpfLO72+ySttA0Ztf8g/RiVnUKw==}
|
||||
/jasmine@5.0.2:
|
||||
resolution: {integrity: sha512-fXgPcWfDhENJJVktFZc/JJ+TpdOQIMJTbn6BgSOIneBagrHtKvnyA8Ag6uD8eF2m7cSESG7K/Hfj/Hk5asAwNg==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
glob: 10.3.10
|
||||
jasmine-core: 5.1.1
|
||||
jasmine-core: 5.0.1
|
||||
dev: true
|
||||
|
||||
/jayson@2.1.2:
|
||||
|
|
Loading…
Reference in New Issue