mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 02:04:26 +08:00
add more log in unit test
This commit is contained in:
@@ -120,6 +120,8 @@ func TestGenerateUuid_10000TimesConcurrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if uuidInfo.SequentialId == 0 {
|
if uuidInfo.SequentialId == 0 {
|
||||||
|
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuid)
|
||||||
|
|
||||||
if existedRoutineIndex, exists := generatedIds.Load(uuid); exists {
|
if existedRoutineIndex, exists := generatedIds.Load(uuid); exists {
|
||||||
mutex.Lock()
|
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))
|
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 {
|
if uuidInfo.SequentialId == 0 {
|
||||||
|
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuid)
|
||||||
|
|
||||||
if existedRoutineIndex, exists := generatedIds.Load(uuid); exists {
|
if existedRoutineIndex, exists := generatedIds.Load(uuid); exists {
|
||||||
mutex.Lock()
|
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))
|
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 {
|
if existedRoutineIndex, exists := generatedIds.Load(uuids[i]); exists {
|
||||||
mutex.Lock()
|
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))
|
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)
|
generatedIds.Store(uuids[i], currentRoutineIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
waitGroup.Done()
|
waitGroup.Done()
|
||||||
}(routineIndex)
|
}(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 {
|
if existedRoutineIndex, exists := generatedIds.Load(uuids[i]); exists {
|
||||||
mutex.Lock()
|
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))
|
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)
|
generatedIds.Store(uuids[i], currentRoutineIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
waitGroup.Done()
|
waitGroup.Done()
|
||||||
}(routineIndex)
|
}(routineIndex)
|
||||||
|
|||||||
Reference in New Issue
Block a user