Skip to content

Commit

Permalink
Merge pull request #16123 from serathius/robustness-txn-key-prefix
Browse files Browse the repository at this point in the history
tests/robustness: Fix multi txn key prefix
  • Loading branch information
serathius committed Jun 22, 2023
2 parents 04d24c2 + 0d2d383 commit 6fd77ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/robustness/traffic/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (c etcdTrafficClient) pickMultiTxnOps() (ops []clientv3.Op) {
}

for i, opType := range opTypes {
key := fmt.Sprintf("%d", keys[i])
key := c.key(keys[i])
switch opType {
case model.RangeOperation:
ops = append(ops, clientv3.OpGet(key))
Expand All @@ -294,7 +294,11 @@ func (c etcdTrafficClient) pickMultiTxnOps() (ops []clientv3.Op) {
}

func (c etcdTrafficClient) randomKey() string {
return fmt.Sprintf("%s%d", c.keyPrefix, rand.Int()%c.keyCount)
return c.key(rand.Int())
}

func (c etcdTrafficClient) key(i int) string {
return fmt.Sprintf("%s%d", c.keyPrefix, i%c.keyCount)
}

func (t etcdTraffic) pickOperationType() model.OperationType {
Expand Down

0 comments on commit 6fd77ac

Please sign in to comment.