{"action":"created","comment":{"url":"https://api.github.com/repos/uber/ringpop-node/pulls/comments/60222046","id":60222046,"diff_hunk":"@@ -20,48 +20,114 @@\n \n 'use strict';\n \n+var async = require('async');\n+var _ = require('underscore');\n+\n var testRingpopCluster = require('../lib/test-ringpop-cluster.js');\n \n testRingpopCluster({\n+    bootstrapSize: 1,\n     size: 2,\n     waitForConvergence: false,\n     autoGossip: false\n-}, 'raise piggyback counter', function t(bootRes, cluster, assert) {\n-    assert.plan(1);\n-\n-    var pingSender = cluster[0];\n-    pingSender.gossip.tick(function() {\n-        var changes = pingSender.dissemination.changes;\n-        var joinChange = changes[pingSender.whoami()];\n-        var piggybackCount = joinChange.piggybackCount;\n-        assert.equals(piggybackCount, 1, 'piggyback counter raised by one');\n-        assert.end();\n+}, 'test bi-directional full syncs', function t(bootRes, cluster, assert) {\n+    // nodeA will include B in it's member list\n+    var nodeA = _.find(cluster, function(node) { return node.isReady;});\n+\n+    // nodeB will not include A in it's member list\n+    var nodeB = _.find(cluster, function(node) { return !node.isReady;});\n+\n+    // bootstrap node B without A.\n+    nodeB.bootstrap([nodeB.hostPort], function onBootStrapped(err) {\n+        assert.error(err);\n+\n+        // clear changes to trigger a full sync\n+        nodeA.dissemination.clearChanges();\n+        nodeB.dissemination.clearChanges();\n+\n+        // verify nodeA does include B in it's member list\n+        assert.notEqual(nodeA.membership.findMemberByAddress(nodeB.hostPort), undefined);\n+\n+        // verify nodeB doesn't include A in it's member list\n+        assert.equal(nodeB.membership.findMemberByAddress(nodeA.hostPort), undefined);\n+\n+        nodeB.membership.on('updated', function(updates) {\n+            // verify nodeB now includes A in it's member list\n+            assert.notEqual(nodeB.membership.findMemberByAddress(nodeA.hostPort), undefined);\n+            assert.end();\n+        });\n+\n+        nodeA.gossip.tick();\n     });\n+\n+    assert.timeoutAfter(2000);\n });\n \n-function mkBadPingResponder(ringpop) {\n-    ringpop.channel.register('/protocol/ping', function protocolPing(req, res) {\n-        res.headers.as = 'raw';\n-        res.sendNotOk(null, JSON.stringify('ping failed on purpose'));\n-    });\n-}\n \n testRingpopCluster({\n+    bootstrapSize: 1,\n     size: 2,\n     waitForConvergence: false,\n-    autoGossip: false,\n-    tap: function tap(cluster) {\n-        mkBadPingResponder(cluster[1]);\n-    },\n-}, 'don\\'t raise piggyback counter when ping fails', function t(bootRes, cluster, assert) {\n-    assert.plan(1);\n-\n-    var pingSender = cluster[0];\n-    pingSender.gossip.tick(function() {\n-        var changes = pingSender.dissemination.changes;\n-        var joinChange = changes[pingSender.whoami()];\n-        var piggybackCount = joinChange.piggybackCount;\n-        assert.equals(piggybackCount, 0, 'piggyback counter not raised');\n-        assert.end();\n+    autoGossip: false\n+}, 'test bi-directional full syncs throttles', function t(bootRes, cluster, assert) {\n+    // nodeA will include B in it's member list\n+    var nodeA = _.find(cluster, function(node) { return node.isReady;});\n+\n+    // nodeB will not include A in it's member list\n+    var nodeB = _.find(cluster, function(node) { return !node.isReady;});\n+\n+    // bootstrap node B without A.\n+    nodeB.bootstrap([nodeB.hostPort], function onBootStrapped(err) {\n+        assert.error(err);\n+\n+        // verify nodeA does include B in it's member list\n+        assert.notEqual(nodeA.membership.findMemberByAddress(nodeB.hostPort), undefined);\n+\n+        // verify nodeB doesn't include A in it's member list\n+        assert.equal(nodeB.membership.findMemberByAddress(nodeA.hostPort), undefined);\n+\n+        var realProtocolJoin = nodeB.client.protocolJoin.bind(nodeB.client);\n+        var protocolJoinCalls = [];\n+        nodeB.client.protocolJoin = function() {\n+            protocolJoinCalls.push(arguments);\n+            assert.equal(nodeB.dissemination.reverseFullSyncJobs, protocolJoinCalls.length);\n+            if (protocolJoinCalls.length > nodeB.maxReverseFullSyncJobs) {\n+                assert.fail('full sync should have been throttled');\n+            }\n+        };\n+\n+        async.timesSeries(nodeB.maxReverseFullSyncJobs, function tick(i, next) {","path":"test/integration/bidirectional-full-sync-test.js","position":99,"original_position":110,"commit_id":"93093dfbea50932ca9692d3a3f46458b177a3c56","original_commit_id":"72031f7e24a3ee58696699177e4c0727aaf33f1c","user":{"login":"CorgiMan","id":2640140,"avatar_url":"https://avatars.githubusercontent.com/u/2640140?v=3","gravatar_id":"","url":"https://api.github.com/users/CorgiMan","html_url":"https://github.com/CorgiMan","followers_url":"https://api.github.com/users/CorgiMan/followers","following_url":"https://api.github.com/users/CorgiMan/following{/other_user}","gists_url":"https://api.github.com/users/CorgiMan/gists{/gist_id}","starred_url":"https://api.github.com/users/CorgiMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CorgiMan/subscriptions","organizations_url":"https://api.github.com/users/CorgiMan/orgs","repos_url":"https://api.github.com/users/CorgiMan/repos","events_url":"https://api.github.com/users/CorgiMan/events{/privacy}","received_events_url":"https://api.github.com/users/CorgiMan/received_events","type":"User","site_admin":false},"body":"what's the benefit of using timeSeries here?","created_at":"2016-04-19T12:38:21Z","updated_at":"2016-04-19T12:38:21Z","html_url":"https://github.com/uber/ringpop-node/pull/251#discussion_r60222046","pull_request_url":"https://api.github.com/repos/uber/ringpop-node/pulls/251","_links":{"self":{"href":"https://api.github.com/repos/uber/ringpop-node/pulls/comments/60222046"},"html":{"href":"https://github.com/uber/ringpop-node/pull/251#discussion_r60222046"},"pull_request":{"href":"https://api.github.com/repos/uber/ringpop-node/pulls/251"}}},"pull_request":{"url":"https://api.github.com/repos/uber/ringpop-node/pulls/251","id":66332323,"html_url":"https://github.com/uber/ringpop-node/pull/251","diff_url":"https://github.com/uber/ringpop-node/pull/251.diff","patch_url":"https://github.com/uber/ringpop-node/pull/251.patch","issue_url":"https://api.github.com/repos/uber/ringpop-node/issues/251","number":251,"state":"open","locked":false,"title":"Bi-directional full syncs","user":{"login":"mennopruijssers","id":831983,"avatar_url":"https://avatars.githubusercontent.com/u/831983?v=3","gravatar_id":"","url":"https://api.github.com/users/mennopruijssers","html_url":"https://github.com/mennopruijssers","followers_url":"https://api.github.com/users/mennopruijssers/followers","following_url":"https://api.github.com/users/mennopruijssers/following{/other_user}","gists_url":"https://api.github.com/users/mennopruijssers/gists{/gist_id}","starred_url":"https://api.github.com/users/mennopruijssers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mennopruijssers/subscriptions","organizations_url":"https://api.github.com/users/mennopruijssers/orgs","repos_url":"https://api.github.com/users/mennopruijssers/repos","events_url":"https://api.github.com/users/mennopruijssers/events{/privacy}","received_events_url":"https://api.github.com/users/mennopruijssers/received_events","type":"User","site_admin":false},"body":"This is a port of the bi-direcitonal full syncs feature in ringpop-go.","created_at":"2016-04-13T14:37:58Z","updated_at":"2016-04-19T12:38:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43a5f6f43f3253e19b9393196e8115c5c7da373a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/uber/ringpop-node/pulls/251/commits","review_comments_url":"https://api.github.com/repos/uber/ringpop-node/pulls/251/comments","review_comment_url":"https://api.github.com/repos/uber/ringpop-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uber/ringpop-node/issues/251/comments","statuses_url":"https://api.github.com/repos/uber/ringpop-node/statuses/93093dfbea50932ca9692d3a3f46458b177a3c56","head":{"label":"uber:uber/menno/bi-dir-sync","ref":"uber/menno/bi-dir-sync","sha":"93093dfbea50932ca9692d3a3f46458b177a3c56","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":29378455,"name":"ringpop-node","full_name":"uber/ringpop-node","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/ringpop-node","description":"Scalable, fault-tolerant application-layer sharding for Node.js applications","fork":false,"url":"https://api.github.com/repos/uber/ringpop-node","forks_url":"https://api.github.com/repos/uber/ringpop-node/forks","keys_url":"https://api.github.com/repos/uber/ringpop-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/ringpop-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/ringpop-node/teams","hooks_url":"https://api.github.com/repos/uber/ringpop-node/hooks","issue_events_url":"https://api.github.com/repos/uber/ringpop-node/issues/events{/number}","events_url":"https://api.github.com/repos/uber/ringpop-node/events","assignees_url":"https://api.github.com/repos/uber/ringpop-node/assignees{/user}","branches_url":"https://api.github.com/repos/uber/ringpop-node/branches{/branch}","tags_url":"https://api.github.com/repos/uber/ringpop-node/tags","blobs_url":"https://api.github.com/repos/uber/ringpop-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/ringpop-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/ringpop-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/ringpop-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/ringpop-node/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/ringpop-node/languages","stargazers_url":"https://api.github.com/repos/uber/ringpop-node/stargazers","contributors_url":"https://api.github.com/repos/uber/ringpop-node/contributors","subscribers_url":"https://api.github.com/repos/uber/ringpop-node/subscribers","subscription_url":"https://api.github.com/repos/uber/ringpop-node/subscription","commits_url":"https://api.github.com/repos/uber/ringpop-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/ringpop-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/ringpop-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/ringpop-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/ringpop-node/contents/{+path}","compare_url":"https://api.github.com/repos/uber/ringpop-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/ringpop-node/merges","archive_url":"https://api.github.com/repos/uber/ringpop-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/ringpop-node/downloads","issues_url":"https://api.github.com/repos/uber/ringpop-node/issues{/number}","pulls_url":"https://api.github.com/repos/uber/ringpop-node/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/ringpop-node/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/ringpop-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/ringpop-node/labels{/name}","releases_url":"https://api.github.com/repos/uber/ringpop-node/releases{/id}","deployments_url":"https://api.github.com/repos/uber/ringpop-node/deployments","created_at":"2015-01-17T03:26:35Z","updated_at":"2016-04-18T18:12:43Z","pushed_at":"2016-04-19T12:29:15Z","git_url":"git://github.com/uber/ringpop-node.git","ssh_url":"git@github.com:uber/ringpop-node.git","clone_url":"https://github.com/uber/ringpop-node.git","svn_url":"https://github.com/uber/ringpop-node","homepage":"http://uber.github.io/ringpop/","size":1384,"stargazers_count":562,"watchers_count":562,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"open_issues_count":24,"forks":58,"open_issues":24,"watchers":562,"default_branch":"master"}},"base":{"label":"uber:master","ref":"master","sha":"d5758c2c168fbfa6ea37b1d132a25fd85ccd4500","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":29378455,"name":"ringpop-node","full_name":"uber/ringpop-node","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/ringpop-node","description":"Scalable, fault-tolerant application-layer sharding for Node.js applications","fork":false,"url":"https://api.github.com/repos/uber/ringpop-node","forks_url":"https://api.github.com/repos/uber/ringpop-node/forks","keys_url":"https://api.github.com/repos/uber/ringpop-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/ringpop-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/ringpop-node/teams","hooks_url":"https://api.github.com/repos/uber/ringpop-node/hooks","issue_events_url":"https://api.github.com/repos/uber/ringpop-node/issues/events{/number}","events_url":"https://api.github.com/repos/uber/ringpop-node/events","assignees_url":"https://api.github.com/repos/uber/ringpop-node/assignees{/user}","branches_url":"https://api.github.com/repos/uber/ringpop-node/branches{/branch}","tags_url":"https://api.github.com/repos/uber/ringpop-node/tags","blobs_url":"https://api.github.com/repos/uber/ringpop-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/ringpop-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/ringpop-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/ringpop-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/ringpop-node/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/ringpop-node/languages","stargazers_url":"https://api.github.com/repos/uber/ringpop-node/stargazers","contributors_url":"https://api.github.com/repos/uber/ringpop-node/contributors","subscribers_url":"https://api.github.com/repos/uber/ringpop-node/subscribers","subscription_url":"https://api.github.com/repos/uber/ringpop-node/subscription","commits_url":"https://api.github.com/repos/uber/ringpop-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/ringpop-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/ringpop-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/ringpop-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/ringpop-node/contents/{+path}","compare_url":"https://api.github.com/repos/uber/ringpop-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/ringpop-node/merges","archive_url":"https://api.github.com/repos/uber/ringpop-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/ringpop-node/downloads","issues_url":"https://api.github.com/repos/uber/ringpop-node/issues{/number}","pulls_url":"https://api.github.com/repos/uber/ringpop-node/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/ringpop-node/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/ringpop-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/ringpop-node/labels{/name}","releases_url":"https://api.github.com/repos/uber/ringpop-node/releases{/id}","deployments_url":"https://api.github.com/repos/uber/ringpop-node/deployments","created_at":"2015-01-17T03:26:35Z","updated_at":"2016-04-18T18:12:43Z","pushed_at":"2016-04-19T12:29:15Z","git_url":"git://github.com/uber/ringpop-node.git","ssh_url":"git@github.com:uber/ringpop-node.git","clone_url":"https://github.com/uber/ringpop-node.git","svn_url":"https://github.com/uber/ringpop-node","homepage":"http://uber.github.io/ringpop/","size":1384,"stargazers_count":562,"watchers_count":562,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"open_issues_count":24,"forks":58,"open_issues":24,"watchers":562,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uber/ringpop-node/pulls/251"},"html":{"href":"https://github.com/uber/ringpop-node/pull/251"},"issue":{"href":"https://api.github.com/repos/uber/ringpop-node/issues/251"},"comments":{"href":"https://api.github.com/repos/uber/ringpop-node/issues/251/comments"},"review_comments":{"href":"https://api.github.com/repos/uber/ringpop-node/pulls/251/comments"},"review_comment":{"href":"https://api.github.com/repos/uber/ringpop-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uber/ringpop-node/pulls/251/commits"},"statuses":{"href":"https://api.github.com/repos/uber/ringpop-node/statuses/93093dfbea50932ca9692d3a3f46458b177a3c56"}}}}