{"action":"created","comment":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/85472840","pull_request_review_id":6187505,"id":85472840,"diff_hunk":"@@ -0,0 +1,177 @@\n+/*\n+ * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0\n+ * (the \"License\"). You may not use this work except in compliance with the License, which is\n+ * available at www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\n+ * either express or implied, as more fully set forth in the License.\n+ *\n+ * See the NOTICE file distributed with this work for information regarding copyright ownership.\n+ */\n+\n+package alluxio.underfs.local;\n+\n+import alluxio.Constants;\n+import alluxio.underfs.UnderFileSystem;\n+import alluxio.util.io.PathUtils;\n+import alluxio.util.network.NetworkAddressUtils;\n+\n+import org.apache.commons.lang.RandomStringUtils;\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.After;\n+import org.junit.Test;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.io.OutputStream;\n+import java.util.List;\n+\n+/**\n+ * Unit tests for the {@link LocalUnderFileSystem}.\n+ */\n+public class LocalUnderFileSystemTest {\n+  private String mLocalUfsRoot;\n+  private UnderFileSystem mLocalUfs;\n+  private final File mTestDirectory = createTestingDirectory();\n+  private static final Logger LOG = LoggerFactory.getLogger(Constants.LOGGER_TYPE);\n+\n+  @Before\n+  public void setUp() throws IOException {\n+    mLocalUfsRoot = mTestDirectory.getAbsolutePath();\n+    mLocalUfs = LocalUnderFileSystem.get(mLocalUfsRoot);\n+  }\n+\n+  @After\n+  public void tearDown() {\n+    cleanUpOldFiles(mTestDirectory);\n+  }\n+\n+  @Test\n+  public void create() throws IOException {\n+    final int size = 512;\n+    final String filepath = createFileWithRandomName(getRandomBytes(size));\n+    Assert.assertTrue(mLocalUfs.exists(filepath));\n+    Assert.assertEquals(size, mLocalUfs.getFileSize(filepath));\n+  }\n+\n+  @Test\n+  public void delete() throws IOException {\n+    String filepath = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());\n+    mLocalUfs.create(filepath);\n+    mLocalUfs.delete(filepath, true);\n+    Assert.assertFalse(mLocalUfs.exists(filepath));\n+  }\n+\n+  @Test\n+  public void recursiveDelete() throws IOException {\n+    String dirpath = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());\n+    mLocalUfs.mkdirs(dirpath, true);\n+    String filepath = PathUtils.concatPath(dirpath, getUniqueFileName());\n+    mLocalUfs.create(filepath);\n+    mLocalUfs.delete(dirpath, true);\n+    Assert.assertFalse(mLocalUfs.exists(dirpath));\n+  }\n+\n+  @Test\n+  public void mkdirs() throws IOException {\n+    String parentPath = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());\n+    String dirpath = PathUtils.concatPath(parentPath, getUniqueFileName());\n+    mLocalUfs.mkdirs(dirpath, true);\n+    Assert.assertTrue(mLocalUfs.exists(dirpath));\n+  }\n+\n+  @Test\n+  public void open() throws IOException {\n+    final int size = 512;\n+    final byte[] bytes = getRandomBytes(size);\n+    final String filepath = createFileWithRandomName(bytes);\n+    InputStream is = mLocalUfs.open(filepath);\n+    byte[] bytes1 = new byte[size];\n+    is.read(bytes1);\n+    is.close();\n+    Assert.assertArrayEquals(bytes, bytes1);\n+  }\n+\n+  @Test\n+  public void getFileLocations() throws IOException {\n+    final int size = 512;\n+    final byte[] bytes = getRandomBytes(size);\n+    final String filepath = createFileWithRandomName(bytes);\n+    List<String> fileLocations = mLocalUfs.getFileLocations(filepath);\n+    Assert.assertEquals(1, fileLocations.size());\n+    Assert.assertEquals(NetworkAddressUtils.getLocalHostName(), fileLocations.get(0));\n+  }\n+\n+  @Test\n+  public void isFile() throws IOException {\n+    final String dirpath = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());\n+    mLocalUfs.mkdirs(dirpath, true);\n+    Assert.assertFalse(mLocalUfs.isFile(dirpath));\n+\n+    final String filepath = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());\n+    mLocalUfs.create(filepath);\n+    Assert.assertTrue(mLocalUfs.isFile(filepath));\n+  }\n+\n+  @Test\n+  public void rename() throws IOException {\n+    final int size = 512;\n+    final byte[] bytes = getRandomBytes(size);\n+    final String filepath1 = createFileWithRandomName(bytes);\n+    final String filepath2 = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());\n+    mLocalUfs.rename(filepath1, filepath2);\n+    InputStream is = mLocalUfs.open(filepath2);\n+    byte[] bytes1 = new byte[size];\n+    is.read(bytes1);\n+    is.close();\n+    Assert.assertArrayEquals(bytes, bytes1);\n+  }\n+\n+  private byte[] getRandomBytes(final int size) {\n+    String s = RandomStringUtils.randomAlphanumeric(size);\n+    return s.getBytes();\n+  }\n+\n+  private String createFileWithRandomName(final byte[] bytes) throws IOException {\n+    final String filepath = PathUtils.concatPath(mLocalUfsRoot, getUniqueFileName());\n+    OutputStream os = mLocalUfs.create(filepath);\n+    os.write(bytes);\n+    os.close();\n+    return filepath;\n+  }\n+\n+  private String getUniqueFileName() {\n+    long time = System.nanoTime();\n+    String fileName = \"\" + time;\n+    return fileName;\n+  }\n+\n+  private File createTestingDirectory() {\n+    final File tmpDir = new File(System.getProperty(\"java.io.tmpdir\"), \"alluxio-tests\");\n+    if (tmpDir.exists()) {\n+      cleanUpOldFiles(tmpDir);\n+    }\n+    if (!tmpDir.exists()) {\n+      if (!tmpDir.mkdir()) {\n+        throw new RuntimeException(\n+                \"Failed to create testing directory \" + tmpDir.getAbsolutePath());\n+      }\n+    }\n+    return tmpDir;\n+  }\n+\n+  private void cleanUpOldFiles(File dir) {\n+    File[] files = dir.listFiles();\n+    for (File file : files) {\n+      try {\n+        alluxio.util.io.FileUtils.deletePathRecursively(file.getAbsolutePath());","path":"underfs/local/src/test/java/alluxio/underfs/local/LocalUnderFileSystemTest.java","position":171,"original_position":171,"commit_id":"6a96b490fa7c5b6137db36ed988e0e0b6ae085dd","original_commit_id":"6a96b490fa7c5b6137db36ed988e0e0b6ae085dd","user":{"login":"milton0825","id":6065051,"avatar_url":"https://avatars.githubusercontent.com/u/6065051?v=3","gravatar_id":"","url":"https://api.github.com/users/milton0825","html_url":"https://github.com/milton0825","followers_url":"https://api.github.com/users/milton0825/followers","following_url":"https://api.github.com/users/milton0825/following{/other_user}","gists_url":"https://api.github.com/users/milton0825/gists{/gist_id}","starred_url":"https://api.github.com/users/milton0825/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milton0825/subscriptions","organizations_url":"https://api.github.com/users/milton0825/orgs","repos_url":"https://api.github.com/users/milton0825/repos","events_url":"https://api.github.com/users/milton0825/events{/privacy}","received_events_url":"https://api.github.com/users/milton0825/received_events","type":"User","site_admin":false},"body":"Removed this method.","created_at":"2016-10-28T05:12:00Z","updated_at":"2016-10-28T05:12:00Z","html_url":"https://github.com/Alluxio/alluxio/pull/4253#discussion_r85472840","pull_request_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253","_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments/85472840"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/4253#discussion_r85472840"},"pull_request":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253"}}},"pull_request":{"url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253","id":90938475,"html_url":"https://github.com/Alluxio/alluxio/pull/4253","diff_url":"https://github.com/Alluxio/alluxio/pull/4253.diff","patch_url":"https://github.com/Alluxio/alluxio/pull/4253.patch","issue_url":"https://api.github.com/repos/Alluxio/alluxio/issues/4253","number":4253,"state":"open","locked":false,"title":"[ALLUXIO-1593] Add unit test coverage for LocalUnderFileSystem","user":{"login":"milton0825","id":6065051,"avatar_url":"https://avatars.githubusercontent.com/u/6065051?v=3","gravatar_id":"","url":"https://api.github.com/users/milton0825","html_url":"https://github.com/milton0825","followers_url":"https://api.github.com/users/milton0825/followers","following_url":"https://api.github.com/users/milton0825/following{/other_user}","gists_url":"https://api.github.com/users/milton0825/gists{/gist_id}","starred_url":"https://api.github.com/users/milton0825/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milton0825/subscriptions","organizations_url":"https://api.github.com/users/milton0825/orgs","repos_url":"https://api.github.com/users/milton0825/repos","events_url":"https://api.github.com/users/milton0825/events{/privacy}","received_events_url":"https://api.github.com/users/milton0825/received_events","type":"User","site_admin":false},"body":"Currently this class is only covered by integration tests, unit tests are needed.\r\n\r\nJira: https://alluxio.atlassian.net/browse/ALLUXIO-1593","created_at":"2016-10-26T05:23:59Z","updated_at":"2016-10-28T05:12:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e149c18116774ae76c5cbc04e9506f5df8ef3791","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253/commits","review_comments_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253/comments","review_comment_url":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/issues/4253/comments","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/6a96b490fa7c5b6137db36ed988e0e0b6ae085dd","head":{"label":"milton0825:ALLUXIO-2160","ref":"ALLUXIO-2160","sha":"6a96b490fa7c5b6137db36ed988e0e0b6ae085dd","user":{"login":"milton0825","id":6065051,"avatar_url":"https://avatars.githubusercontent.com/u/6065051?v=3","gravatar_id":"","url":"https://api.github.com/users/milton0825","html_url":"https://github.com/milton0825","followers_url":"https://api.github.com/users/milton0825/followers","following_url":"https://api.github.com/users/milton0825/following{/other_user}","gists_url":"https://api.github.com/users/milton0825/gists{/gist_id}","starred_url":"https://api.github.com/users/milton0825/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milton0825/subscriptions","organizations_url":"https://api.github.com/users/milton0825/orgs","repos_url":"https://api.github.com/users/milton0825/repos","events_url":"https://api.github.com/users/milton0825/events{/privacy}","received_events_url":"https://api.github.com/users/milton0825/received_events","type":"User","site_admin":false},"repo":{"id":66688800,"name":"alluxio","full_name":"milton0825/alluxio","owner":{"login":"milton0825","id":6065051,"avatar_url":"https://avatars.githubusercontent.com/u/6065051?v=3","gravatar_id":"","url":"https://api.github.com/users/milton0825","html_url":"https://github.com/milton0825","followers_url":"https://api.github.com/users/milton0825/followers","following_url":"https://api.github.com/users/milton0825/following{/other_user}","gists_url":"https://api.github.com/users/milton0825/gists{/gist_id}","starred_url":"https://api.github.com/users/milton0825/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/milton0825/subscriptions","organizations_url":"https://api.github.com/users/milton0825/orgs","repos_url":"https://api.github.com/users/milton0825/repos","events_url":"https://api.github.com/users/milton0825/events{/privacy}","received_events_url":"https://api.github.com/users/milton0825/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/milton0825/alluxio","description":"Alluxio, formerly Tachyon, Memory Speed Virtual Distributed Storage System","fork":true,"url":"https://api.github.com/repos/milton0825/alluxio","forks_url":"https://api.github.com/repos/milton0825/alluxio/forks","keys_url":"https://api.github.com/repos/milton0825/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/milton0825/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/milton0825/alluxio/teams","hooks_url":"https://api.github.com/repos/milton0825/alluxio/hooks","issue_events_url":"https://api.github.com/repos/milton0825/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/milton0825/alluxio/events","assignees_url":"https://api.github.com/repos/milton0825/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/milton0825/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/milton0825/alluxio/tags","blobs_url":"https://api.github.com/repos/milton0825/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/milton0825/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/milton0825/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/milton0825/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/milton0825/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/milton0825/alluxio/languages","stargazers_url":"https://api.github.com/repos/milton0825/alluxio/stargazers","contributors_url":"https://api.github.com/repos/milton0825/alluxio/contributors","subscribers_url":"https://api.github.com/repos/milton0825/alluxio/subscribers","subscription_url":"https://api.github.com/repos/milton0825/alluxio/subscription","commits_url":"https://api.github.com/repos/milton0825/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/milton0825/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/milton0825/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/milton0825/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/milton0825/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/milton0825/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/milton0825/alluxio/merges","archive_url":"https://api.github.com/repos/milton0825/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/milton0825/alluxio/downloads","issues_url":"https://api.github.com/repos/milton0825/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/milton0825/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/milton0825/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/milton0825/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/milton0825/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/milton0825/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/milton0825/alluxio/deployments","created_at":"2016-08-27T01:18:07Z","updated_at":"2016-08-27T01:18:12Z","pushed_at":"2016-10-26T05:22:22Z","git_url":"git://github.com/milton0825/alluxio.git","ssh_url":"git@github.com:milton0825/alluxio.git","clone_url":"https://github.com/milton0825/alluxio.git","svn_url":"https://github.com/milton0825/alluxio","homepage":"http://www.alluxio.org/","size":59407,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Alluxio:master","ref":"master","sha":"d427d9948cf026fa1ee5630147f40922151fbe37","user":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"repo":{"id":7276954,"name":"alluxio","full_name":"Alluxio/alluxio","owner":{"login":"Alluxio","id":16203694,"avatar_url":"https://avatars.githubusercontent.com/u/16203694?v=3","gravatar_id":"","url":"https://api.github.com/users/Alluxio","html_url":"https://github.com/Alluxio","followers_url":"https://api.github.com/users/Alluxio/followers","following_url":"https://api.github.com/users/Alluxio/following{/other_user}","gists_url":"https://api.github.com/users/Alluxio/gists{/gist_id}","starred_url":"https://api.github.com/users/Alluxio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alluxio/subscriptions","organizations_url":"https://api.github.com/users/Alluxio/orgs","repos_url":"https://api.github.com/users/Alluxio/repos","events_url":"https://api.github.com/users/Alluxio/events{/privacy}","received_events_url":"https://api.github.com/users/Alluxio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Alluxio/alluxio","description":"Alluxio, formerly Tachyon, Memory Speed Virtual Distributed Storage System","fork":false,"url":"https://api.github.com/repos/Alluxio/alluxio","forks_url":"https://api.github.com/repos/Alluxio/alluxio/forks","keys_url":"https://api.github.com/repos/Alluxio/alluxio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Alluxio/alluxio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Alluxio/alluxio/teams","hooks_url":"https://api.github.com/repos/Alluxio/alluxio/hooks","issue_events_url":"https://api.github.com/repos/Alluxio/alluxio/issues/events{/number}","events_url":"https://api.github.com/repos/Alluxio/alluxio/events","assignees_url":"https://api.github.com/repos/Alluxio/alluxio/assignees{/user}","branches_url":"https://api.github.com/repos/Alluxio/alluxio/branches{/branch}","tags_url":"https://api.github.com/repos/Alluxio/alluxio/tags","blobs_url":"https://api.github.com/repos/Alluxio/alluxio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Alluxio/alluxio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Alluxio/alluxio/git/refs{/sha}","trees_url":"https://api.github.com/repos/Alluxio/alluxio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Alluxio/alluxio/statuses/{sha}","languages_url":"https://api.github.com/repos/Alluxio/alluxio/languages","stargazers_url":"https://api.github.com/repos/Alluxio/alluxio/stargazers","contributors_url":"https://api.github.com/repos/Alluxio/alluxio/contributors","subscribers_url":"https://api.github.com/repos/Alluxio/alluxio/subscribers","subscription_url":"https://api.github.com/repos/Alluxio/alluxio/subscription","commits_url":"https://api.github.com/repos/Alluxio/alluxio/commits{/sha}","git_commits_url":"https://api.github.com/repos/Alluxio/alluxio/git/commits{/sha}","comments_url":"https://api.github.com/repos/Alluxio/alluxio/comments{/number}","issue_comment_url":"https://api.github.com/repos/Alluxio/alluxio/issues/comments{/number}","contents_url":"https://api.github.com/repos/Alluxio/alluxio/contents/{+path}","compare_url":"https://api.github.com/repos/Alluxio/alluxio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Alluxio/alluxio/merges","archive_url":"https://api.github.com/repos/Alluxio/alluxio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Alluxio/alluxio/downloads","issues_url":"https://api.github.com/repos/Alluxio/alluxio/issues{/number}","pulls_url":"https://api.github.com/repos/Alluxio/alluxio/pulls{/number}","milestones_url":"https://api.github.com/repos/Alluxio/alluxio/milestones{/number}","notifications_url":"https://api.github.com/repos/Alluxio/alluxio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Alluxio/alluxio/labels{/name}","releases_url":"https://api.github.com/repos/Alluxio/alluxio/releases{/id}","deployments_url":"https://api.github.com/repos/Alluxio/alluxio/deployments","created_at":"2012-12-21T17:43:46Z","updated_at":"2016-10-28T02:26:19Z","pushed_at":"2016-10-28T03:43:20Z","git_url":"git://github.com/Alluxio/alluxio.git","ssh_url":"git@github.com:Alluxio/alluxio.git","clone_url":"https://github.com/Alluxio/alluxio.git","svn_url":"https://github.com/Alluxio/alluxio","homepage":"http://www.alluxio.org/","size":98967,"stargazers_count":2695,"watchers_count":2695,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1218,"mirror_url":null,"open_issues_count":28,"forks":1218,"open_issues":28,"watchers":2695,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253"},"html":{"href":"https://github.com/Alluxio/alluxio/pull/4253"},"issue":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/4253"},"comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/issues/4253/comments"},"review_comments":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253/comments"},"review_comment":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Alluxio/alluxio/pulls/4253/commits"},"statuses":{"href":"https://api.github.com/repos/Alluxio/alluxio/statuses/6a96b490fa7c5b6137db36ed988e0e0b6ae085dd"}}}}
{"actor":{"display_login":"milton0825"}}