overlaycache's DB access modified to use transaction (#1596)
This commit is contained in:
parent
9dbc7c719e
commit
ea22411cac
@ -5,6 +5,7 @@ package overlay_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -264,6 +265,8 @@ func testDatabase(ctx context.Context, t *testing.T, cache overlay.DB) {
|
||||
{ // TestUpdateBatchExists
|
||||
nodeID1 := storj.NodeID{255, 1}
|
||||
nodeID2 := storj.NodeID{255, 2}
|
||||
nodeID3 := storj.NodeID{255, 3}
|
||||
nodeID4 := storj.NodeID{255, 4}
|
||||
|
||||
auditSuccessCount1 := int64(4)
|
||||
auditCount1 := int64(10)
|
||||
@ -340,5 +343,19 @@ func testDatabase(ctx context.Context, t *testing.T, cache overlay.DB) {
|
||||
assert.EqualValues(t, newUptimeRatio1, stats1.UptimeRatio)
|
||||
assert.EqualValues(t, newAuditRatio2, stats2.AuditSuccessRatio)
|
||||
assert.EqualValues(t, newUptimeRatio2, stats2.UptimeRatio)
|
||||
|
||||
concurrency := 100
|
||||
t.Run("CreateEntryIfNotExists", func(t *testing.T) {
|
||||
nodes := []*pb.Node{&pb.Node{Id: nodeID1}, &pb.Node{Id: nodeID2}, &pb.Node{Id: nodeID3}, &pb.Node{Id: nodeID4}}
|
||||
for P := 0; P < concurrency; P++ {
|
||||
t.Run("#"+strconv.Itoa(P), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, node := range nodes {
|
||||
_, err := cache.CreateEntryIfNotExists(ctx, node)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user