functional/tester: remove Txn stresser in 3.2

Nested Txn is not supported

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
release-3.2
Gyuho Lee 2018-04-12 19:42:33 -07:00
parent 4e11cea8cb
commit 21e7a30d31
1 changed files with 5 additions and 57 deletions

View File

@ -87,11 +87,11 @@ func (s *keyStresser) Stress() error {
}
if s.keyTxnSuffixRange > 0 {
// adjust to make up ±70% of workloads with writes
stressEntries[0].weight = 0.35
stressEntries = append(stressEntries, stressEntry{
weight: 0.35,
f: newStressTxn(s.cli, s.keyTxnSuffixRange, s.keyTxnOps),
})
// stressEntries[0].weight = 0.35
// stressEntries = append(stressEntries, stressEntry{
// weight: 0.35,
// f: newStressTxn(s.cli, s.keyTxnSuffixRange, s.keyTxnOps),
// })
}
s.stressTable = createStressTable(stressEntries)
@ -249,58 +249,6 @@ func newStressPut(cli *clientv3.Client, keySuffixRange, keySize int) stressFunc
}
}
func newStressTxn(cli *clientv3.Client, keyTxnSuffixRange, txnOps int) stressFunc {
keys := make([]string, keyTxnSuffixRange)
for i := range keys {
keys[i] = fmt.Sprintf("/k%03d", i)
}
return writeTxn(cli, keys, txnOps)
}
func writeTxn(cli *clientv3.Client, keys []string, txnOps int) stressFunc {
return func(ctx context.Context) (error, int64) {
ks := make(map[string]struct{}, txnOps)
for len(ks) != txnOps {
ks[keys[rand.Intn(len(keys))]] = struct{}{}
}
selected := make([]string, 0, txnOps)
for k := range ks {
selected = append(selected, k)
}
com, delOp, putOp := getTxnOps(selected[0], "bar00")
thenOps := []clientv3.Op{delOp}
elseOps := []clientv3.Op{putOp}
for i := 1; i < txnOps; i++ { // nested txns
k, v := selected[i], fmt.Sprintf("bar%02d", i)
com, delOp, putOp = getTxnOps(k, v)
txnOp := clientv3.OpTxn(
[]clientv3.Cmp{com},
[]clientv3.Op{delOp},
[]clientv3.Op{putOp},
)
thenOps = append(thenOps, txnOp)
elseOps = append(elseOps, txnOp)
}
_, err := cli.Txn(ctx).
If(com).
Then(thenOps...).
Else(elseOps...).
Commit()
return err, int64(txnOps)
}
}
func getTxnOps(k, v string) (
cmp clientv3.Cmp,
dop clientv3.Op,
pop clientv3.Op) {
// if key exists (version > 0)
cmp = clientv3.Compare(clientv3.Version(k), ">", 0)
dop = clientv3.OpDelete(k)
pop = clientv3.OpPut(k, v)
return cmp, dop, pop
}
func newStressRange(cli *clientv3.Client, keySuffixRange int) stressFunc {
return func(ctx context.Context) (error, int64) {
_, err := cli.Get(ctx, fmt.Sprintf("foo%016x", rand.Intn(keySuffixRange)))