tests/framework: add Client.LeaseList

This commit is contained in:
Danielle Lancashire 2022-03-16 15:00:29 +00:00
parent 6b7be72a43
commit 68e6493977
3 changed files with 23 additions and 1 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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)
}