From 0d2d383f0ab816b807611106ffca8c6d9d7f3906 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Wed, 21 Jun 2023 22:15:09 +0200 Subject: [PATCH] tests/robustness: Fix multi txn key prefix Signed-off-by: Marek Siarkowicz --- tests/robustness/traffic/etcd.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/robustness/traffic/etcd.go b/tests/robustness/traffic/etcd.go index 82a1d81796c..2754fd80ccc 100644 --- a/tests/robustness/traffic/etcd.go +++ b/tests/robustness/traffic/etcd.go @@ -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)) @@ -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 {