{"action":"created","comment":{"url":"https://api.github.com/repos/scality/S3/pulls/comments/88130210","pull_request_review_id":8713146,"id":88130210,"diff_hunk":"@@ -0,0 +1,254 @@\n+import assert from 'assert';\n+import async from 'async';\n+import { exec, execFile } from 'child_process';\n+import fs from 'fs';\n+\n+import withV4 from '../support/withV4';\n+import BucketUtility from '../../lib/utility/bucket-util';\n+\n+const bucket = 'bucket-for-range-test';\n+const key = 'key-for-range-test';\n+let s3;\n+\n+// Calculate the total number of bytes for range end values\n+const getTotal = (begin, end) =>\n+    Number.parseInt(end, 10) - Number.parseInt(begin, 10) + 1;\n+\n+// Get the expected end values for various ranges (e.g., '-10', '10-', '-')\n+const getOuterRange = (range, fileSize) => {\n+    const arr = range.split('-');\n+    if (arr[0] === '' && arr[1] !== '') {\n+        arr[0] = Number.parseInt(fileSize, 10) - Number.parseInt(arr[1], 10);\n+        arr[1] = Number.parseInt(fileSize, 10) - 1;\n+    } else {\n+        arr[0] = arr[0] === '' ? '0' : arr[0]; // For invalid ranges\n+        arr[1] = arr[1] === '' || Number.parseInt(arr[1], 10) >= fileSize ?\n+            Number.parseInt(fileSize, 10) - 1 : arr[1];\n+    }\n+    return {\n+        begin: arr[0],\n+        end: arr[1],\n+    };\n+};\n+\n+// Compare the S3 object from getObject with the corresponding hashed range file\n+const checkRanges = (range, fileSize, cb) => {\n+    s3.getObjectAsync({\n+        Bucket: bucket,\n+        Key: key,\n+        Range: `bytes=${range}`,\n+    })\n+    .then(res => fs.readFile(`hashedFile.${fileSize}.${range}`, (err, data) => {\n+        if (err) {\n+            return cb(err);\n+        }\n+        const { begin, end } = getOuterRange(range, fileSize);\n+        const contentLength = getTotal(begin, end).toString();\n+        // If the range header is invalid, content range should be `undefined`\n+        const contentRange = range === '-' ? undefined :","path":"tests/functional/aws-node-sdk/test/object/rangeTest.js","position":48,"original_position":48,"commit_id":"b2e7fc1aa67d1da5055f067f796b0491b3e75e23","original_commit_id":"d687b76e9e2349c22c7f20b5cca4a009b38efc9e","user":{"login":"bennettbuchanan","id":15207067,"avatar_url":"https://avatars.githubusercontent.com/u/15207067?v=3","gravatar_id":"","url":"https://api.github.com/users/bennettbuchanan","html_url":"https://github.com/bennettbuchanan","followers_url":"https://api.github.com/users/bennettbuchanan/followers","following_url":"https://api.github.com/users/bennettbuchanan/following{/other_user}","gists_url":"https://api.github.com/users/bennettbuchanan/gists{/gist_id}","starred_url":"https://api.github.com/users/bennettbuchanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennettbuchanan/subscriptions","organizations_url":"https://api.github.com/users/bennettbuchanan/orgs","repos_url":"https://api.github.com/users/bennettbuchanan/repos","events_url":"https://api.github.com/users/bennettbuchanan/events{/privacy}","received_events_url":"https://api.github.com/users/bennettbuchanan/received_events","type":"User","site_admin":false},"body":"This range '-' is meant to test for an invalid range [here](https://github.com/scality/S3/pull/389/files#diff-496eac81ba5250d3fbf22abf5c48596cR207). It is the range being used for that case in legacy tests [here](https://github.com/scality/S3/blob/master/tests/functional/aws-node-sdk/test/legacy/tests.js#L421).","created_at":"2016-11-15T22:37:09Z","updated_at":"2016-11-15T22:37:09Z","html_url":"https://github.com/scality/S3/pull/389#discussion_r88130210","pull_request_url":"https://api.github.com/repos/scality/S3/pulls/389","_links":{"self":{"href":"https://api.github.com/repos/scality/S3/pulls/comments/88130210"},"html":{"href":"https://github.com/scality/S3/pull/389#discussion_r88130210"},"pull_request":{"href":"https://api.github.com/repos/scality/S3/pulls/389"}}},"pull_request":{"url":"https://api.github.com/repos/scality/S3/pulls/389","id":93422683,"html_url":"https://github.com/scality/S3/pull/389","diff_url":"https://github.com/scality/S3/pull/389.diff","patch_url":"https://github.com/scality/S3/pull/389.patch","issue_url":"https://api.github.com/repos/scality/S3/issues/389","number":389,"state":"open","locked":false,"title":"TEST: Refactor range tests to use getRange.c","user":{"login":"bennettbuchanan","id":15207067,"avatar_url":"https://avatars.githubusercontent.com/u/15207067?v=3","gravatar_id":"","url":"https://api.github.com/users/bennettbuchanan","html_url":"https://github.com/bennettbuchanan","followers_url":"https://api.github.com/users/bennettbuchanan/followers","following_url":"https://api.github.com/users/bennettbuchanan/following{/other_user}","gists_url":"https://api.github.com/users/bennettbuchanan/gists{/gist_id}","starred_url":"https://api.github.com/users/bennettbuchanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennettbuchanan/subscriptions","organizations_url":"https://api.github.com/users/bennettbuchanan/orgs","repos_url":"https://api.github.com/users/bennettbuchanan/repos","events_url":"https://api.github.com/users/bennettbuchanan/events{/privacy}","received_events_url":"https://api.github.com/users/bennettbuchanan/received_events","type":"User","site_admin":false},"body":"This PR refactors range tests by using files created with the executable file of getRange.c where each byte of the file is a hash of its offset. The C code is written by Flavien Lebarbe. The general approach for each test: \r\n1. Generate a hashed file of a certain number of bytes with the executable and put that file in a bucket. \r\n2. Create another file with a specified byte range using the `dd` Unix command-line utility, based on the file created in step 1.\r\n3. Use the getObject API to retrieve the same byte range from the bucket and compare the returned buffer with the file created in step 2.\r\n4. Success!","created_at":"2016-11-12T01:33:33Z","updated_at":"2016-11-15T22:37:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6ae7206657ca9fa982f77af23eadb574cde226d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scality/S3/pulls/389/commits","review_comments_url":"https://api.github.com/repos/scality/S3/pulls/389/comments","review_comment_url":"https://api.github.com/repos/scality/S3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scality/S3/issues/389/comments","statuses_url":"https://api.github.com/repos/scality/S3/statuses/b2e7fc1aa67d1da5055f067f796b0491b3e75e23","head":{"label":"scality:dev/CLEANUP/refactor_range_tests","ref":"dev/CLEANUP/refactor_range_tests","sha":"b2e7fc1aa67d1da5055f067f796b0491b3e75e23","user":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"repo":{"id":60165924,"name":"S3","full_name":"scality/S3","owner":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scality/S3","description":"An open-source Node.js implementation of a server handling the S3 protocol","fork":false,"url":"https://api.github.com/repos/scality/S3","forks_url":"https://api.github.com/repos/scality/S3/forks","keys_url":"https://api.github.com/repos/scality/S3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scality/S3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scality/S3/teams","hooks_url":"https://api.github.com/repos/scality/S3/hooks","issue_events_url":"https://api.github.com/repos/scality/S3/issues/events{/number}","events_url":"https://api.github.com/repos/scality/S3/events","assignees_url":"https://api.github.com/repos/scality/S3/assignees{/user}","branches_url":"https://api.github.com/repos/scality/S3/branches{/branch}","tags_url":"https://api.github.com/repos/scality/S3/tags","blobs_url":"https://api.github.com/repos/scality/S3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scality/S3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scality/S3/git/refs{/sha}","trees_url":"https://api.github.com/repos/scality/S3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scality/S3/statuses/{sha}","languages_url":"https://api.github.com/repos/scality/S3/languages","stargazers_url":"https://api.github.com/repos/scality/S3/stargazers","contributors_url":"https://api.github.com/repos/scality/S3/contributors","subscribers_url":"https://api.github.com/repos/scality/S3/subscribers","subscription_url":"https://api.github.com/repos/scality/S3/subscription","commits_url":"https://api.github.com/repos/scality/S3/commits{/sha}","git_commits_url":"https://api.github.com/repos/scality/S3/git/commits{/sha}","comments_url":"https://api.github.com/repos/scality/S3/comments{/number}","issue_comment_url":"https://api.github.com/repos/scality/S3/issues/comments{/number}","contents_url":"https://api.github.com/repos/scality/S3/contents/{+path}","compare_url":"https://api.github.com/repos/scality/S3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scality/S3/merges","archive_url":"https://api.github.com/repos/scality/S3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scality/S3/downloads","issues_url":"https://api.github.com/repos/scality/S3/issues{/number}","pulls_url":"https://api.github.com/repos/scality/S3/pulls{/number}","milestones_url":"https://api.github.com/repos/scality/S3/milestones{/number}","notifications_url":"https://api.github.com/repos/scality/S3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scality/S3/labels{/name}","releases_url":"https://api.github.com/repos/scality/S3/releases{/id}","deployments_url":"https://api.github.com/repos/scality/S3/deployments","created_at":"2016-06-01T09:58:56Z","updated_at":"2016-11-14T09:01:27Z","pushed_at":"2016-11-15T22:28:38Z","git_url":"git://github.com/scality/S3.git","ssh_url":"git@github.com:scality/S3.git","clone_url":"https://github.com/scality/S3.git","svn_url":"https://github.com/scality/S3","homepage":"http://s3.scality.com","size":3920,"stargazers_count":254,"watchers_count":254,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":45,"forks":34,"open_issues":45,"watchers":254,"default_branch":"master"}},"base":{"label":"scality:master","ref":"master","sha":"50f93164e17b7af32494d2f28a9ca20e228caea1","user":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"repo":{"id":60165924,"name":"S3","full_name":"scality/S3","owner":{"login":"scality","id":383812,"avatar_url":"https://avatars.githubusercontent.com/u/383812?v=3","gravatar_id":"","url":"https://api.github.com/users/scality","html_url":"https://github.com/scality","followers_url":"https://api.github.com/users/scality/followers","following_url":"https://api.github.com/users/scality/following{/other_user}","gists_url":"https://api.github.com/users/scality/gists{/gist_id}","starred_url":"https://api.github.com/users/scality/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scality/subscriptions","organizations_url":"https://api.github.com/users/scality/orgs","repos_url":"https://api.github.com/users/scality/repos","events_url":"https://api.github.com/users/scality/events{/privacy}","received_events_url":"https://api.github.com/users/scality/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scality/S3","description":"An open-source Node.js implementation of a server handling the S3 protocol","fork":false,"url":"https://api.github.com/repos/scality/S3","forks_url":"https://api.github.com/repos/scality/S3/forks","keys_url":"https://api.github.com/repos/scality/S3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scality/S3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scality/S3/teams","hooks_url":"https://api.github.com/repos/scality/S3/hooks","issue_events_url":"https://api.github.com/repos/scality/S3/issues/events{/number}","events_url":"https://api.github.com/repos/scality/S3/events","assignees_url":"https://api.github.com/repos/scality/S3/assignees{/user}","branches_url":"https://api.github.com/repos/scality/S3/branches{/branch}","tags_url":"https://api.github.com/repos/scality/S3/tags","blobs_url":"https://api.github.com/repos/scality/S3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scality/S3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scality/S3/git/refs{/sha}","trees_url":"https://api.github.com/repos/scality/S3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scality/S3/statuses/{sha}","languages_url":"https://api.github.com/repos/scality/S3/languages","stargazers_url":"https://api.github.com/repos/scality/S3/stargazers","contributors_url":"https://api.github.com/repos/scality/S3/contributors","subscribers_url":"https://api.github.com/repos/scality/S3/subscribers","subscription_url":"https://api.github.com/repos/scality/S3/subscription","commits_url":"https://api.github.com/repos/scality/S3/commits{/sha}","git_commits_url":"https://api.github.com/repos/scality/S3/git/commits{/sha}","comments_url":"https://api.github.com/repos/scality/S3/comments{/number}","issue_comment_url":"https://api.github.com/repos/scality/S3/issues/comments{/number}","contents_url":"https://api.github.com/repos/scality/S3/contents/{+path}","compare_url":"https://api.github.com/repos/scality/S3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scality/S3/merges","archive_url":"https://api.github.com/repos/scality/S3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scality/S3/downloads","issues_url":"https://api.github.com/repos/scality/S3/issues{/number}","pulls_url":"https://api.github.com/repos/scality/S3/pulls{/number}","milestones_url":"https://api.github.com/repos/scality/S3/milestones{/number}","notifications_url":"https://api.github.com/repos/scality/S3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scality/S3/labels{/name}","releases_url":"https://api.github.com/repos/scality/S3/releases{/id}","deployments_url":"https://api.github.com/repos/scality/S3/deployments","created_at":"2016-06-01T09:58:56Z","updated_at":"2016-11-14T09:01:27Z","pushed_at":"2016-11-15T22:28:38Z","git_url":"git://github.com/scality/S3.git","ssh_url":"git@github.com:scality/S3.git","clone_url":"https://github.com/scality/S3.git","svn_url":"https://github.com/scality/S3","homepage":"http://s3.scality.com","size":3920,"stargazers_count":254,"watchers_count":254,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":45,"forks":34,"open_issues":45,"watchers":254,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scality/S3/pulls/389"},"html":{"href":"https://github.com/scality/S3/pull/389"},"issue":{"href":"https://api.github.com/repos/scality/S3/issues/389"},"comments":{"href":"https://api.github.com/repos/scality/S3/issues/389/comments"},"review_comments":{"href":"https://api.github.com/repos/scality/S3/pulls/389/comments"},"review_comment":{"href":"https://api.github.com/repos/scality/S3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scality/S3/pulls/389/commits"},"statuses":{"href":"https://api.github.com/repos/scality/S3/statuses/b2e7fc1aa67d1da5055f067f796b0491b3e75e23"}}}}
{"actor":{"display_login":"bennettbuchanan"}}