{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/49805513","id":49805513,"diff_hunk":"@@ -193,3 +194,156 @@ func TestV3DeleteRange(t *testing.T) {\n \t\tclus.Terminate(t)\n \t}\n }\n+\n+// TestV3WatchFromCurrentRevision tests Watch APIs from current revision.\n+func TestV3WatchFromCurrentRevision(t *testing.T) {\n+\ttests := []struct {\n+\t\tputKeys      []string\n+\t\twatchRequest *pb.WatchRequest\n+\n+\t\twresps []*pb.WatchResponse\n+\t}{\n+\t\t// watch the key, matching\n+\t\t{\n+\t\t\t[]string{\"foo\"},\n+\t\t\t&pb.WatchRequest{CreateRequest: &pb.WatchCreateRequest{Key: []byte(\"foo\")}},\n+\n+\t\t\t[]*pb.WatchResponse{\n+\t\t\t\t{\n+\t\t\t\t\tHeader:  &pb.ResponseHeader{Revision: 1},\n+\t\t\t\t\tCreated: true,\n+\t\t\t\t\tEvents:  []*storagepb.Event{},\n+\t\t\t\t},\n+\t\t\t\t{\n+\t\t\t\t\tHeader:  &pb.ResponseHeader{Revision: 1},\n+\t\t\t\t\tCreated: false,\n+\t\t\t\t\tEvents: []*storagepb.Event{\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tType: storagepb.PUT,\n+\t\t\t\t\t\t\tKv:   &storagepb.KeyValue{Key: []byte(\"foo\"), Value: []byte(\"bar\"), CreateRevision: 1, ModRevision: 1, Version: 1},\n+\t\t\t\t\t\t},\n+\t\t\t\t\t},\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\t\t// watch the key, non-matching\n+\t\t{\n+\t\t\t[]string{\"foo\"},\n+\t\t\t&pb.WatchRequest{CreateRequest: &pb.WatchCreateRequest{Key: []byte(\"helloworld\")}},\n+\n+\t\t\t[]*pb.WatchResponse{\n+\t\t\t\t{\n+\t\t\t\t\tHeader:  &pb.ResponseHeader{Revision: 1},\n+\t\t\t\t\tCreated: true,\n+\t\t\t\t\tEvents:  []*storagepb.Event{},\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\t\t// watch the prefix, matching\n+\t\t{\n+\t\t\t[]string{\"fooLong\"},\n+\t\t\t&pb.WatchRequest{CreateRequest: &pb.WatchCreateRequest{Prefix: []byte(\"foo\")}},\n+\n+\t\t\t[]*pb.WatchResponse{\n+\t\t\t\t{\n+\t\t\t\t\tHeader:  &pb.ResponseHeader{Revision: 1},\n+\t\t\t\t\tCreated: true,\n+\t\t\t\t\tEvents:  []*storagepb.Event{},\n+\t\t\t\t},\n+\t\t\t\t{\n+\t\t\t\t\tHeader:  &pb.ResponseHeader{Revision: 1},\n+\t\t\t\t\tCreated: false,\n+\t\t\t\t\tEvents: []*storagepb.Event{\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tType: storagepb.PUT,\n+\t\t\t\t\t\t\tKv:   &storagepb.KeyValue{Key: []byte(\"fooLong\"), Value: []byte(\"bar\"), CreateRevision: 1, ModRevision: 1, Version: 1},\n+\t\t\t\t\t\t},\n+\t\t\t\t\t},\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\t\t// watch the prefix, non-matching\n+\t\t{\n+\t\t\t[]string{\"foo\"},\n+\t\t\t&pb.WatchRequest{CreateRequest: &pb.WatchCreateRequest{Prefix: []byte(\"helloworld\")}},\n+\n+\t\t\t[]*pb.WatchResponse{\n+\t\t\t\t{\n+\t\t\t\t\tHeader:  &pb.ResponseHeader{Revision: 1},\n+\t\t\t\t\tCreated: true,\n+\t\t\t\t\tEvents:  []*storagepb.Event{},\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\n+\t\t// TODO: watch and receive multiple-events from synced (need Txn)\n+\t}\n+\n+\tfor i, tt := range tests {\n+\t\tclus := newClusterGRPC(t, &clusterConfig{size: 3})\n+\n+\t\twAPI := pb.NewWatchClient(clus.RandConn())\n+\t\twStream, err := wAPI.Watch(context.TODO())\n+\t\tif err != nil {\n+\t\t\tt.Fatalf(\"#%d: wAPI.Watch error: %v\", i, err)\n+\t\t}\n+\n+\t\tif err := wStream.Send(tt.watchRequest); err != nil {\n+\t\t\tt.Fatalf(\"#%d: wStream.Send error: %v\", i, err)\n+\t\t}\n+\n+\t\tkvc := pb.NewKVClient(clus.RandConn())\n+\t\tfor _, k := range tt.putKeys {\n+\t\t\tif _, err := kvc.Put(context.TODO(), &pb.PutRequest{Key: []byte(k), Value: []byte(\"bar\")}); err != nil {\n+\t\t\t\tt.Fatalf(\"#%d: couldn't put key (%v)\", i, err)\n+\t\t\t}\n+\t\t}\n+\n+\t\tvar createdWatchId int64\n+\n+\t\tfor j, wresp := range tt.wresps {\n+\t\t\tresp, err := wStream.Recv()\n+\t\t\tif err != nil {\n+\t\t\t\tt.Errorf(\"#%d-%d: wStream.Recv error: %v\", i, j, err)\n+\t\t\t}\n+\n+\t\t\tif j == 0 {\n+\t\t\t\tcreatedWatchId = resp.WatchId\n+\t\t\t}\n+\t\t\tif resp.WatchId != createdWatchId {\n+\t\t\t\tt.Errorf(\"#%d-%d: resp.WatchId got = %d, want = %d\", i, j, resp.WatchId, createdWatchId)\n+\t\t\t}\n+\n+\t\t\tif resp.Header == nil {\n+\t\t\t\tt.Errorf(\"#%d-%d: unexpected nil resp.Header\", i, j)","path":"integration/v3_grpc_test.go","position":null,"original_position":133,"commit_id":"4674faccb93e79ec481185707dbf14fe84cc3def","original_commit_id":"3113d5786655b05f99493ba060b4a88cba3a7746","user":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"body":"we need to fatal here. if header is nil, the test should not continue or it panics when access header.revision.","created_at":"2016-01-15T00:08:38Z","updated_at":"2016-01-15T00:08:38Z","html_url":"https://github.com/coreos/etcd/pull/4214#discussion_r49805513","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/4214","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/49805513"},"html":{"href":"https://github.com/coreos/etcd/pull/4214#discussion_r49805513"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/4214"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/4214","id":56069264,"html_url":"https://github.com/coreos/etcd/pull/4214","diff_url":"https://github.com/coreos/etcd/pull/4214.diff","patch_url":"https://github.com/coreos/etcd/pull/4214.patch","issue_url":"https://api.github.com/repos/coreos/etcd/issues/4214","number":4214,"state":"open","locked":false,"title":"integration: add TestV3WatchFromCurrentRevision in grpc test","user":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars.githubusercontent.com/u/6799218?v=3","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-14T17:47:31Z","updated_at":"2016-01-15T00:08:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ab3f4daf2a9db11e2fe5603a57ab00d5ed8ed81a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd/pulls/4214/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd/pulls/4214/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/4214/comments","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/4674faccb93e79ec481185707dbf14fe84cc3def","head":{"label":"gyuho:watch_integration_test","ref":"watch_integration_test","sha":"4674faccb93e79ec481185707dbf14fe84cc3def","user":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars.githubusercontent.com/u/6799218?v=3","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"repo":{"id":42982042,"name":"etcd","full_name":"gyuho/etcd","owner":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars.githubusercontent.com/u/6799218?v=3","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gyuho/etcd","description":"A distributed consistent key-value store for shared configuration and service discovery","fork":true,"url":"https://api.github.com/repos/gyuho/etcd","forks_url":"https://api.github.com/repos/gyuho/etcd/forks","keys_url":"https://api.github.com/repos/gyuho/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gyuho/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gyuho/etcd/teams","hooks_url":"https://api.github.com/repos/gyuho/etcd/hooks","issue_events_url":"https://api.github.com/repos/gyuho/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/gyuho/etcd/events","assignees_url":"https://api.github.com/repos/gyuho/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/gyuho/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/gyuho/etcd/tags","blobs_url":"https://api.github.com/repos/gyuho/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gyuho/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gyuho/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/gyuho/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gyuho/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/gyuho/etcd/languages","stargazers_url":"https://api.github.com/repos/gyuho/etcd/stargazers","contributors_url":"https://api.github.com/repos/gyuho/etcd/contributors","subscribers_url":"https://api.github.com/repos/gyuho/etcd/subscribers","subscription_url":"https://api.github.com/repos/gyuho/etcd/subscription","commits_url":"https://api.github.com/repos/gyuho/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/gyuho/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/gyuho/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/gyuho/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/gyuho/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/gyuho/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gyuho/etcd/merges","archive_url":"https://api.github.com/repos/gyuho/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gyuho/etcd/downloads","issues_url":"https://api.github.com/repos/gyuho/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/gyuho/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/gyuho/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/gyuho/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gyuho/etcd/labels{/name}","releases_url":"https://api.github.com/repos/gyuho/etcd/releases{/id}","created_at":"2015-09-23T06:15:42Z","updated_at":"2015-09-23T06:15:45Z","pushed_at":"2016-01-15T00:07:12Z","git_url":"git://github.com/gyuho/etcd.git","ssh_url":"git@github.com:gyuho/etcd.git","clone_url":"https://github.com/gyuho/etcd.git","svn_url":"https://github.com/gyuho/etcd","homepage":"","size":20302,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"02ab7be10675a31359c78b89a54d0d2721b7f546","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":11225014,"name":"etcd","full_name":"coreos/etcd","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd","description":"Distributed reliable key-value store for the most critical data of a distributed system","fork":false,"url":"https://api.github.com/repos/coreos/etcd","forks_url":"https://api.github.com/repos/coreos/etcd/forks","keys_url":"https://api.github.com/repos/coreos/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd/teams","hooks_url":"https://api.github.com/repos/coreos/etcd/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd/events","assignees_url":"https://api.github.com/repos/coreos/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd/tags","blobs_url":"https://api.github.com/repos/coreos/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd/subscription","commits_url":"https://api.github.com/repos/coreos/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd/merges","archive_url":"https://api.github.com/repos/coreos/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd/downloads","issues_url":"https://api.github.com/repos/coreos/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd/releases{/id}","created_at":"2013-07-06T21:57:21Z","updated_at":"2016-01-14T22:46:39Z","pushed_at":"2016-01-15T00:07:14Z","git_url":"git://github.com/coreos/etcd.git","ssh_url":"git@github.com:coreos/etcd.git","clone_url":"https://github.com/coreos/etcd.git","svn_url":"https://github.com/coreos/etcd","homepage":"https://coreos.com/etcd/docs/latest/","size":22574,"stargazers_count":8458,"watchers_count":8458,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1360,"mirror_url":null,"open_issues_count":150,"forks":1360,"open_issues":150,"watchers":8458,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/4214"},"html":{"href":"https://github.com/coreos/etcd/pull/4214"},"issue":{"href":"https://api.github.com/repos/coreos/etcd/issues/4214"},"comments":{"href":"https://api.github.com/repos/coreos/etcd/issues/4214/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd/pulls/4214/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd/pulls/4214/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd/statuses/4674faccb93e79ec481185707dbf14fe84cc3def"}}}}