feat: setup logs retention by max file size
This commit is contained in:
1 parent
70c8492f4f
commit
f914eae3c5
44 files changed
+2316
-161
No files matched your search
@@ -3,8 +3,11 @@ import { initializeLocale, setLocale } from '@/i18n'
|
||||
import type { WorkspaceSettings } from '@/composables/useSettings'
|
||||
import { recentWhenLabel } from '../activityTime'
|
||||
import {
|
||||
formatLogSize,
|
||||
helperCopy,
|
||||
isShorter,
|
||||
isSmaller,
|
||||
sizeHelperCopy,
|
||||
lastCleanupLine,
|
||||
nextCleanupLine,
|
||||
shorteningDescription,
|
||||
@@ -20,6 +23,8 @@ function settings(overrides: Partial<WorkspaceSettings> = {}): WorkspaceSettings
|
||||
return {
|
||||
version: 'v2.2.0-beta',
|
||||
activity_retention_days: 90,
|
||||
activity_retention_max_gb: 0,
|
||||
activity_log_size_bytes: 0,
|
||||
activity_last_cleanup_at: at(6, 3, 0),
|
||||
activity_last_cleanup_removed: 142,
|
||||
activity_next_cleanup_at: at(7, 3, 0),
|
||||
@@ -86,3 +91,43 @@ describe('retention lines', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('retention size limit', () => {
|
||||
it('ranks 1 < 5 < 10 < 25 < 50 < No size limit', () => {
|
||||
expect(isSmaller(1, 5)).toBe(true)
|
||||
expect(isSmaller(5, 0)).toBe(true)
|
||||
expect(isSmaller(0, 50)).toBe(false)
|
||||
expect(isSmaller(5, 5)).toBe(false)
|
||||
expect(isSmaller(10, 50)).toBe(true)
|
||||
})
|
||||
|
||||
it.each([
|
||||
[0, 'Less than 0.1 GB'],
|
||||
[53687091, 'Less than 0.1 GB'],
|
||||
[107374183, '0.1 GB'],
|
||||
[1073741824, '1.0 GB'],
|
||||
[3435973837, '3.2 GB'],
|
||||
[5368709120, '5.0 GB'],
|
||||
])('formats %s bytes as %s on a 1024^3 base', (bytes, shown) => {
|
||||
expect(formatLogSize(bytes)).toBe(shown)
|
||||
})
|
||||
|
||||
it('words the helpers for each combination', () => {
|
||||
expect(helperCopy(90, 5)).toBe('Events older than this are removed.')
|
||||
expect(helperCopy(0, 5)).toBe('No age limit. Only the size limit applies.')
|
||||
expect(helperCopy(0, 0)).toBe('Nothing is removed automatically. The log grows over time.')
|
||||
expect(sizeHelperCopy(0, 99)).toBe('Optional. Logs can grow without a size cap.')
|
||||
expect(sizeHelperCopy(5, 3435973837)).toBe(
|
||||
'When logs pass 5 GB, the oldest events are removed. Currently 3.2 GB.',
|
||||
)
|
||||
})
|
||||
|
||||
it('words the helpers in French with Go and a decimal comma', () => {
|
||||
setLocale('fr')
|
||||
|
||||
expect(sizeHelperCopy(5, 3435973837)).toBe(
|
||||
'Au-delà de 5 Go, les événements les plus anciens sont supprimés. Actuellement 3,2 Go.',
|
||||
)
|
||||
expect(formatLogSize(0)).toBe('Moins de 0,1 Go')
|
||||
})
|
||||
})
|
||||
@@ -101,6 +101,26 @@ describe('Sentences: English and French come from the same code and params', ()
|
||||
'Changed the activity retention from 90 days to Forever',
|
||||
"Durée de conservation de l'activité modifiée : 90 jours → Toujours",
|
||||
],
|
||||
[
|
||||
'system.activity_retention_changed size only',
|
||||
{
|
||||
action: 'system.activity_retention_changed',
|
||||
target: null,
|
||||
params: { max_gb_from: 0, max_gb_to: 5 },
|
||||
},
|
||||
'Changed the activity size limit from No size limit to 5 GB',
|
||||
"Limite de taille de l'activité modifiée : Aucune limite de taille → 5 Go",
|
||||
],
|
||||
[
|
||||
'system.activity_retention_changed age and size',
|
||||
{
|
||||
action: 'system.activity_retention_changed',
|
||||
target: null,
|
||||
params: { from: 90, to: 30, max_gb_from: 10, max_gb_to: 0 },
|
||||
},
|
||||
'Changed the activity retention from 90 days to 30 days and the size limit from 10 GB to No size limit',
|
||||
"Durée de conservation de l'activité modifiée : 90 jours → 30 jours, et limite de taille : 10 Go → Aucune limite de taille",
|
||||
],
|
||||
[
|
||||
'system.restart_requested update',
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user