chore: 初始开源发布
iotlcm-worker-svr:异步执行中枢(RabbitMQ 消费者 + 全量同步编排)。 - Go module:iotlcm-worker-svr → git.5iot.com/iotlcm-public/iotlcm-worker-svr(214 文件) - 凭据与内部标识脱敏:MySQL/Redis 凭据、私网与生产 IP、内网域名、 库名 xiujie_admin → iotlcm、哨兵名占位 - 159 处真实手机号 → 合法 11 位编造号(保留号段与后 4 位,维持互异, 不破坏「校验 MSISDN 格式」等测试断言) - 移除内部资产:CI 触发器、Jenkins 触发测试文档、预演门禁与镜像 digest 记录 - Dockerfile 改用公共基础镜像(golang:1.25-alpine → alpine:3.23), 移除写死的 git 凭据 - README 重写(架构/全量同步模型/配置/已知失败),补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes 已知:3 个测试包在源仓同一提交上同样失败(client/upstream、 service/allocate、service/inbound),属既有缺陷,本仓未引入亦未修复。
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package contract_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/fullsync/contract"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/model"
|
||||
)
|
||||
|
||||
// TestSyncKindForDailyUsageOperation guards the mapping that makes a daily run
|
||||
// discoverable. Catalog.ListRuns drops any run whose operation maps to an empty
|
||||
// kind, so losing this case would make daily runs invisible in the monitor
|
||||
// without any error.
|
||||
func TestSyncKindForDailyUsageOperation(t *testing.T) {
|
||||
if got := contract.SyncKindForOperation(model.OperationPreviousDayUsageFullSync); got != contract.SyncKindTrafficUsageDaily {
|
||||
t.Fatalf("SyncKindForOperation(%q) = %q, want %q",
|
||||
model.OperationPreviousDayUsageFullSync, got, contract.SyncKindTrafficUsageDaily)
|
||||
}
|
||||
if !contract.SyncKindTrafficUsageDaily.Valid() {
|
||||
t.Fatal("SyncKindTrafficUsageDaily must be a valid kind")
|
||||
}
|
||||
if contract.SyncKindForOperation("some_unknown_operation") != "" {
|
||||
t.Fatal("an unknown operation must not be assigned a sync kind")
|
||||
}
|
||||
}
|
||||
|
||||
// TestSyncKindForMonthlyHistoryOperation guards the mapping that makes a monthly
|
||||
// history run discoverable. Catalog.ListRuns drops any run whose operation maps
|
||||
// to an empty kind, so losing this case would make monthly history runs
|
||||
// invisible in the monitor without any error.
|
||||
func TestSyncKindForMonthlyHistoryOperation(t *testing.T) {
|
||||
if got := contract.SyncKindForOperation(model.OperationPreviousMonthUsageFullSync); got != contract.SyncKindTrafficUsageMonthly {
|
||||
t.Fatalf("SyncKindForOperation(%q) = %q, want %q",
|
||||
model.OperationPreviousMonthUsageFullSync, got, contract.SyncKindTrafficUsageMonthly)
|
||||
}
|
||||
}
|
||||
|
||||
// TestDailyAndMonthlyUsageHaveDistinctSyncKinds keeps the usage runs separately
|
||||
// filterable. There are three distinct usage runs now: the MySQL current-month
|
||||
// snapshot, the TDengine daily history, and the TDengine monthly history.
|
||||
func TestDailyAndMonthlyUsageHaveDistinctSyncKinds(t *testing.T) {
|
||||
monthly := contract.SyncKindForOperation("current_month_usage_full_sync")
|
||||
daily := contract.SyncKindForOperation(model.OperationPreviousDayUsageFullSync)
|
||||
monthlyHistory := contract.SyncKindForOperation(model.OperationPreviousMonthUsageFullSync)
|
||||
if monthly == daily {
|
||||
t.Fatalf("current-month snapshot and daily history share the sync kind %q", daily)
|
||||
}
|
||||
if monthly == monthlyHistory {
|
||||
t.Fatalf("current-month snapshot and monthly history share the sync kind %q", monthlyHistory)
|
||||
}
|
||||
if daily == monthlyHistory {
|
||||
t.Fatalf("daily and monthly history share the sync kind %q", daily)
|
||||
}
|
||||
if !monthlyHistory.Valid() {
|
||||
t.Fatal("SyncKindTrafficUsageMonthly must be a valid kind")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user