Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.security.UserGroupInformation;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;

public class TestFcHdfsCreateMkdir extends
FileContextCreateMkdirBaseTest {
Expand All @@ -44,7 +44,7 @@ protected FileContextTestHelper createFileContextHelper() {
}


@BeforeClass
@BeforeAll
public static void clusterSetupAtBegining()
throws IOException, LoginException, URISyntaxException {
Configuration conf = new HdfsConfiguration();
Expand All @@ -56,21 +56,21 @@ public static void clusterSetupAtBegining()
}


@AfterClass
@AfterAll
public static void ClusterShutdownAtEnd() throws Exception {
if (cluster != null) {
cluster.shutdown();
}
}

@Override
@Before
@BeforeEach
public void setUp() throws Exception {
super.setUp();
}

@Override
@After
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.security.UserGroupInformation;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;

public class TestFcHdfsPermission extends FileContextPermissionBase {

Expand All @@ -51,7 +51,7 @@ protected FileContext getFileContext() {
return fc;
}

@BeforeClass
@BeforeAll
public static void clusterSetupAtBegining()
throws IOException, LoginException, URISyntaxException {
Configuration conf = new HdfsConfiguration();
Expand All @@ -63,21 +63,21 @@ public static void clusterSetupAtBegining()
}


@AfterClass
@AfterAll
public static void ClusterShutdownAtEnd() throws Exception {
if (cluster != null) {
cluster.shutdown();
}
}

@Override
@Before
@BeforeEach
public void setUp() throws Exception {
super.setUp();
}

@Override
@After
@AfterEach
public void tearDown() throws Exception {
super.tearDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.security.UserGroupInformation;
import static org.apache.hadoop.fs.FileContextTestHelper.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class TestFcHdfsSetUMask {

Expand Down Expand Up @@ -78,7 +81,7 @@ public class TestFcHdfsSetUMask {
private static final FsPermission WIDE_OPEN_TEST_UMASK = FsPermission
.createImmutable((short) (0777 ^ 0777));

@BeforeClass
@BeforeAll
public static void clusterSetupAtBegining()
throws IOException, LoginException, URISyntaxException {
Configuration conf = new HdfsConfiguration();
Expand All @@ -91,20 +94,20 @@ public static void clusterSetupAtBegining()
fc.mkdir(defaultWorkingDirectory, FileContext.DEFAULT_PERM, true);
}

@AfterClass
@AfterAll
public static void ClusterShutdownAtEnd() throws Exception {
if (cluster != null) {
cluster.shutdown();
}
}

@Before
@BeforeEach
public void setUp() throws Exception {
fc.setUMask(WIDE_OPEN_TEST_UMASK);
fc.mkdir(fileContextTestHelper.getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
}

@After
@AfterEach
public void tearDown() throws Exception {
fc.delete(fileContextTestHelper.getTestRootPath(fc), true);
}
Expand Down Expand Up @@ -165,23 +168,23 @@ public void testCreateRecursiveWithExistingDirMiddle() throws IOException {

@Test
public void testCreateRecursiveWithNonExistingDirClear() throws IOException {
// directory permission inherited from parent so this must match the @Before
// directory permission inherited from parent so this must match the @BeforeEach
// set of umask
testCreateRecursiveWithNonExistingDir(BLANK_TEST_UMASK,
WIDE_OPEN_PERMISSIONS, BLANK_PERMISSIONS);
}

@Test
public void testCreateRecursiveWithNonExistingDirOpen() throws IOException {
// directory permission inherited from parent so this must match the @Before
// directory permission inherited from parent so this must match the @BeforeEach
// set of umask
testCreateRecursiveWithNonExistingDir(WIDE_OPEN_TEST_UMASK,
WIDE_OPEN_PERMISSIONS, WIDE_OPEN_FILE_PERMISSIONS);
}

@Test
public void testCreateRecursiveWithNonExistingDirMiddle() throws IOException {
// directory permission inherited from parent so this must match the @Before
// directory permission inherited from parent so this must match the @BeforeEach
// set of umask
testCreateRecursiveWithNonExistingDir(USER_GROUP_OPEN_TEST_UMASK,
WIDE_OPEN_PERMISSIONS, USER_GROUP_OPEN_FILE_PERMISSIONS);
Expand All @@ -193,9 +196,9 @@ public void testMkdirWithExistingDir(FsPermission umask,
Path f = fileContextTestHelper.getTestRootPath(fc, "aDir");
fc.setUMask(umask);
fc.mkdir(f, FileContext.DEFAULT_PERM, true);
Assert.assertTrue(isDir(fc, f));
Assert.assertEquals("permissions on directory are wrong",
expectedPerms, fc.getFileStatus(f).getPermission());
assertTrue(isDir(fc, f));
assertEquals(expectedPerms, fc.getFileStatus(f).getPermission(),
"permissions on directory are wrong");
}

public void testMkdirRecursiveWithNonExistingDir(FsPermission umask,
Expand All @@ -204,12 +207,12 @@ public void testMkdirRecursiveWithNonExistingDir(FsPermission umask,
Path f = fileContextTestHelper.getTestRootPath(fc, "NonExistant2/aDir");
fc.setUMask(umask);
fc.mkdir(f, FileContext.DEFAULT_PERM, true);
Assert.assertTrue(isDir(fc, f));
Assert.assertEquals("permissions on directory are wrong",
expectedPerms, fc.getFileStatus(f).getPermission());
assertTrue(isDir(fc, f));
assertEquals(expectedPerms, fc.getFileStatus(f).getPermission(),
"permissions on directory are wrong");
Path fParent = fileContextTestHelper.getTestRootPath(fc, "NonExistant2");
Assert.assertEquals("permissions on parent directory are wrong",
expectedParentPerms, fc.getFileStatus(fParent).getPermission());
assertEquals(expectedParentPerms, fc.getFileStatus(fParent).getPermission(),
"permissions on parent directory are wrong");
}


Expand All @@ -218,9 +221,9 @@ public void testCreateRecursiveWithExistingDir(FsPermission umask,
Path f = fileContextTestHelper.getTestRootPath(fc,"foo");
fc.setUMask(umask);
createFile(fc, f);
Assert.assertTrue(isFile(fc, f));
Assert.assertEquals("permissions on file are wrong",
expectedPerms , fc.getFileStatus(f).getPermission());
assertTrue(isFile(fc, f));
assertEquals(expectedPerms, fc.getFileStatus(f).getPermission(),
"permissions on file are wrong");
}


Expand All @@ -229,14 +232,14 @@ public void testCreateRecursiveWithNonExistingDir(FsPermission umask,
throws IOException {
Path f = fileContextTestHelper.getTestRootPath(fc,"NonExisting/foo");
Path fParent = fileContextTestHelper.getTestRootPath(fc, "NonExisting");
Assert.assertFalse(exists(fc, fParent));
assertFalse(exists(fc, fParent));
fc.setUMask(umask);
createFile(fc, f);
Assert.assertTrue(isFile(fc, f));
Assert.assertEquals("permissions on file are wrong",
expectedFilePerms, fc.getFileStatus(f).getPermission());
Assert.assertEquals("permissions on parent directory are wrong",
expectedDirPerms, fc.getFileStatus(fParent).getPermission());
assertTrue(isFile(fc, f));
assertEquals(expectedFilePerms, fc.getFileStatus(f).getPermission(),
"permissions on file are wrong");
assertEquals(expectedDirPerms, fc.getFileStatus(fParent).getPermission(),
"permissions on parent directory are wrong");
}

}
Loading