add more log in unit test

This commit is contained in:
MaysWind
2023-08-21 01:41:03 +08:00
parent 2aa6df48c6
commit 09f6dd8d82
+12
View File
@@ -120,6 +120,8 @@ func TestGenerateUuid_10000TimesConcurrent(t *testing.T) {
}
if uuidInfo.SequentialId == 0 {
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuid)
if existedRoutineIndex, exists := generatedIds.Load(uuid); exists {
mutex.Lock()
assert.Fail(t, fmt.Sprintf("uuid \"%d\" conflicts, unix time is %d, seq id is %d, existed routine index is %d, current routine index is %d", uuid, uuidInfo.UnixTime, uuidInfo.SequentialId, existedRoutineIndex, currentRoutineIndex))
@@ -168,6 +170,8 @@ func TestGenerateUuid_1000000TimesConcurrent(t *testing.T) {
}
if uuidInfo.SequentialId == 0 {
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuid)
if existedRoutineIndex, exists := generatedIds.Load(uuid); exists {
mutex.Lock()
assert.Fail(t, fmt.Sprintf("uuid \"%d\" conflicts, unix time is %d, seq id is %d, existed routine index is %d, current routine index is %d", uuid, uuidInfo.UnixTime, uuidInfo.SequentialId, existedRoutineIndex, currentRoutineIndex))
@@ -297,6 +301,9 @@ func TestGenerateUuids_20000TimesConcurrent(t *testing.T) {
}
}
if uuidInfo.SequentialId == 0 {
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuids[i])
if existedRoutineIndex, exists := generatedIds.Load(uuids[i]); exists {
mutex.Lock()
assert.Fail(t, fmt.Sprintf("uuid \"%d\" conflicts, unix time is %d, seq id is %d, existed routine index is %d, current routine index is %d", uuids[i], uuidInfo.UnixTime, uuidInfo.SequentialId, existedRoutineIndex, currentRoutineIndex))
@@ -306,6 +313,7 @@ func TestGenerateUuids_20000TimesConcurrent(t *testing.T) {
generatedIds.Store(uuids[i], currentRoutineIndex)
}
}
}
waitGroup.Done()
}(routineIndex)
@@ -346,6 +354,9 @@ func TestGenerateUuids_1000000TimesConcurrent(t *testing.T) {
}
}
if uuidInfo.SequentialId == 0 {
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuids[i])
if existedRoutineIndex, exists := generatedIds.Load(uuids[i]); exists {
mutex.Lock()
assert.Fail(t, fmt.Sprintf("uuid \"%d\" conflicts, unix time is %d, seq id is %d, existed routine index is %d, current routine index is %d", uuids[i], uuidInfo.UnixTime, uuidInfo.SequentialId, existedRoutineIndex, currentRoutineIndex))
@@ -355,6 +366,7 @@ func TestGenerateUuids_1000000TimesConcurrent(t *testing.T) {
generatedIds.Store(uuids[i], currentRoutineIndex)
}
}
}
waitGroup.Done()
}(routineIndex)