Skip to content

Commit

Permalink
Migrate all OldGet calls to Get
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksander Mistewicz <[email protected]>
  • Loading branch information
AwesomePatrol committed Jan 8, 2025
1 parent 45b2933 commit 9966740
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
11 changes: 0 additions & 11 deletions tests/robustness/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ func (c *RecordingClient) Get(ctx context.Context, key string, opts ...clientv3.
return c.Range(ctx, key, "", revision, 0)
}

func (c *RecordingClient) OldGet(ctx context.Context, key string, revision int64) (kv *mvccpb.KeyValue, rev int64, err error) {
resp, err := c.Range(ctx, key, "", revision, 0)
if err != nil {
return nil, 0, err
}
if len(resp.Kvs) == 1 {
kv = resp.Kvs[0]
}
return kv, resp.Header.Revision, nil
}

func (c *RecordingClient) Range(ctx context.Context, start, end string, revision, limit int64) (*clientv3.GetResponse, error) {
ops := []clientv3.OpOption{}
if end != "" {
Expand Down
4 changes: 3 additions & 1 deletion tests/robustness/failpoint/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/tests/v3/framework/e2e"
"go.etcd.io/etcd/tests/v3/robustness/client"
"go.etcd.io/etcd/tests/v3/robustness/identity"
Expand Down Expand Up @@ -67,10 +68,11 @@ func (t triggerCompact) Trigger(ctx context.Context, _ *testing.T, member e2e.Et

var rev int64
for {
_, rev, err = cc.OldGet(ctx, "/", 0)
resp, err := cc.Get(ctx, "/", clientv3.WithRev(0))
if err != nil {
return nil, fmt.Errorf("failed to get revision: %w", err)
}
rev = resp.Header.Revision

if !t.multiBatchCompaction || rev > int64(clus.Cfg.ServerConfig.ExperimentalCompactionBatchLimit) {
break
Expand Down
19 changes: 16 additions & 3 deletions tests/robustness/traffic/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,17 @@ func (c etcdTrafficClient) Request(ctx context.Context, request etcdRequestType,
var limit int64
switch request {
case StaleGet:
_, rev, err = c.client.OldGet(opCtx, c.randomKey(), lastRev)
var resp *clientv3.GetResponse
resp, err = c.client.Get(opCtx, c.randomKey(), clientv3.WithRev(lastRev))
if err == nil {
rev = resp.Header.Revision
}
case Get:
_, rev, err = c.client.OldGet(opCtx, c.randomKey(), 0)
var resp *clientv3.GetResponse
resp, err = c.client.Get(opCtx, c.randomKey(), clientv3.WithRev(0))
if err == nil {
rev = resp.Header.Revision
}
case List:
var resp *clientv3.GetResponse
resp, err = c.client.Range(ctx, c.keyPrefix, clientv3.GetPrefixRangeEnd(c.keyPrefix), 0, limit)
Expand Down Expand Up @@ -212,8 +220,13 @@ func (c etcdTrafficClient) Request(ctx context.Context, request etcdRequestType,
case CompareAndSet:
var kv *mvccpb.KeyValue
key := c.randomKey()
kv, rev, err = c.client.OldGet(opCtx, key, 0)
var resp *clientv3.GetResponse
resp, err = c.client.Get(opCtx, key, clientv3.WithRev(0))
if err == nil {
rev = resp.Header.Revision
if len(resp.Kvs) == 1 {
kv = resp.Kvs[0]
}
c.limiter.Wait(ctx)
var expectedRevision int64
if kv != nil {
Expand Down

0 comments on commit 9966740

Please sign in to comment.