Files
OpenFlare/internal/repository/analytics/clickhouse_maintenance_test.go
T
ryan f0e234df1f feat(obs): 访问日志 SSOT 与 edge_health,去掉协议兼容层
Agent 仅上报 host_metrics/edge_health/access_logs;业务流量与 UV 由
Server 侧访问日志聚合。新增 of_node_edge_health 与 of_access_log_hourly,
删除 request_reports/openresty 吞吐路径;API 不再暴露 traffic_reports
与 openresty_rx|tx。心跳/离线默认阈值与回填迁移一并入库。
2026-07-18 11:53:11 +08:00

37 lines
932 B
Go

// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
package analytics
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestTableTTLCutoff(t *testing.T) {
now := time.Date(2026, 7, 10, 12, 0, 0, 0, time.UTC)
got := tableTTLCutoff(30, now)
assert.Equal(t, now.Add(-30*24*time.Hour), got)
got = tableTTLCutoff(90, now)
assert.Equal(t, now.Add(-90*24*time.Hour), got)
// Invalid TTL floors to 1 day.
got = tableTTLCutoff(0, now)
assert.Equal(t, now.Add(-24*time.Hour), got)
}
func TestCleanupModeConstants(t *testing.T) {
assert.Equal(t, "ttl_materialize", CleanupModeTTLMaterialize)
assert.Equal(t, "truncate", CleanupModeTruncate)
}
func TestTableTTLDaysMatchDDL(t *testing.T) {
assert.Equal(t, 90, TableTTLDaysNodeAccessLogs)
assert.Equal(t, 30, TableTTLDaysNodeMetricSnapshots)
assert.Equal(t, 30, TableTTLDaysNodeObs)
assert.Equal(t, 180, TableTTLDaysUserAccessLogs)
}