{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd/pulls/comments/83452805","pull_request_review_id":4298027,"id":83452805,"diff_hunk":"@@ -212,6 +215,130 @@ func runRacer(eps []string, round int) {\n \tdoRounds(rcs, round)\n }\n \n+func runWatcher(eps []string) {\n+\t// watcher for setting watch on prefixes and also handling the response on watches\n+\ttype watcher struct {\n+\t\tprefix string\n+\t\tc      *clientv3.Client\n+\t\twc     clientv3.WatchChan\n+\t}\n+\n+\tprefixes := 36       // total number of prefixes which will be watched upon\n+\twatchPerPrefix := 10 // number of watchers per prefix\n+\tctx := context.Background()\n+\tprefixKeysMap := make(map[string][]string)\n+\tws := make([]watcher, prefixes*watchPerPrefix)\n+\n+\tvar (\n+\t\twg  sync.WaitGroup\n+\t\tpr  *clientv3.PutResponse\n+\t\terr error\n+\t)\n+\n+\tconst (\n+\t\tchars = \"abcdefghijklmnopqrstuvwxyz0123456789\" // for generating random keys and setting prefixes\n+\t)\n+\n+\t// assign watchPerPrefix times watchers on each prefix\n+\twg.Add(len(ws))\n+\tfor i := 0; i < len(ws); {\n+\t\tfor _, prefix := range chars {\n+\t\t\tgo func(w *watcher, i int, prefix rune) {\n+\t\t\t\tdefer wg.Done()\n+\t\t\t\tw.c = randClient(eps)\n+\t\t\t\tw.prefix = string(prefix)\n+\t\t\t\tw.wc = w.c.Watch(ctx, w.prefix, clientv3.WithPrefix())\n+\t\t\t}(&ws[i], i, prefix)\n+\t\t\ti++\n+\t\t}\n+\t}\n+\twg.Wait()\n+\n+\tdone := make(chan bool)\n+\t// generate and put keys in cluster\n+\tgo func(strlen int, runningTime time.Duration, reqRate int, done chan bool) {\n+\t\tclient := randClient(eps)\n+\t\tdefer client.Close()\n+\n+\t\trand.Seed(time.Now().UTC().UnixNano())\n+\t\tresult := make([]byte, strlen)\n+\t\tlimiter := rate.NewLimiter(rate.Limit(reqRate), reqRate)\n+\t\tctxt, cancel := context.WithDeadline(ctx, time.Now().Add(runningTime*time.Second))\n+\t\tdefer cancel()\n+\t\tfor {\n+\t\t\t// generate key\n+\t\t\tfor i := 0; i < strlen; i++ {\n+\t\t\t\tresult[i] = chars[rand.Intn(len(chars))]\n+\t\t\t}\n+\t\t\tkey := string(result)\n+\n+\t\t\t// limit key put as per reqRate\n+\t\t\terr = limiter.Wait(ctxt)\n+\t\t\tif err != nil {\n+\t\t\t\tdone <- true\n+\t\t\t\treturn\n+\t\t\t}\n+\n+\t\t\tprefix := key[0:1]\n+\t\t\tvals := prefixKeysMap[prefix]\n+\t\t\t//maintain a map of key prefix and the values put for the prefix\n+\t\t\tprefixKeysMap[prefix] = append(vals, key)\n+\n+\t\t\tpr, err = client.Put(ctxt, key, key)\n+\t\t\tif err == context.DeadlineExceeded {\n+\t\t\t\tdone <- true\n+\t\t\t\treturn\n+\t\t\t}\n+\n+\t\t\tif err != nil {\n+\t\t\t\tlog.Printf(\"Error: %v occured while trying to key: %v, value : %v to kv store.\", err, key, key)\n+\t\t\t\tcontinue\n+\t\t\t}\n+\t\t}\n+\t\tdone <- true\n+\t}(10, 30, 20, done)\n+\t<-done","path":"tools/functional-tester/etcd-runner/main.go","position":112,"original_position":112,"commit_id":"46ce68a20596b251a8336bbdea80707b486f27d5","original_commit_id":"46ce68a20596b251a8336bbdea80707b486f27d5","user":{"login":"sinsharat","id":20169156,"avatar_url":"https://avatars.githubusercontent.com/u/20169156?v=3","gravatar_id":"","url":"https://api.github.com/users/sinsharat","html_url":"https://github.com/sinsharat","followers_url":"https://api.github.com/users/sinsharat/followers","following_url":"https://api.github.com/users/sinsharat/following{/other_user}","gists_url":"https://api.github.com/users/sinsharat/gists{/gist_id}","starred_url":"https://api.github.com/users/sinsharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinsharat/subscriptions","organizations_url":"https://api.github.com/users/sinsharat/orgs","repos_url":"https://api.github.com/users/sinsharat/repos","events_url":"https://api.github.com/users/sinsharat/events{/privacy}","received_events_url":"https://api.github.com/users/sinsharat/received_events","type":"User","site_admin":false},"body":"@xiang90 but we will not know in the beginning on how many keys to generate. For this reason i was thinking of generating a go routine to keep generating keys in parallel with buffer of 100. This will be independently running and would have generated keys from before and we can keep reading on it using channels. Is this fine, or you want keys to be generated the way you suggested using an arbitrary large number?","created_at":"2016-10-14T16:07:11Z","updated_at":"2016-10-14T16:07:11Z","html_url":"https://github.com/coreos/etcd/pull/6635#discussion_r83452805","pull_request_url":"https://api.github.com/repos/coreos/etcd/pulls/6635","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments/83452805"},"html":{"href":"https://github.com/coreos/etcd/pull/6635#discussion_r83452805"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6635"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/6635","id":89099191,"html_url":"https://github.com/coreos/etcd/pull/6635","diff_url":"https://github.com/coreos/etcd/pull/6635.diff","patch_url":"https://github.com/coreos/etcd/pull/6635.patch","issue_url":"https://api.github.com/repos/coreos/etcd/issues/6635","number":6635,"state":"open","locked":false,"title":"etcd-runner:added watch runner","user":{"login":"sinsharat","id":20169156,"avatar_url":"https://avatars.githubusercontent.com/u/20169156?v=3","gravatar_id":"","url":"https://api.github.com/users/sinsharat","html_url":"https://github.com/sinsharat","followers_url":"https://api.github.com/users/sinsharat/followers","following_url":"https://api.github.com/users/sinsharat/following{/other_user}","gists_url":"https://api.github.com/users/sinsharat/gists{/gist_id}","starred_url":"https://api.github.com/users/sinsharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinsharat/subscriptions","organizations_url":"https://api.github.com/users/sinsharat/orgs","repos_url":"https://api.github.com/users/sinsharat/repos","events_url":"https://api.github.com/users/sinsharat/events{/privacy}","received_events_url":"https://api.github.com/users/sinsharat/received_events","type":"User","site_admin":false},"body":"#6584\r\n\r\n@xiang90 i have added the feature for watch runner.\r\nHave a few queries:\r\n\r\n1. Whether any of the parameter in runWatcher needs to be created as flag?\r\n2. If required the test can be modified to make putting of keys and reading on the watcher concurrent.\r\n\r\nThank you!","created_at":"2016-10-12T21:39:59Z","updated_at":"2016-10-14T16:07:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15ddbb0cb451da43bcb90744f5532077cd1758a1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd/pulls/6635/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd/pulls/6635/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/6635/comments","statuses_url":"https://api.github.com/repos/coreos/etcd/statuses/46ce68a20596b251a8336bbdea80707b486f27d5","head":{"label":"sinsharat:etcd_runner_add_watcher_runner","ref":"etcd_runner_add_watcher_runner","sha":"46ce68a20596b251a8336bbdea80707b486f27d5","user":{"login":"sinsharat","id":20169156,"avatar_url":"https://avatars.githubusercontent.com/u/20169156?v=3","gravatar_id":"","url":"https://api.github.com/users/sinsharat","html_url":"https://github.com/sinsharat","followers_url":"https://api.github.com/users/sinsharat/followers","following_url":"https://api.github.com/users/sinsharat/following{/other_user}","gists_url":"https://api.github.com/users/sinsharat/gists{/gist_id}","starred_url":"https://api.github.com/users/sinsharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinsharat/subscriptions","organizations_url":"https://api.github.com/users/sinsharat/orgs","repos_url":"https://api.github.com/users/sinsharat/repos","events_url":"https://api.github.com/users/sinsharat/events{/privacy}","received_events_url":"https://api.github.com/users/sinsharat/received_events","type":"User","site_admin":false},"repo":{"id":67736780,"name":"etcd","full_name":"sinsharat/etcd","owner":{"login":"sinsharat","id":20169156,"avatar_url":"https://avatars.githubusercontent.com/u/20169156?v=3","gravatar_id":"","url":"https://api.github.com/users/sinsharat","html_url":"https://github.com/sinsharat","followers_url":"https://api.github.com/users/sinsharat/followers","following_url":"https://api.github.com/users/sinsharat/following{/other_user}","gists_url":"https://api.github.com/users/sinsharat/gists{/gist_id}","starred_url":"https://api.github.com/users/sinsharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinsharat/subscriptions","organizations_url":"https://api.github.com/users/sinsharat/orgs","repos_url":"https://api.github.com/users/sinsharat/repos","events_url":"https://api.github.com/users/sinsharat/events{/privacy}","received_events_url":"https://api.github.com/users/sinsharat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sinsharat/etcd","description":"Distributed reliable key-value store for the most critical data of a distributed system","fork":true,"url":"https://api.github.com/repos/sinsharat/etcd","forks_url":"https://api.github.com/repos/sinsharat/etcd/forks","keys_url":"https://api.github.com/repos/sinsharat/etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sinsharat/etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sinsharat/etcd/teams","hooks_url":"https://api.github.com/repos/sinsharat/etcd/hooks","issue_events_url":"https://api.github.com/repos/sinsharat/etcd/issues/events{/number}","events_url":"https://api.github.com/repos/sinsharat/etcd/events","assignees_url":"https://api.github.com/repos/sinsharat/etcd/assignees{/user}","branches_url":"https://api.github.com/repos/sinsharat/etcd/branches{/branch}","tags_url":"https://api.github.com/repos/sinsharat/etcd/tags","blobs_url":"https://api.github.com/repos/sinsharat/etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sinsharat/etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sinsharat/etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/sinsharat/etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sinsharat/etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/sinsharat/etcd/languages","stargazers_url":"https://api.github.com/repos/sinsharat/etcd/stargazers","contributors_url":"https://api.github.com/repos/sinsharat/etcd/contributors","subscribers_url":"https://api.github.com/repos/sinsharat/etcd/subscribers","subscription_url":"https://api.github.com/repos/sinsharat/etcd/subscription","commits_url":"https://api.github.com/repos/sinsharat/etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/sinsharat/etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/sinsharat/etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/sinsharat/etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/sinsharat/etcd/contents/{+path}","compare_url":"https://api.github.com/repos/sinsharat/etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sinsharat/etcd/merges","archive_url":"https://api.github.com/repos/sinsharat/etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sinsharat/etcd/downloads","issues_url":"https://api.github.com/repos/sinsharat/etcd/issues{/number}","pulls_url":"https://api.github.com/repos/sinsharat/etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/sinsharat/etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/sinsharat/etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sinsharat/etcd/labels{/name}","releases_url":"https://api.github.com/repos/sinsharat/etcd/releases{/id}","deployments_url":"https://api.github.com/repos/sinsharat/etcd/deployments","created_at":"2016-09-08T20:11:20Z","updated_at":"2016-09-28T20:41:16Z","pushed_at":"2016-10-14T09:28:59Z","git_url":"git://github.com/sinsharat/etcd.git","ssh_url":"git@github.com:sinsharat/etcd.git","clone_url":"https://github.com/sinsharat/etcd.git","svn_url":"https://github.com/sinsharat/etcd","homepage":"https://coreos.com/etcd/docs/latest/","size":25257,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"57008f1690322d3be8aa67c144be9d50404ab3c8","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}","deployments_url":"https://api.github.com/repos/coreos/etcd/deployments","created_at":"2013-07-06T21:57:21Z","updated_at":"2016-10-14T15:13:30Z","pushed_at":"2016-10-14T14:56:26Z","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":32866,"stargazers_count":11113,"watchers_count":11113,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1967,"mirror_url":null,"open_issues_count":136,"forks":1967,"open_issues":136,"watchers":11113,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6635"},"html":{"href":"https://github.com/coreos/etcd/pull/6635"},"issue":{"href":"https://api.github.com/repos/coreos/etcd/issues/6635"},"comments":{"href":"https://api.github.com/repos/coreos/etcd/issues/6635/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6635/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd/pulls/6635/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd/statuses/46ce68a20596b251a8336bbdea80707b486f27d5"}}}}
{"actor":{"display_login":"sinsharat"}}