From 1ff78b03747b42ce8f23eda680452888daac0fd1 Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 11 Oct 2024 17:51:44 -0500 Subject: [PATCH] Add dataPath option to mongo config --- docs/docs.md | 6 ++++++ package-lock.json | 2 +- src/plugins/mongo/__tests__/index.js | 31 +++++++++++++-------------- src/plugins/mongo/command-handlers.js | 2 +- src/plugins/mongo/validate.js | 1 + tests/fixtures/project-mongo-6/mup.js | 1 + 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 28e60e75..03365b0b 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -249,6 +249,12 @@ module.exports = { // (optional, default is 3.4.1) Version of MongoDB version: '3.4.1', + // (optional, default is the name of the app) + dbName: 'maps', + + // (optional, default is /var/lib/mongodb) Folder to store the mongodb data + dataPath: '/var/lib/mongodb', + servers: { one: {} } diff --git a/package-lock.json b/package-lock.json index 4fd778ca..eced6ccc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mup", - "version": "1.5.10", + "version": "1.5.11-beta.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/plugins/mongo/__tests__/index.js b/src/plugins/mongo/__tests__/index.js index e584c5d0..e14f7b25 100644 --- a/src/plugins/mongo/__tests__/index.js +++ b/src/plugins/mongo/__tests__/index.js @@ -76,6 +76,21 @@ describe('module - mongo', function() { 1 ); }); + + it('should start Mongo 6', async () => { + const serverInfo = servers.mymongo; + sh.cd(path.resolve(os.tmpdir(), 'tests/project-mongo-6')); + sh.exec('mup docker setup && mup mongo setup'); + const out = sh.exec('mup mongo start'); + expect(out.code).to.be.equal(0); + + expect(countOccurrences('Start Mongo: SUCCESS', out.stdout)).to.be.equal( + 1 + ); + expect( + (await runSSHCommand(serverInfo, 'nc -z -v -w5 localhost 27017')).code + ).to.be.equal(0); + }); }); describe('stop', () => { @@ -94,21 +109,5 @@ describe('module - mongo', function() { (await runSSHCommand(serverInfo, 'nc -z -v -w5 localhost 27017')).code ).to.be.equal(1); }); - - it('should start Mongo 6', async () => { - const serverInfo = servers.mymongo; - sh.cd(path.resolve(os.tmpdir(), 'tests/project-mongo-6')); - sh.exec('mup docker setup && mup mongo setup'); - - const out = sh.exec('mup mongo start'); - expect(out.code).to.be.equal(0); - - expect(countOccurrences('Start Mongo: SUCCESS', out.stdout)).to.be.equal( - 1 - ); - expect( - (await runSSHCommand(serverInfo, 'nc -z -v -w5 localhost 27017')).code - ).to.be.equal(0); - }); }); }); diff --git a/src/plugins/mongo/command-handlers.js b/src/plugins/mongo/command-handlers.js index 18f804d3..d2c29ede 100644 --- a/src/plugins/mongo/command-handlers.js +++ b/src/plugins/mongo/command-handlers.js @@ -58,7 +58,7 @@ export function setup(api) { vars: { mongoVersion: mongoConfig.version, mongoshCmd: mongoConfig.version.split('.')[0] > 5 ? 'mongosh' : 'mongo', - mongoDbDir: '/var/lib/mongodb' + mongoDbDir: mongoConfig.dataPath || '/var/lib/mongodb' } }); diff --git a/src/plugins/mongo/validate.js b/src/plugins/mongo/validate.js index 79bd6743..b2746a6e 100644 --- a/src/plugins/mongo/validate.js +++ b/src/plugins/mongo/validate.js @@ -7,6 +7,7 @@ const schema = joi.object().keys({ oplog: joi.bool(), port: joi.number(), dbName: joi.string(), + dataPath: joi.string(), version: joi.string(), servers: joi.object().keys().required() }); diff --git a/tests/fixtures/project-mongo-6/mup.js b/tests/fixtures/project-mongo-6/mup.js index 7f3a837f..373a4c0c 100644 --- a/tests/fixtures/project-mongo-6/mup.js +++ b/tests/fixtures/project-mongo-6/mup.js @@ -31,6 +31,7 @@ module.exports = { }, mongo: { version: '6.0.18', + dataPath: '/opt/mongo-5-data', servers: { mymongo: {} }