mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 01:34:24 +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,13 +301,17 @@ func TestGenerateUuids_20000TimesConcurrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if existedRoutineIndex, exists := generatedIds.Load(uuids[i]); exists {
|
if uuidInfo.SequentialId == 0 {
|
||||||
mutex.Lock()
|
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuids[i])
|
||||||
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))
|
|
||||||
mutex.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
generatedIds.Store(uuids[i], currentRoutineIndex)
|
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))
|
||||||
|
mutex.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
generatedIds.Store(uuids[i], currentRoutineIndex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,13 +354,17 @@ func TestGenerateUuids_1000000TimesConcurrent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if existedRoutineIndex, exists := generatedIds.Load(uuids[i]); exists {
|
if uuidInfo.SequentialId == 0 {
|
||||||
mutex.Lock()
|
fmt.Printf("routine#%d generate uuid %d\n", currentRoutineIndex, uuids[i])
|
||||||
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))
|
|
||||||
mutex.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
generatedIds.Store(uuids[i], currentRoutineIndex)
|
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))
|
||||||
|
mutex.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
generatedIds.Store(uuids[i], currentRoutineIndex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user