Skip to content

Commit 684557d

Browse files
committed
Test cache in robustness tests
Signed-off-by: Marek Siarkowicz <[email protected]>
1 parent 6d65230 commit 684557d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/robustness/client/client.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"go.uber.org/zap"
2525

2626
"go.etcd.io/etcd/api/v3/mvccpb"
27+
"go.etcd.io/etcd/cache/v3"
2728
clientv3 "go.etcd.io/etcd/client/v3"
2829
"go.etcd.io/etcd/tests/v3/robustness/identity"
2930
"go.etcd.io/etcd/tests/v3/robustness/model"
@@ -64,6 +65,14 @@ func NewRecordingClient(endpoints []string, ids identity.Provider, baseTime time
6465
if err != nil {
6566
return nil, err
6667
}
68+
c, err := cache.New(cc.Watcher, "")
69+
if err != nil {
70+
return nil, err
71+
}
72+
cc.Watcher = &cacheWatcher{
73+
Cache: c,
74+
Watcher: cc.Watcher,
75+
}
6776
return &RecordingClient{
6877
ID: ids.NewClientID(),
6978
client: *cc,
@@ -72,6 +81,24 @@ func NewRecordingClient(endpoints []string, ids identity.Provider, baseTime time
7281
}, nil
7382
}
7483

84+
type cacheWatcher struct {
85+
Cache *cache.Cache
86+
Watcher clientv3.Watcher
87+
}
88+
89+
func (cw *cacheWatcher) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan {
90+
return cw.Cache.Watch(ctx, key, opts...)
91+
}
92+
93+
func (cw *cacheWatcher) RequestProgress(ctx context.Context) error {
94+
return cw.Watcher.RequestProgress(ctx)
95+
}
96+
97+
func (cw *cacheWatcher) Close() error {
98+
cw.Cache.Close()
99+
return cw.Watcher.Close()
100+
}
101+
75102
func (c *RecordingClient) Close() error {
76103
return c.client.Close()
77104
}

0 commit comments

Comments
 (0)