From 4d4ce6e9a8aa50671083d84f8b24b502b763a920 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Sat, 30 Nov 2024 17:44:08 -0500 Subject: [PATCH] quarterly pass --- pkg/database/partman/partman_test.go | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pkg/database/partman/partman_test.go b/pkg/database/partman/partman_test.go index 28bf8e8..81fc50c 100644 --- a/pkg/database/partman/partman_test.go +++ b/pkg/database/partman/partman_test.go @@ -108,9 +108,9 @@ func TestPartman(t *testing.T) { partResult("calls_p_2024_07", "2024-07-01", "2024-08-01"), }, expectCreate: []partSpec{ - {name:"calls_p_2024_11", timeRange: timeRange{start: dateInUTC("2024-11-01"), end: dateInUTC("2024-12-01")}}, - {name:"calls_p_2024_12", timeRange: timeRange{start: dateInUTC("2024-12-01"), end: dateInUTC("2025-01-01")}}, - {name:"calls_p_2025_01", timeRange: timeRange{start: dateInUTC("2025-01-01"), end: dateInUTC("2025-02-01")}}, + {name: "calls_p_2024_11", timeRange: timeRange{start: dateInUTC("2024-11-01"), end: dateInUTC("2024-12-01")}}, + {name: "calls_p_2024_12", timeRange: timeRange{start: dateInUTC("2024-12-01"), end: dateInUTC("2025-01-01")}}, + {name: "calls_p_2025_01", timeRange: timeRange{start: dateInUTC("2025-01-01"), end: dateInUTC("2025-02-01")}}, }, expectDrop: []string{ "public.calls_p_2024_07", @@ -206,7 +206,7 @@ func TestPartman(t *testing.T) { }, { name: "quarterly base", - now: timeInUTC("2025-07-28 11:37:04"), + now: timeInUTC("2025-07-28 11:37:04"), // q3 cfg: config.Partition{ Enabled: true, Schema: "public", @@ -222,20 +222,25 @@ func TestPartman(t *testing.T) { partResult("calls_p_2025_q2", "2025-04-01", "2024-07-01"), }, expectDrop: []string{ - "public.calls_p_2024_11_24", - "public.calls_p_2024_11_25", + "public.calls_p_2024_q3", + "public.calls_p_2024_q4", }, expectSweep: []timeRange{ - {start: dateInUTC("2024-11-24"), end: dateInUTC("2024-11-25")}, - {start: dateInUTC("2024-11-25"), end: dateInUTC("2024-11-26")}, + {start: dateInUTC("2024-07-01"), end: dateInUTC("2024-10-01")}, + {start: dateInUTC("2024-10-01"), end: dateInUTC("2025-01-01")}, }, expectCleanup: []timeRange{ - {start: dateInUTC("2024-11-24"), end: dateInUTC("2024-11-25")}, - {start: dateInUTC("2024-11-25"), end: dateInUTC("2024-11-26")}, + {start: dateInUTC("2024-07-01"), end: dateInUTC("2024-10-01")}, + {start: dateInUTC("2024-10-01"), end: dateInUTC("2025-01-01")}, + }, + expectCreate: []partSpec{ + {name: "calls_p_2025_q3", timeRange: timeRange{dateInUTC("2025-07-01"), dateInUTC("2025-10-01")}}, + {name: "calls_p_2025_q4", timeRange: timeRange{dateInUTC("2025-10-01"), dateInUTC("2026-01-01")}}, + {name: "calls_p_2026_q1", timeRange: timeRange{dateInUTC("2026-01-01"), dateInUTC("2026-04-01")}}, }, expectDetach: []string{ - "public.calls_p_2024_11_24", - "public.calls_p_2024_11_25", + "public.calls_p_2024_q3", + "public.calls_p_2024_q4", }, }, {