From c80c8a567887a114c28ea2cb7e303fb80c68eb18 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jan 2024 10:00:35 +0100 Subject: [PATCH 1/2] fix: refs #5483 No apply changes of db in dev --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index c8a0579d7..c65b01d47 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -101,6 +101,7 @@ pipeline { } stage('Database') { when { anyOf { + branch 'dev' branch 'test' branch 'master' }} From c1726f93904ad909fb1b9c8c89eae228c58db492 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 30 Jan 2024 10:23:32 +0100 Subject: [PATCH 2/2] fix: refs #5483 Remove DB container when back tests end --- back/tests.js | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/back/tests.js b/back/tests.js index a9cdeb338..c4c477090 100644 --- a/back/tests.js +++ b/back/tests.js @@ -1,9 +1,10 @@ +/* eslint-disable no-console */ const path = require('path'); const Myt = require('@verdnatura/myt/myt'); const Run = require('@verdnatura/myt/myt-run'); let dataSources = require('../loopback/server/datasources.json'); -let myt; +let server; process.on('warning', warning => { console.log(warning.name); @@ -11,26 +12,33 @@ process.on('warning', warning => { console.log(warning.stack); }); -process.on('SIGUSR2', async() => { - if (myt) await myt.deinit(); -}); +process.on('SIGUSR2', rmServer); +process.on('exit', rmServer); -process.on('exit', async function() { - if (myt) await myt.deinit(); -}); +async function rmServer() { + if (!server) return; + await server.rm(); + server = null; +} async function test() { + console.log('Building and running DB container.'); + const isCI = process.argv[2] === 'ci'; - myt = new Myt(); + const myt = new Myt(); await myt.init({ workspace: path.join(__dirname, '..'), random: true, ci: isCI, - tmpfs: true, + tmpfs: process.platform == 'linux', 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)); Object.assign(dataSources.vn, { @@ -47,6 +55,8 @@ async function test() { // FIXME: Workaround to wait for loopback to be ready await app.models.Application.status(); + console.log('Running tests.'); + const Jasmine = require('jasmine'); const jasmine = new Jasmine(); @@ -82,9 +92,13 @@ async function test() { }); await jasmine.execute(); + + console.log('Stopping.'); + if (app) await app.disconnect(); - if (myt) await myt.deinit(); - console.log('App disconnected & container removed'); + await rmServer(); + + console.log('Tests ended.\n'); } test();