Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: improve Lease coverage #9017

Merged
merged 1 commit into from
Dec 18, 2017
Merged

Conversation

hexfusion
Copy link
Contributor

@hexfusion hexfusion commented Dec 15, 2017

Added tests to improve Lease coverage in e2e testing.

  • authLeaseTestKeepAlive
  • authLeaseTestTimeToLiveExpired
  • leaseTestTimeToLiveExpired

ref #9010

@hexfusion hexfusion changed the title e2e: improve lease coverage e2e: improve Lease coverage Dec 15, 2017
@gyuho
Copy link
Contributor

gyuho commented Dec 15, 2017

Also test lease timetolive command output on the expired lease (e.g. ...granted with TTL(0s), remaining(-...)?

}
if !strings.Contains(line, "TTL(3s), remaining(0s)") {
cx.t.Fatalf("expected 'TTL(3s), remaining(0s)', got %q", line)
}
Copy link
Contributor Author

@hexfusion hexfusion Dec 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gyuho why does this test pass? Are one of the CI checks running e2e against master?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it just got lucky, it ran timetolive command when TTL is <1-sec.

if err := ctlV3Put(cx, "key", "val", leaseID); err != nil {
cx.t.Fatalf("authLeaseTestTimeToLiveExpired: ctlV3Put error (%v)", err)
}
// eliminate false posative
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

if err != nil {
cx.t.Fatal(err)
}
line, err := proc.Expect(" granted with TTL(")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be matched by TTL(0s), remaining(-1s) since we are testing the expired lease output.

@@ -73,6 +75,33 @@ func leaseTestGrantLeasesList(cx ctlCtx) {
}
}

func leaseTestTimeToLiveExpired(cx ctlCtx) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems redundant with authLeaseTestTimeToLiveExpired. Could this be simplified by sharing code with authLeaseTestTimeToLiveExpired?

@hexfusion
Copy link
Contributor Author

hexfusion commented Dec 15, 2017

@gyuho thanks for review, will resolve.

@hexfusion
Copy link
Contributor Author

@gyuho PTAL, thanks.

return fmt.Errorf(fmt.Sprintf("expected '%s', got %q", e, line))
}
if err := ctlV3Get(cx, []string{"key"}, kv{"key", ""}); err != nil {
fmt.Errorf("leaseTestTimeToLiveExpired: ctlV3Get error (%v)", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to return this error?

@hexfusion
Copy link
Contributor Author

@gyuho fixed PTAL

@hexfusion hexfusion force-pushed the test_lease_auth branch 3 times, most recently from 2bc80d6 to db908e2 Compare December 16, 2017 19:03
@hexfusion
Copy link
Contributor Author

Excuse the dust folks shaking off the rust a bit. \o/

if err != nil {
return err
}
line, err := proc.Expect(" granted with TTL(")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hexfusion @gyuho

eventually we should return things like lease already expired to explicitly return the error.

@xiang90
Copy link
Contributor

xiang90 commented Dec 16, 2017

@hexfusion Thanks!

LGTM. Defer to @gyuho

@codecov-io
Copy link

codecov-io commented Dec 16, 2017

Codecov Report

Merging #9017 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9017      +/-   ##
==========================================
+ Coverage   76.12%   76.13%   +<.01%     
==========================================
  Files         359      359              
  Lines       29838    29838              
==========================================
+ Hits        22715    22717       +2     
- Misses       5548     5551       +3     
+ Partials     1575     1570       -5
Impacted Files Coverage Δ
mvcc/watchable_store.go 85.97% <0%> (-4.43%) ⬇️
clientv3/leasing/txn.go 88.09% <0%> (-3.18%) ⬇️
proxy/grpcproxy/watch.go 91.92% <0%> (-3.11%) ⬇️
rafthttp/peer.go 90.22% <0%> (-1.51%) ⬇️
clientv3/op.go 72.56% <0%> (-1.33%) ⬇️
pkg/netutil/netutil.go 64.36% <0%> (-1.15%) ⬇️
clientv3/leasing/kv.go 90.93% <0%> (-0.68%) ⬇️
clientv3/leasing/cache.go 91.11% <0%> (-0.56%) ⬇️
etcdserver/api/v3rpc/watch.go 92.69% <0%> (-0.46%) ⬇️
etcdserver/server.go 79.12% <0%> (+0.22%) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33a1d30...ed36728. Read the comment docs.

Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nits, and lgtm. Thanks!

if err != nil {
return err
}
line, err := proc.Expect(" granted with TTL(")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_, err := proc.Expect("TTL(0s), remaining(-1s)") // expect expired lease

and remove line 105-108?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point, thanks.

@gyuho
Copy link
Contributor

gyuho commented Dec 18, 2017

@gyuho gyuho merged commit 9b98cbb into etcd-io:master Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants