Skip to content

Commit 1f25401

Browse files
committed
fix(tests): use 10kb files for the test and update validation
1 parent d646849 commit 1f25401

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

packages/e2e-tests/test/e2e.spec.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,10 +1734,10 @@ describe('e2e', function () {
17341734
});
17351735
});
17361736

1737-
describe('with custom log retention days', function () {
1737+
describe('with logRetentionDays', function () {
17381738
const customLogDir = useTmpdir();
17391739

1740-
it('should delete older files according to the setting', async function () {
1740+
it('should delete older files older than logRetentionDays', async function () {
17411741
const paths: string[] = [];
17421742
const today = Math.floor(Date.now() / 1000);
17431743
const tenDaysAgo = today - 10 * 24 * 60 * 60;
@@ -1790,10 +1790,10 @@ describe('e2e', function () {
17901790
});
17911791
});
17921792

1793-
describe('with custom log retention max file count', function () {
1793+
describe('with logMaxFileCount', function () {
17941794
const customLogDir = useTmpdir();
17951795

1796-
it('should delete files once it is above the max file count limit', async function () {
1796+
it('should delete files once it is above logMaxFileCount', async function () {
17971797
const globalConfig = path.join(homedir, 'globalconfig.conf');
17981798
await fs.writeFile(
17991799
globalConfig,
@@ -1842,28 +1842,28 @@ describe('e2e', function () {
18421842
});
18431843
});
18441844

1845-
describe('with custom log retention max logs size', function () {
1845+
describe('with logRetentionGB', function () {
18461846
const customLogDir = useTmpdir();
18471847

1848-
it('should delete files once it is above the logs retention GB', async function () {
1848+
it('should delete files once it is above logRetentionGB', async function () {
18491849
const globalConfig = path.join(homedir, 'globalconfig.conf');
18501850
await fs.writeFile(
18511851
globalConfig,
1852-
// Set logRetentionGB to 4 KB
1852+
// Set logRetentionGB to 40 KB and we will create prior 10 log files, 10 KB each
18531853
`mongosh:\n logLocation: ${JSON.stringify(
18541854
customLogDir.path
1855-
)}\n logRetentionGB: ${4 / 1024 / 1024}`
1855+
)}\n logRetentionGB: ${40 / 1024 / 1024}`
18561856
);
18571857
const paths: string[] = [];
18581858
const offset = Math.floor(Date.now() / 1000);
18591859

1860-
// Create 10 log files, 1kb each
1860+
// Create 10 log files, 10kb each
18611861
for (let i = 9; i >= 0; i--) {
18621862
const filename = path.join(
18631863
customLogDir.path,
18641864
ObjectId.createFromTime(offset - i).toHexString() + '_log'
18651865
);
1866-
await fs.writeFile(filename, '0'.repeat(1024));
1866+
await fs.writeFile(filename, '0'.repeat(1024 * 10));
18671867
paths.push(filename);
18681868
}
18691869

@@ -1888,10 +1888,11 @@ describe('e2e', function () {
18881888

18891889
expect(
18901890
await shell.executeLine('config.get("logRetentionGB")')
1891-
).contains(`${4 / 1024 / 1024}`);
1891+
).contains(`${40 / 1024 / 1024}`);
18921892

1893-
// Expect 6 files to be deleted and 5 to remain (including the new log file)
1894-
expect(await getFilesState(paths)).to.equal('00000011111');
1893+
// Expect 6 files to be deleted and 4 to remain
1894+
// (including the new log file which should be <10 kb)
1895+
expect(await getFilesState(paths)).to.equal('00000001111');
18951896
});
18961897
});
18971898

packages/types/src/index.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ describe('config validation', function () {
3939
);
4040
expect(await validate('logRetentionGB', undefined)).to.equal(null);
4141
expect(await validate('logRetentionGB', 100)).to.equal(null);
42-
expect(await validate('logRetentionDays', -1)).to.equal(
43-
'logRetentionGB must be a positive integer'
44-
);
4542
expect(await validate('logMaxFileCount', 'foo')).to.equal(
4643
'logMaxFileCount must be a positive integer'
4744
);

0 commit comments

Comments
 (0)