Compare commits

...

3 Commits

Author SHA1 Message Date
Juanjo Breso a6c0bf8766 Merge branch 'dev' into 6686-Limpieza-vistas-esquema-vn2008-part3
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-01-30 12:00:22 +00:00
Juan Ferrer acf47468c0 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head There was a failure building this commit Details
2024-01-30 10:23:34 +01:00
Juan Ferrer c1726f9390 fix: refs #5483 Remove DB container when back tests end 2024-01-30 10:23:32 +01:00
1 changed files with 26 additions and 12 deletions

View File

@ -1,9 +1,10 @@
/* eslint-disable no-console */
const path = require('path'); const path = require('path');
const Myt = require('@verdnatura/myt/myt'); const Myt = require('@verdnatura/myt/myt');
const Run = require('@verdnatura/myt/myt-run'); const Run = require('@verdnatura/myt/myt-run');
let dataSources = require('../loopback/server/datasources.json'); let dataSources = require('../loopback/server/datasources.json');
let myt; let server;
process.on('warning', warning => { process.on('warning', warning => {
console.log(warning.name); console.log(warning.name);
@ -11,26 +12,33 @@ process.on('warning', warning => {
console.log(warning.stack); console.log(warning.stack);
}); });
process.on('SIGUSR2', async() => { process.on('SIGUSR2', rmServer);
if (myt) await myt.deinit(); process.on('exit', rmServer);
});
process.on('exit', async function() { async function rmServer() {
if (myt) await myt.deinit(); if (!server) return;
}); await server.rm();
server = null;
}
async function test() { async function test() {
console.log('Building and running DB container.');
const isCI = process.argv[2] === 'ci'; const isCI = process.argv[2] === 'ci';
myt = new Myt(); const myt = new Myt();
await myt.init({ await myt.init({
workspace: path.join(__dirname, '..'), workspace: path.join(__dirname, '..'),
random: true, random: true,
ci: isCI, ci: isCI,
tmpfs: true, tmpfs: process.platform == 'linux',
network: isCI ? 'jenkins' : null network: isCI ? 'jenkins' : null
}); });
const {dbConfig} = await myt.run(Run); server = await myt.run(Run);
await myt.deinit();
const {dbConfig} = server;
console.log('Initializing backend.');
dataSources = JSON.parse(JSON.stringify(dataSources)); dataSources = JSON.parse(JSON.stringify(dataSources));
Object.assign(dataSources.vn, { Object.assign(dataSources.vn, {
@ -47,6 +55,8 @@ async function test() {
// FIXME: Workaround to wait for loopback to be ready // FIXME: Workaround to wait for loopback to be ready
await app.models.Application.status(); await app.models.Application.status();
console.log('Running tests.');
const Jasmine = require('jasmine'); const Jasmine = require('jasmine');
const jasmine = new Jasmine(); const jasmine = new Jasmine();
@ -82,9 +92,13 @@ async function test() {
}); });
await jasmine.execute(); await jasmine.execute();
console.log('Stopping.');
if (app) await app.disconnect(); if (app) await app.disconnect();
if (myt) await myt.deinit(); await rmServer();
console.log('App disconnected & container removed');
console.log('Tests ended.\n');
} }
test(); test();