{"action":"created","comment":{"url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/comments/36863628","id":36863628,"diff_hunk":"@@ -538,3 +539,78 @@ TEST_F(SNMPTest, SuccessFailCountByRequestTypeTable)\n   cwtest_reset_time();\n   delete tbl;\n }\n+\n+// Advance to the next start of interval - accurate to within the first\n+// second.\n+void jump_to_next_periodstart(uint32_t interval_ms)\n+{\n+  struct timespec now;\n+  clock_gettime(CLOCK_REALTIME_COARSE, &now);\n+  uint64_t ms_since_epoch = (now.tv_sec * 1000) + (now.tv_nsec / 1000000);\n+  cwtest_advance_time_ms(interval_ms - (ms_since_epoch % interval_ms));\n+}\n+\n+TEST_F(SNMPTest, ContinuousAccumulatorTable)\n+{\n+  cwtest_completely_control_time();\n+\n+  // Consider a 5 minute period\n+  jump_to_next_periodstart(300000);\n+\n+  // Advance to 2m into the period\n+  cwtest_advance_time_ms(120000);\n+\n+  // Create table at this point\n+  SNMP::ContinuousAccumulatorTable* tbl = SNMP::ContinuousAccumulatorTable::create(\"continuous\", test_oid);\n+\n+  // Add one value to the table and advance 90 seconds\n+  tbl->accumulate(200);\n+  cwtest_advance_time_ms(90000);\n+\n+  // Average should not take into account the time before the table was created\n+  // (therefore average should still be 200)\n+  FILE* fd = popen(\"snmpwalk -v2c -On -c clearwater 127.0.0.1:16161 .1.2.2.1.2.2\", \"r\");\n+  char buf[1024];\n+  fgets(buf, sizeof(buf), fd);\n+  ASSERT_STREQ(\".1.2.2.1.2.2 = Gauge32: 200\\n\", buf); // Current 5 minutes\n+\n+  // Add another value to the table and advance 89 seconds\n+  tbl->accumulate(100);\n+  cwtest_advance_time_ms(89000);\n+\n+  // This period has spent half the time at 200, and half at 100\n+  // So average value should be 150\n+  fd = popen(\"snmpwalk -v2c -On -c clearwater 127.0.0.1:16161 .1.2.2.1.2.2\", \"r\");\n+  fgets(buf, sizeof(buf), fd);\n+  ASSERT_STREQ(\".1.2.2.1.2.2 = Gauge32: 150\\n\", buf); // Current 5 minutes\n+\n+  // Jump forward to the next 5 minutes (half way through it)","path":"src/test_snmp.cpp","position":236,"original_position":236,"commit_id":"3b4720c192555a17881179ee03c7f0d3a052285b","original_commit_id":"3b4720c192555a17881179ee03c7f0d3a052285b","user":{"login":"TygerBurning","id":6792948,"avatar_url":"https://avatars.githubusercontent.com/u/6792948?v=3","gravatar_id":"","url":"https://api.github.com/users/TygerBurning","html_url":"https://github.com/TygerBurning","followers_url":"https://api.github.com/users/TygerBurning/followers","following_url":"https://api.github.com/users/TygerBurning/following{/other_user}","gists_url":"https://api.github.com/users/TygerBurning/gists{/gist_id}","starred_url":"https://api.github.com/users/TygerBurning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TygerBurning/subscriptions","organizations_url":"https://api.github.com/users/TygerBurning/orgs","repos_url":"https://api.github.com/users/TygerBurning/repos","events_url":"https://api.github.com/users/TygerBurning/events{/privacy}","received_events_url":"https://api.github.com/users/TygerBurning/received_events","type":"User","site_admin":false},"body":"Recall we advanced time by 120s at the beginning to prove start of periods don't need to be at boundaries, but I've made this clearer anyway\r\n","created_at":"2015-08-12T14:10:18Z","updated_at":"2015-08-12T14:10:18Z","html_url":"https://github.com/Metaswitch/clearwater-fv-test/pull/21#discussion_r36863628","pull_request_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/comments/36863628"},"html":{"href":"https://github.com/Metaswitch/clearwater-fv-test/pull/21#discussion_r36863628"},"pull_request":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21","id":42028656,"html_url":"https://github.com/Metaswitch/clearwater-fv-test/pull/21","diff_url":"https://github.com/Metaswitch/clearwater-fv-test/pull/21.diff","patch_url":"https://github.com/Metaswitch/clearwater-fv-test/pull/21.patch","issue_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/21","number":21,"state":"open","locked":false,"title":"[Reviewer: Matt] Added test for continuous accumulator ","user":{"login":"TygerBurning","id":6792948,"avatar_url":"https://avatars.githubusercontent.com/u/6792948?v=3","gravatar_id":"","url":"https://api.github.com/users/TygerBurning","html_url":"https://github.com/TygerBurning","followers_url":"https://api.github.com/users/TygerBurning/followers","following_url":"https://api.github.com/users/TygerBurning/following{/other_user}","gists_url":"https://api.github.com/users/TygerBurning/gists{/gist_id}","starred_url":"https://api.github.com/users/TygerBurning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TygerBurning/subscriptions","organizations_url":"https://api.github.com/users/TygerBurning/orgs","repos_url":"https://api.github.com/users/TygerBurning/repos","events_url":"https://api.github.com/users/TygerBurning/events{/privacy}","received_events_url":"https://api.github.com/users/TygerBurning/received_events","type":"User","site_admin":false},"body":"Renamed AccumulatorTable to the new name EventAccumulatorTable and added UT for ContinuousAccumulatorTable, including for crossover period cases and non-boundary aligned period starts.","created_at":"2015-08-10T14:54:32Z","updated_at":"2015-08-12T14:10:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"222823d579be71825c4048e178cb11cd15bba204","assignee":{"login":"TygerBurning","id":6792948,"avatar_url":"https://avatars.githubusercontent.com/u/6792948?v=3","gravatar_id":"","url":"https://api.github.com/users/TygerBurning","html_url":"https://github.com/TygerBurning","followers_url":"https://api.github.com/users/TygerBurning/followers","following_url":"https://api.github.com/users/TygerBurning/following{/other_user}","gists_url":"https://api.github.com/users/TygerBurning/gists{/gist_id}","starred_url":"https://api.github.com/users/TygerBurning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TygerBurning/subscriptions","organizations_url":"https://api.github.com/users/TygerBurning/orgs","repos_url":"https://api.github.com/users/TygerBurning/repos","events_url":"https://api.github.com/users/TygerBurning/events{/privacy}","received_events_url":"https://api.github.com/users/TygerBurning/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21/commits","review_comments_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21/comments","review_comment_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/21/comments","statuses_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/statuses/3b4720c192555a17881179ee03c7f0d3a052285b","head":{"label":"Metaswitch:sto1375","ref":"sto1375","sha":"3b4720c192555a17881179ee03c7f0d3a052285b","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":31425304,"name":"clearwater-fv-test","full_name":"Metaswitch/clearwater-fv-test","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/clearwater-fv-test","description":"Functional verification tests for Clearwater components.","fork":false,"url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test","forks_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/forks","keys_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/teams","hooks_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/events","assignees_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/tags","blobs_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/subscription","commits_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/merges","archive_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/downloads","issues_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/releases{/id}","created_at":"2015-02-27T15:21:58Z","updated_at":"2015-05-07T12:02:08Z","pushed_at":"2015-08-12T14:09:17Z","git_url":"git://github.com/Metaswitch/clearwater-fv-test.git","ssh_url":"git@github.com:Metaswitch/clearwater-fv-test.git","clone_url":"https://github.com/Metaswitch/clearwater-fv-test.git","svn_url":"https://github.com/Metaswitch/clearwater-fv-test","homepage":null,"size":477,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Metaswitch:master","ref":"master","sha":"e910dff16f640e9a025d7c4b6bd1c56da1e7218c","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":31425304,"name":"clearwater-fv-test","full_name":"Metaswitch/clearwater-fv-test","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/clearwater-fv-test","description":"Functional verification tests for Clearwater components.","fork":false,"url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test","forks_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/forks","keys_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/teams","hooks_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/events","assignees_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/tags","blobs_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/subscription","commits_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/merges","archive_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/downloads","issues_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/releases{/id}","created_at":"2015-02-27T15:21:58Z","updated_at":"2015-05-07T12:02:08Z","pushed_at":"2015-08-12T14:09:17Z","git_url":"git://github.com/Metaswitch/clearwater-fv-test.git","ssh_url":"git@github.com:Metaswitch/clearwater-fv-test.git","clone_url":"https://github.com/Metaswitch/clearwater-fv-test.git","svn_url":"https://github.com/Metaswitch/clearwater-fv-test","homepage":null,"size":477,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21"},"html":{"href":"https://github.com/Metaswitch/clearwater-fv-test/pull/21"},"issue":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/21"},"comments":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/Metaswitch/clearwater-fv-test/statuses/3b4720c192555a17881179ee03c7f0d3a052285b"}}}}