@@ -1691,6 +1691,49 @@ describe('e2e', function () {
16911691 ) . join ( '' ) ;
16921692 } ;
16931693
1694+ describe ( 'with custom log compression' , function ( ) {
1695+ const customLogDir = useTmpdir ( ) ;
1696+
1697+ it ( 'should created compressed files when enabled' , async function ( ) {
1698+ const globalConfig = path . join ( homedir , 'globalconfig.conf' ) ;
1699+ await fs . writeFile (
1700+ globalConfig ,
1701+ `mongosh:\n logLocation: ${ JSON . stringify (
1702+ customLogDir . path
1703+ ) } \n logCompression: true`
1704+ ) ;
1705+
1706+ shell = this . startTestShell ( {
1707+ args : [ '--nodb' ] ,
1708+ env : {
1709+ ...env ,
1710+ MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING : globalConfig ,
1711+ } ,
1712+ forceTerminal : true ,
1713+ } ) ;
1714+
1715+ await shell . waitForPrompt ( ) ;
1716+
1717+ const logFile = path . join (
1718+ customLogDir . path ,
1719+ `${ shell . logId as string } _log`
1720+ ) ;
1721+ const logFileGzip = path . join (
1722+ customLogDir . path ,
1723+ `${ shell . logId as string } _log.gz`
1724+ ) ;
1725+
1726+ // Only the gzipped file should exist
1727+ expect ( await getFilesState ( [ logFile , logFileGzip ] ) ) . equals ( '01' ) ;
1728+
1729+ const logContent = await fs . readFile ( logFileGzip ) ;
1730+
1731+ // gzipped files start with 0x1f 0x8b
1732+ expect ( logContent [ 0 ] ) . equals ( 0x1f ) ;
1733+ expect ( logContent [ 1 ] ) . equals ( 0x8b ) ;
1734+ } ) ;
1735+ } ) ;
1736+
16941737 describe ( 'with custom log retention days' , function ( ) {
16951738 const customLogDir = useTmpdir ( ) ;
16961739
0 commit comments