@@ -1722,10 +1722,10 @@ describe('e2e', function () {
1722
1722
} ) ;
1723
1723
} ) ;
1724
1724
1725
- describe ( 'with custom log retention days ' , function ( ) {
1725
+ describe ( 'with logRetentionDays ' , function ( ) {
1726
1726
const customLogDir = useTmpdir ( ) ;
1727
1727
1728
- it ( 'should delete older files according to the setting ' , async function ( ) {
1728
+ it ( 'should delete older files older than logRetentionDays ' , async function ( ) {
1729
1729
const paths : string [ ] = [ ] ;
1730
1730
const today = Math . floor ( Date . now ( ) / 1000 ) ;
1731
1731
const tenDaysAgo = today - 10 * 24 * 60 * 60 ;
@@ -1776,10 +1776,10 @@ describe('e2e', function () {
1776
1776
} ) ;
1777
1777
} ) ;
1778
1778
1779
- describe ( 'with custom log retention max file count ' , function ( ) {
1779
+ describe ( 'with logMaxFileCount ' , function ( ) {
1780
1780
const customLogDir = useTmpdir ( ) ;
1781
1781
1782
- it ( 'should delete files once it is above the max file count limit ' , async function ( ) {
1782
+ it ( 'should delete files once it is above logMaxFileCount ' , async function ( ) {
1783
1783
const globalConfig = path . join ( homedir , 'globalconfig.conf' ) ;
1784
1784
await fs . writeFile (
1785
1785
globalConfig ,
@@ -1825,28 +1825,28 @@ describe('e2e', function () {
1825
1825
} ) ;
1826
1826
} ) ;
1827
1827
1828
- describe ( 'with custom log retention max logs size ' , function ( ) {
1828
+ describe ( 'with logRetentionGB ' , function ( ) {
1829
1829
const customLogDir = useTmpdir ( ) ;
1830
1830
1831
- it ( 'should delete files once it is above the logs retention GB ' , async function ( ) {
1831
+ it ( 'should delete files once it is above logRetentionGB ' , async function ( ) {
1832
1832
const globalConfig = path . join ( homedir , 'globalconfig.conf' ) ;
1833
1833
await fs . writeFile (
1834
1834
globalConfig ,
1835
- // Set logRetentionGB to 4 KB
1835
+ // Set logRetentionGB to 40 KB and we will create prior 10 log files, 10 KB each
1836
1836
`mongosh:\n logLocation: ${ JSON . stringify (
1837
1837
customLogDir . path
1838
- ) } \n logRetentionGB: ${ 4 / 1024 / 1024 } `
1838
+ ) } \n logRetentionGB: ${ 40 / 1024 / 1024 } `
1839
1839
) ;
1840
1840
const paths : string [ ] = [ ] ;
1841
1841
const offset = Math . floor ( Date . now ( ) / 1000 ) ;
1842
1842
1843
- // Create 10 log files, 1kb each
1843
+ // Create 10 log files, 10kb each
1844
1844
for ( let i = 9 ; i >= 0 ; i -- ) {
1845
1845
const filename = path . join (
1846
1846
customLogDir . path ,
1847
1847
ObjectId . createFromTime ( offset - i ) . toHexString ( ) + '_log'
1848
1848
) ;
1849
- await fs . writeFile ( filename , '0' . repeat ( 1024 ) ) ;
1849
+ await fs . writeFile ( filename , '0' . repeat ( 1024 * 10 ) ) ;
1850
1850
paths . push ( filename ) ;
1851
1851
}
1852
1852
@@ -1868,10 +1868,11 @@ describe('e2e', function () {
1868
1868
1869
1869
expect (
1870
1870
await shell . executeLine ( 'config.get("logRetentionGB")' )
1871
- ) . contains ( `${ 4 / 1024 / 1024 } ` ) ;
1871
+ ) . contains ( `${ 40 / 1024 / 1024 } ` ) ;
1872
1872
1873
- // Expect 6 files to be deleted and 5 to remain (including the new log file)
1874
- expect ( await getFilesState ( paths ) ) . to . equal ( '00000011111' ) ;
1873
+ // Expect 6 files to be deleted and 4 to remain
1874
+ // (including the new log file which should be <10 kb)
1875
+ expect ( await getFilesState ( paths ) ) . to . equal ( '00000001111' ) ;
1875
1876
} ) ;
1876
1877
} ) ;
1877
1878
0 commit comments