GitHub PullRequestReviewCommentEvent at 2014-07-31 18:03:20
Repository: Daptiv.Bus
Actor: drewburlingame
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/comments/15658548","id":15658548,"diff_hunk":"@@ -0,0 +1,144 @@\n+﻿using Druq.Framework;\n+using Druq.Framework.Database;\n+using Druq.Hub;\n+using Druq.Hub.Messaging;\n+using NUnit.Framework;\n+using SharpTestsEx;\n+using System;\n+using System.Collections.Concurrent;\n+\n+namespace Druq.Tests.Integration.Hub.Messaging\n+{\n+    [TestFixture]\n+    public class IdempotencyServiceTests\n+    {\n+        private readonly string[] _subscriber = new[] { \"mysub1\", \"mysub2\", \"mysub3\", \"mysub4\", \"mysub5\" };\n+        private readonly string[] _msgKey = new[] { \"mymsgkey1\", \"mymsgkey2\", \"mymsgkey3\", \"mymsgkey4\", \"mymsgkey5\" };\n+\n+        private ISnapshot[] _hubSnapshot;\n+        private IDatabaseFactory _dbFactory;\n+        private CurrentHub _currentHub;\n+        private IPartitionDb _partDb;\n+        private ConcurrentDictionary<string, CacheItem<DateTime>> _cache;\n+        private IdempotencyService _service;\n+        private IDisposable _lock;\n+        private DateTime _now;\n+\n+        /* Test List\n+         * \n+         * can get \n+         * \n+         */\n+\n+        [TestFixtureSetUp]\n+        public void FixtureSetup()\n+        {\n+            _dbFactory = IoC.Resolve<IDatabaseFactory>();\n+            _hubSnapshot = Snapshot.Take(_dbFactory.GetHubDb());\n+            _currentHub = new CurrentHub {Hub = TestConfig.Hub};\n+            _partDb = TestConfig.Partition1Db;\n+        }\n+\n+        [TestFixtureTearDown]\n+        public void FixtureTeardown()\n+        {\n+            _hubSnapshot.Restore();\n+        }\n+\n+        [SetUp]\n+        public void Setup()\n+        {\n+            _hubSnapshot.Truncate();\n+            _cache = new ConcurrentDictionary<string, CacheItem<DateTime>>();\n+            _service = new IdempotencyService(_currentHub, _cache);\n+            _now = Time.Now;\n+            _lock = null;\n+        }\n+\n+        [TearDown]\n+        public void Teardown()\n+        {\n+            if (_lock != null)\n+            {\n+                _lock.Dispose();\n+            }\n+            _cache.Clear();\n+        }\n+\n+        [Test]\n+        public void ShouldRun_should_return_true_for_new_alike_messages_until_LogMessageRun_has_been_called()\n+        {\n+            _service.ShouldRun(_partDb, _now, _subscriber[0], _msgKey[0]).Should().Be.True();\n+            _service.ShouldRun(_partDb, _now, _subscriber[0], _msgKey[0]).Should().Be.True();\n+            _service.LogMessageRun(_partDb, _subscriber[0], _msgKey[0]);\n+            _service.ShouldRun(_partDb, _now, _subscriber[0], _msgKey[0]).Should().Be.False();\n+            \n+            //ensures this works across machines\n+            _cache.Clear();\n+            _service.ShouldRun(_partDb, _now, _subscriber[0], _msgKey[0]).Should().Be.False();\n+        }\n+\n+        [Test]\n+        public void ShouldRun_should_return_true_if_LogMessageRun_has_been_called_before_alike_message_is_processed()\n+        {\n+            _service.ShouldRun(_partDb, _now, _subscriber[1], _msgKey[1]).Should().Be.True();\n+            _service.LogMessageRun(_partDb, _subscriber[1], _msgKey[1]);\n+\n+            _now = _now.AddSeconds(1);","path":"Druq.Tests.Integration/Hub/Messaging/IdempotencyServiceTests.cs","position":87,"original_position":87,"commit_id":"9663b71fe51bb9819874896d12d40d1fdbf04781","original_commit_id":"9663b71fe51bb9819874896d12d40d1fdbf04781","user":{"login":"drewburlingame","id":103345,"avatar_url":"https://avatars.githubusercontent.com/u/103345?v=1","gravatar_id":"b093ff7de1152d62c0705027a780936f","url":"https://api.github.com/users/drewburlingame","html_url":"https://github.com/drewburlingame","followers_url":"https://api.github.com/users/drewburlingame/followers","following_url":"https://api.github.com/users/drewburlingame/following{/other_user}","gists_url":"https://api.github.com/users/drewburlingame/gists{/gist_id}","starred_url":"https://api.github.com/users/drewburlingame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewburlingame/subscriptions","organizations_url":"https://api.github.com/users/drewburlingame/orgs","repos_url":"https://api.github.com/users/drewburlingame/repos","events_url":"https://api.github.com/users/drewburlingame/events{/privacy}","received_events_url":"https://api.github.com/users/drewburlingame/received_events","type":"User","site_admin":false},"body":"if we end up with a few long context switches, _now.AddSeconds(1) may still be less than the Time.Now used in LogMessageRun.  Safer choice would be \r\n\r\n_service.ShouldRun(_partDb, Time.Now.AddSeconds(1), _subscriber[1], _msgKey[1]).Should().Be.True();","created_at":"2014-07-31T18:03:20Z","updated_at":"2014-07-31T18:03:20Z","html_url":"https://github.com/daptiv/Daptiv.Bus/pull/56#discussion_r15658548","pull_request_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/comments/15658548"},"html":{"href":"https://github.com/daptiv/Daptiv.Bus/pull/56#discussion_r15658548"},"pull_request":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56","id":18303917,"html_url":"https://github.com/daptiv/Daptiv.Bus/pull/56","diff_url":"https://github.com/daptiv/Daptiv.Bus/pull/56.diff","patch_url":"https://github.com/daptiv/Daptiv.Bus/pull/56.patch","issue_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/56","number":56,"state":"open","title":"Idemponent","user":{"login":"drewburlingame","id":103345,"avatar_url":"https://avatars.githubusercontent.com/u/103345?v=1","gravatar_id":"b093ff7de1152d62c0705027a780936f","url":"https://api.github.com/users/drewburlingame","html_url":"https://github.com/drewburlingame","followers_url":"https://api.github.com/users/drewburlingame/followers","following_url":"https://api.github.com/users/drewburlingame/following{/other_user}","gists_url":"https://api.github.com/users/drewburlingame/gists{/gist_id}","starred_url":"https://api.github.com/users/drewburlingame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewburlingame/subscriptions","organizations_url":"https://api.github.com/users/drewburlingame/orgs","repos_url":"https://api.github.com/users/drewburlingame/repos","events_url":"https://api.github.com/users/drewburlingame/events{/privacy}","received_events_url":"https://api.github.com/users/drewburlingame/received_events","type":"User","site_admin":false},"body":":warning: not ready for merge :warning: \r\n\r\n- [ ] add partition migration for Idempotent\r\n- [ ] update query to get lock to account for dead hubs locking the idempotent record\r\n- [ ] add tests for IdempotencyService\r\n- [ ] add tests for MessageProcessor\r\n- [ ] test SubscriberValidator in PPM\r\n\r\noptional\r\n- [ ] find a better name than Idempotent","created_at":"2014-07-11T21:50:25Z","updated_at":"2014-07-31T18:03:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd7d27d689320e00a3f728ca1a8b01ea008c6090","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56/commits","review_comments_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56/comments","review_comment_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/comments/{number}","comments_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/56/comments","statuses_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/statuses/9663b71fe51bb9819874896d12d40d1fdbf04781","head":{"label":"daptiv:idemponent","ref":"idemponent","sha":"9663b71fe51bb9819874896d12d40d1fdbf04781","user":{"login":"daptiv","id":601501,"avatar_url":"https://avatars.githubusercontent.com/u/601501?v=1","gravatar_id":"ea1e0d6922efb4b6d03e8b29f2741645","url":"https://api.github.com/users/daptiv","html_url":"https://github.com/daptiv","followers_url":"https://api.github.com/users/daptiv/followers","following_url":"https://api.github.com/users/daptiv/following{/other_user}","gists_url":"https://api.github.com/users/daptiv/gists{/gist_id}","starred_url":"https://api.github.com/users/daptiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daptiv/subscriptions","organizations_url":"https://api.github.com/users/daptiv/orgs","repos_url":"https://api.github.com/users/daptiv/repos","events_url":"https://api.github.com/users/daptiv/events{/privacy}","received_events_url":"https://api.github.com/users/daptiv/received_events","type":"Organization","site_admin":false},"repo":{"id":17488097,"name":"Daptiv.Bus","full_name":"daptiv/Daptiv.Bus","owner":{"login":"daptiv","id":601501,"avatar_url":"https://avatars.githubusercontent.com/u/601501?v=1","gravatar_id":"ea1e0d6922efb4b6d03e8b29f2741645","url":"https://api.github.com/users/daptiv","html_url":"https://github.com/daptiv","followers_url":"https://api.github.com/users/daptiv/followers","following_url":"https://api.github.com/users/daptiv/following{/other_user}","gists_url":"https://api.github.com/users/daptiv/gists{/gist_id}","starred_url":"https://api.github.com/users/daptiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daptiv/subscriptions","organizations_url":"https://api.github.com/users/daptiv/orgs","repos_url":"https://api.github.com/users/daptiv/repos","events_url":"https://api.github.com/users/daptiv/events{/privacy}","received_events_url":"https://api.github.com/users/daptiv/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/daptiv/Daptiv.Bus","description":"Temporary message bus until we can get resources for a real message bus","fork":false,"url":"https://api.github.com/repos/daptiv/Daptiv.Bus","forks_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/forks","keys_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/teams","hooks_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/hooks","issue_events_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/events{/number}","events_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/events","assignees_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/assignees{/user}","branches_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/branches{/branch}","tags_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/tags","blobs_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/refs{/sha}","trees_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/statuses/{sha}","languages_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/languages","stargazers_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/stargazers","contributors_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/contributors","subscribers_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/subscribers","subscription_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/subscription","commits_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/commits{/sha}","git_commits_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/commits{/sha}","comments_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/comments{/number}","issue_comment_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/comments/{number}","contents_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/contents/{+path}","compare_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/merges","archive_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/downloads","issues_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues{/number}","pulls_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls{/number}","milestones_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/milestones{/number}","notifications_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/labels{/name}","releases_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/releases{/id}","created_at":"2014-03-06T18:32:04Z","updated_at":"2014-07-02T21:05:59Z","pushed_at":"2014-07-31T17:50:24Z","git_url":"git://github.com/daptiv/Daptiv.Bus.git","ssh_url":"git@github.com:daptiv/Daptiv.Bus.git","clone_url":"https://github.com/daptiv/Daptiv.Bus.git","svn_url":"https://github.com/daptiv/Daptiv.Bus","homepage":null,"size":15580,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"daptiv:master","ref":"master","sha":"5099ac5db6c7faeff9bb25a01d8f259ab30edfe6","user":{"login":"daptiv","id":601501,"avatar_url":"https://avatars.githubusercontent.com/u/601501?v=1","gravatar_id":"ea1e0d6922efb4b6d03e8b29f2741645","url":"https://api.github.com/users/daptiv","html_url":"https://github.com/daptiv","followers_url":"https://api.github.com/users/daptiv/followers","following_url":"https://api.github.com/users/daptiv/following{/other_user}","gists_url":"https://api.github.com/users/daptiv/gists{/gist_id}","starred_url":"https://api.github.com/users/daptiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daptiv/subscriptions","organizations_url":"https://api.github.com/users/daptiv/orgs","repos_url":"https://api.github.com/users/daptiv/repos","events_url":"https://api.github.com/users/daptiv/events{/privacy}","received_events_url":"https://api.github.com/users/daptiv/received_events","type":"Organization","site_admin":false},"repo":{"id":17488097,"name":"Daptiv.Bus","full_name":"daptiv/Daptiv.Bus","owner":{"login":"daptiv","id":601501,"avatar_url":"https://avatars.githubusercontent.com/u/601501?v=1","gravatar_id":"ea1e0d6922efb4b6d03e8b29f2741645","url":"https://api.github.com/users/daptiv","html_url":"https://github.com/daptiv","followers_url":"https://api.github.com/users/daptiv/followers","following_url":"https://api.github.com/users/daptiv/following{/other_user}","gists_url":"https://api.github.com/users/daptiv/gists{/gist_id}","starred_url":"https://api.github.com/users/daptiv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daptiv/subscriptions","organizations_url":"https://api.github.com/users/daptiv/orgs","repos_url":"https://api.github.com/users/daptiv/repos","events_url":"https://api.github.com/users/daptiv/events{/privacy}","received_events_url":"https://api.github.com/users/daptiv/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/daptiv/Daptiv.Bus","description":"Temporary message bus until we can get resources for a real message bus","fork":false,"url":"https://api.github.com/repos/daptiv/Daptiv.Bus","forks_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/forks","keys_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/teams","hooks_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/hooks","issue_events_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/events{/number}","events_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/events","assignees_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/assignees{/user}","branches_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/branches{/branch}","tags_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/tags","blobs_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/refs{/sha}","trees_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/statuses/{sha}","languages_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/languages","stargazers_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/stargazers","contributors_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/contributors","subscribers_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/subscribers","subscription_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/subscription","commits_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/commits{/sha}","git_commits_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/git/commits{/sha}","comments_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/comments{/number}","issue_comment_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/comments/{number}","contents_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/contents/{+path}","compare_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/merges","archive_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/downloads","issues_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues{/number}","pulls_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls{/number}","milestones_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/milestones{/number}","notifications_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/labels{/name}","releases_url":"https://api.github.com/repos/daptiv/Daptiv.Bus/releases{/id}","created_at":"2014-03-06T18:32:04Z","updated_at":"2014-07-02T21:05:59Z","pushed_at":"2014-07-31T17:50:24Z","git_url":"git://github.com/daptiv/Daptiv.Bus.git","ssh_url":"git@github.com:daptiv/Daptiv.Bus.git","clone_url":"https://github.com/daptiv/Daptiv.Bus.git","svn_url":"https://github.com/daptiv/Daptiv.Bus","homepage":null,"size":15580,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56"},"html":{"href":"https://github.com/daptiv/Daptiv.Bus/pull/56"},"issue":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/56"},"comments":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/daptiv/Daptiv.Bus/statuses/9663b71fe51bb9819874896d12d40d1fdbf04781"}}}}