fix: 修复测试文件格式问题

- 修正测试文件中的换行符和格式
- 确保所有测试文件的一致性
This commit is contained in:
ryan
2025-12-24 17:22:50 +08:00
parent bdca8b59e0
commit e54d3c96b7
4 changed files with 82 additions and 86 deletions

View File

@@ -77,7 +77,7 @@ func TestClusterSafety_MultipleCursorWorkers(t *testing.T) {
`, opID, "cluster-tester", fmt.Sprintf("cluster/test/%d", i), "cluster-producer",
"req-hash", "resp-hash", "op-hash", "signature",
"DOIP", "CREATE", "cluster-test", "cluster-repo", "NOT_TRUSTLOGGED", time.Now())
if err != nil {
t.Fatalf("Failed to create test data: %v", err)
}
@@ -88,14 +88,14 @@ func TestClusterSafety_MultipleCursorWorkers(t *testing.T) {
workerCount := 3
var clients []*persistence.PersistenceClient
var wg sync.WaitGroup
// 统计变量
var processedCount int64
var duplicateCount int64
for i := 0; i < workerCount; i++ {
workerID := i
// 创建 Pulsar Publisher
publisher, err := adapter.NewPublisher(adapter.PublisherConfig{
URL: e2eTestPulsarURL,
@@ -138,21 +138,21 @@ func TestClusterSafety_MultipleCursorWorkers(t *testing.T) {
}
clientConfig := persistence.PersistenceClientConfig{
Publisher: publisher,
Logger: log,
EnvelopeConfig: envelopeConfig,
DBConfig: dbConfig,
PersistenceConfig: persistenceConfig,
CursorWorkerConfig: cursorConfig,
EnableCursorWorker: true,
RetryWorkerConfig: retryConfig,
EnableRetryWorker: true,
Publisher: publisher,
Logger: log,
EnvelopeConfig: envelopeConfig,
DBConfig: dbConfig,
PersistenceConfig: persistenceConfig,
CursorWorkerConfig: cursorConfig,
EnableCursorWorker: true,
RetryWorkerConfig: retryConfig,
EnableRetryWorker: true,
}
client, err := persistence.NewPersistenceClient(ctx, clientConfig)
require.NoError(t, err, "Failed to create PersistenceClient %d", workerID)
clients = append(clients, client)
t.Logf("✅ Worker %d started", workerID)
}
@@ -162,23 +162,23 @@ func TestClusterSafety_MultipleCursorWorkers(t *testing.T) {
defer wg.Done()
ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
maxWait := 30 * time.Second
startTime := time.Now()
for {
select {
case <-ticker.C:
var trustloggedCount int
db.QueryRow("SELECT COUNT(*) FROM operation WHERE op_id LIKE 'cluster-test-%' AND trustlog_status = 'TRUSTLOGGED'").Scan(&trustloggedCount)
t.Logf("⏳ Progress: %d/%d operations trustlogged", trustloggedCount, operationCount)
if trustloggedCount >= operationCount {
t.Log("✅ All operations processed")
return
}
if time.Since(startTime) > maxWait {
t.Log("⚠️ Timeout waiting for processing")
return
@@ -296,7 +296,7 @@ func TestClusterSafety_ConcurrentStatusUpdate(t *testing.T) {
// 使用 CAS 更新状态
opRepo := manager.GetOperationRepo()
updated, err := opRepo.UpdateStatusWithCAS(ctx, nil, "concurrent-test", persistence.StatusNotTrustlogged, persistence.StatusTrustlogged)
if err != nil {
t.Logf("Error updating: %v", err)
return
@@ -334,4 +334,3 @@ func TestClusterSafety_ConcurrentStatusUpdate(t *testing.T) {
t.Log("✅ CAS mechanism working correctly - Only one update succeeded")
}