diff --git a/.evergreen/setup-env.sh b/.evergreen/setup-env.sh index fd555dba7..7526c19cc 100755 --- a/.evergreen/setup-env.sh +++ b/.evergreen/setup-env.sh @@ -13,7 +13,8 @@ fi export BASEDIR="$PWD/.evergreen" export PATH="/cygdrive/c/python/Python311/Scripts:/cygdrive/c/python/Python311:/cygdrive/c/Python311/Scripts:/cygdrive/c/Python311:/opt/python/3.6/bin:$BASEDIR/mingit/cmd:$BASEDIR/mingit/mingw64/libexec/git-core:$BASEDIR/git-2:$BASEDIR/npm-10/node_modules/.bin:$BASEDIR/node-v$NODE_JS_VERSION-win-x64:/opt/java/jdk16/bin:/opt/chefdk/gitbin:/cygdrive/c/cmake/bin:$TOOLCHAIN_PATH:$PATH" -export MONGOSH_TEST_ONLY_MAX_LOG_FILE_COUNT=100000 +export MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING="$BASEDIR/../../testing/tests-globalconfig.conf" + export IS_MONGOSH_EVERGREEN_CI=1 export DEBUG="mongodb*,$DEBUG" diff --git a/packages/cli-repl/src/cli-repl.spec.ts b/packages/cli-repl/src/cli-repl.spec.ts index 359f9336c..35ac80653 100644 --- a/packages/cli-repl/src/cli-repl.spec.ts +++ b/packages/cli-repl/src/cli-repl.spec.ts @@ -1463,9 +1463,6 @@ describe('CliRepl', function () { it('can set log max file count', async function () { const testMaxFileCount = 123; cliRepl.config.logMaxFileCount = testMaxFileCount; - const oldEnvironmentLimit = - process.env.MONGOSH_TEST_ONLY_MAX_LOG_FILE_COUNT; - delete process.env.MONGOSH_TEST_ONLY_MAX_LOG_FILE_COUNT; await cliRepl.start(await testServer.connectionString(), {}); expect(await cliRepl.getConfig('logMaxFileCount')).equals( @@ -1474,9 +1471,6 @@ describe('CliRepl', function () { expect(cliRepl.logManager?._options.maxLogFileCount).equals( testMaxFileCount ); - - process.env.MONGOSH_TEST_ONLY_MAX_LOG_FILE_COUNT = - oldEnvironmentLimit; }); it('can set log compression', async function () { diff --git a/packages/cli-repl/src/cli-repl.ts b/packages/cli-repl/src/cli-repl.ts index bc8c718dd..589a02650 100644 --- a/packages/cli-repl/src/cli-repl.ts +++ b/packages/cli-repl/src/cli-repl.ts @@ -261,10 +261,7 @@ export class CliRepl implements MongoshIOProvider { this.shellHomeDirectory.localPath('.'), retentionDays: await this.getConfig('logRetentionDays'), gzip: await this.getConfig('logCompressionEnabled'), - maxLogFileCount: +( - process.env.MONGOSH_TEST_ONLY_MAX_LOG_FILE_COUNT || - (await this.getConfig('logMaxFileCount')) - ), + maxLogFileCount: await this.getConfig('logMaxFileCount'), onerror: (err: Error) => this.bus.emit('mongosh:error', err, 'log'), onwarn: (err: Error, path: string) => this.warnAboutInaccessibleFile(err, path), diff --git a/packages/e2e-tests/test/e2e.spec.ts b/packages/e2e-tests/test/e2e.spec.ts index ca402a2c7..9316dfa16 100644 --- a/packages/e2e-tests/test/e2e.spec.ts +++ b/packages/e2e-tests/test/e2e.spec.ts @@ -1414,7 +1414,7 @@ describe('e2e', function () { startTestShell = async (...extraArgs: string[]) => { const shell = this.startTestShell({ args: ['--nodb', ...extraArgs], - env: env, + env, forceTerminal: true, }); await shell.waitForPrompt(); @@ -1467,10 +1467,8 @@ describe('e2e', function () { ); shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); await shell.waitForPrompt(); @@ -1524,10 +1522,8 @@ describe('e2e', function () { await fs.writeFile(globalConfig, 'mongosh:\n disableLogging: true'); shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); await shell.waitForPrompt(); @@ -1545,10 +1541,8 @@ describe('e2e', function () { await fs.writeFile(globalConfig, 'mongosh:\n disableLogging: false'); shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); await shell.waitForPrompt(); @@ -1580,10 +1574,8 @@ describe('e2e', function () { shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); await shell.waitForPrompt(); @@ -1610,10 +1602,8 @@ describe('e2e', function () { shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); await shell.waitForPrompt(); @@ -1705,10 +1695,8 @@ describe('e2e', function () { shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); @@ -1774,10 +1762,8 @@ describe('e2e', function () { shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); @@ -1818,11 +1804,8 @@ describe('e2e', function () { expect(await getFilesState(paths)).to.equal('1111111111'); shell = this.startTestShell({ args: ['--nodb'], - env: { - ...env, - MONGOSH_TEST_ONLY_MAX_LOG_FILE_COUNT: '', - MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: globalConfig, - }, + env, + globalConfigPath: globalConfig, forceTerminal: true, }); diff --git a/packages/e2e-tests/test/test-shell.ts b/packages/e2e-tests/test/test-shell.ts index 3a5d870b8..7024255e1 100644 --- a/packages/e2e-tests/test/test-shell.ts +++ b/packages/e2e-tests/test/test-shell.ts @@ -39,6 +39,7 @@ export interface TestShellOptions { cwd?: string; forceTerminal?: boolean; consumeStdio?: boolean; + globalConfigPath?: string; } /** @@ -63,6 +64,13 @@ export class TestShell { env = { ...env, MONGOSH_FORCE_TERMINAL: '1' }; } + if (options.globalConfigPath) { + env = { + ...env, + MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING: options.globalConfigPath, + }; + } + const args = [...options.args]; if (process.env.MONGOSH_TEST_E2E_FORCE_FIPS) { args.push('--tlsFIPSMode'); diff --git a/testing/tests-globalconfig.conf b/testing/tests-globalconfig.conf new file mode 100644 index 000000000..e90115218 --- /dev/null +++ b/testing/tests-globalconfig.conf @@ -0,0 +1,3 @@ +# Default global configuration used by tests +mongosh: + logMaxFileCount: 100000 \ No newline at end of file