mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests/framework: Add Client.LeaseKeepAliveOnce
This commit is contained in:
parent
c12e03c8e6
commit
353b011f59
@ -311,3 +311,19 @@ func (ctl *EtcdctlV3) LeaseList() (*clientv3.LeaseLeasesResponse, error) {
|
||||
err = json.Unmarshal([]byte(line), &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
func (ctl *EtcdctlV3) LeaseKeepAliveOnce(id clientv3.LeaseID) (*clientv3.LeaseKeepAliveResponse, error) {
|
||||
args := ctl.cmdArgs()
|
||||
args = append(args, "lease", "keep-alive", strconv.FormatInt(int64(id), 16), "--once", "-w", "json")
|
||||
cmd, err := SpawnCmd(args, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var resp clientv3.LeaseKeepAliveResponse
|
||||
line, err := cmd.Expect("ID")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal([]byte(line), &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
@ -238,3 +238,9 @@ func (c integrationClient) LeaseList() (*clientv3.LeaseLeasesResponse, error) {
|
||||
|
||||
return c.Client.Leases(ctx)
|
||||
}
|
||||
|
||||
func (c integrationClient) LeaseKeepAliveOnce(id clientv3.LeaseID) (*clientv3.LeaseKeepAliveResponse, error) {
|
||||
ctx := context.Background()
|
||||
|
||||
return c.Client.KeepAliveOnce(ctx, id)
|
||||
}
|
||||
|
@ -44,4 +44,5 @@ type Client interface {
|
||||
Grant(ttl int64) (*clientv3.LeaseGrantResponse, error)
|
||||
TimeToLive(id clientv3.LeaseID, opts config.LeaseOption) (*clientv3.LeaseTimeToLiveResponse, error)
|
||||
LeaseList() (*clientv3.LeaseLeasesResponse, error)
|
||||
LeaseKeepAliveOnce(id clientv3.LeaseID) (*clientv3.LeaseKeepAliveResponse, error)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user