mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests/framework: add Client.LeaseList
This commit is contained in:
parent
6b7be72a43
commit
68e6493977
@ -279,7 +279,6 @@ func (ctl *EtcdctlV3) TimeToLive(id clientv3.LeaseID, o config.LeaseOption) (*cl
|
||||
}
|
||||
|
||||
func (ctl *EtcdctlV3) Defragment(o config.DefragOption) error {
|
||||
|
||||
args := append(ctl.cmdArgs(), "defrag")
|
||||
if o.Timeout != 0 {
|
||||
args = append(args, fmt.Sprintf("--command-timeout=%s", o.Timeout))
|
||||
@ -291,3 +290,19 @@ func (ctl *EtcdctlV3) Defragment(o config.DefragOption) error {
|
||||
_, err := SpawnWithExpectLines(args, map[string]string{}, lines...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (ctl *EtcdctlV3) LeaseList() (*clientv3.LeaseLeasesResponse, error) {
|
||||
args := ctl.cmdArgs()
|
||||
args = append(args, "lease", "list", "-w", "json")
|
||||
cmd, err := SpawnCmd(args, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var resp clientv3.LeaseLeasesResponse
|
||||
line, err := cmd.Expect("id")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal([]byte(line), &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
@ -228,3 +228,9 @@ func (c integrationClient) TimeToLive(id clientv3.LeaseID, o config.LeaseOption)
|
||||
|
||||
return c.Client.TimeToLive(ctx, id, leaseOpts...)
|
||||
}
|
||||
|
||||
func (c integrationClient) LeaseList() (*clientv3.LeaseLeasesResponse, error) {
|
||||
ctx := context.Background()
|
||||
|
||||
return c.Client.Leases(ctx)
|
||||
}
|
||||
|
@ -43,4 +43,5 @@ type Client interface {
|
||||
Defragment(opts config.DefragOption) error
|
||||
Grant(ttl int64) (*clientv3.LeaseGrantResponse, error)
|
||||
TimeToLive(id clientv3.LeaseID, opts config.LeaseOption) (*clientv3.LeaseTimeToLiveResponse, error)
|
||||
LeaseList() (*clientv3.LeaseLeasesResponse, error)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user