|
@@ -17,9 +17,13 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.hdfs.nfs.nfs3;
|
|
|
|
|
|
-import static org.junit.Assert.assertArrayEquals;
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
|
+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 static org.junit.jupiter.api.Assertions.fail;
|
|
|
+import static org.mockito.Mockito.mock;
|
|
|
+import static org.mockito.Mockito.when;
|
|
|
|
|
|
import java.io.EOFException;
|
|
|
import java.io.File;
|
|
@@ -93,13 +97,11 @@ import org.apache.hadoop.oncrpc.security.SecurityHandler;
|
|
|
import org.apache.hadoop.security.IdMappingConstant;
|
|
|
import org.apache.hadoop.security.authorize.DefaultImpersonationProvider;
|
|
|
import org.apache.hadoop.security.authorize.ProxyUsers;
|
|
|
-import org.junit.AfterClass;
|
|
|
-import org.junit.Assert;
|
|
|
-import org.junit.Before;
|
|
|
-import org.junit.BeforeClass;
|
|
|
-import org.junit.Test;
|
|
|
-import org.mockito.Mockito;
|
|
|
-
|
|
|
+import org.junit.jupiter.api.AfterAll;
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
+import org.junit.jupiter.api.BeforeAll;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.jupiter.api.Timeout;
|
|
|
|
|
|
/**
|
|
|
* Tests for {@link RpcProgramNfs3}
|
|
@@ -121,7 +123,7 @@ public class TestRpcProgramNfs3 {
|
|
|
private static final EnumSet<CreateEncryptionZoneFlag> NO_TRASH =
|
|
|
EnumSet.of(CreateEncryptionZoneFlag.NO_TRASH);
|
|
|
|
|
|
- @BeforeClass
|
|
|
+ @BeforeAll
|
|
|
public static void setup() throws Exception {
|
|
|
String currentUser = System.getProperty("user.name");
|
|
|
|
|
@@ -159,22 +161,22 @@ public class TestRpcProgramNfs3 {
|
|
|
DFSTestUtil.createKey(TEST_KEY, cluster, config);
|
|
|
|
|
|
// Mock SecurityHandler which returns system user.name
|
|
|
- securityHandler = Mockito.mock(SecurityHandler.class);
|
|
|
- Mockito.when(securityHandler.getUser()).thenReturn(currentUser);
|
|
|
+ securityHandler = mock(SecurityHandler.class);
|
|
|
+ when(securityHandler.getUser()).thenReturn(currentUser);
|
|
|
|
|
|
// Mock SecurityHandler which returns a dummy username "harry"
|
|
|
- securityHandlerUnpriviledged = Mockito.mock(SecurityHandler.class);
|
|
|
- Mockito.when(securityHandlerUnpriviledged.getUser()).thenReturn("harry");
|
|
|
+ securityHandlerUnpriviledged = mock(SecurityHandler.class);
|
|
|
+ when(securityHandlerUnpriviledged.getUser()).thenReturn("harry");
|
|
|
}
|
|
|
|
|
|
- @AfterClass
|
|
|
+ @AfterAll
|
|
|
public static void shutdown() throws Exception {
|
|
|
if (cluster != null) {
|
|
|
cluster.shutdown();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Before
|
|
|
+ @BeforeEach
|
|
|
public void createFiles() throws IllegalArgumentException, IOException {
|
|
|
hdfs.delete(new Path(testdir), true);
|
|
|
hdfs.mkdirs(new Path(testdir));
|
|
@@ -182,7 +184,8 @@ public class TestRpcProgramNfs3 {
|
|
|
DFSTestUtil.createFile(hdfs, new Path(testdir + "/bar"), 0, (short) 1, 0);
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testGetattr() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -196,17 +199,18 @@ public class TestRpcProgramNfs3 {
|
|
|
GETATTR3Response response1 = nfsd.getattr(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
GETATTR3Response response2 = nfsd.getattr(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testSetattr() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -222,17 +226,18 @@ public class TestRpcProgramNfs3 {
|
|
|
SETATTR3Response response1 = nfsd.setattr(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
SETATTR3Response response2 = nfsd.setattr(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testLookup() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -246,17 +251,18 @@ public class TestRpcProgramNfs3 {
|
|
|
LOOKUP3Response response1 = nfsd.lookup(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
LOOKUP3Response response2 = nfsd.lookup(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testAccess() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -270,17 +276,18 @@ public class TestRpcProgramNfs3 {
|
|
|
ACCESS3Response response1 = nfsd.access(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
ACCESS3Response response2 = nfsd.access(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testReadlink() throws Exception {
|
|
|
// Create a symlink first.
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
@@ -294,8 +301,8 @@ public class TestRpcProgramNfs3 {
|
|
|
|
|
|
SYMLINK3Response response = nfsd.symlink(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Now perform readlink operations.
|
|
|
FileHandle handle2 = response.getObjFileHandle();
|
|
@@ -307,17 +314,18 @@ public class TestRpcProgramNfs3 {
|
|
|
READLINK3Response response1 = nfsd.readlink(xdr_req2.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
READLINK3Response response2 = nfsd.readlink(xdr_req2.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testRead() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -332,17 +340,18 @@ public class TestRpcProgramNfs3 {
|
|
|
READ3Response response1 = nfsd.read(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
READ3Response response2 = nfsd.read(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 120000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 120)
|
|
|
public void testEncryptedReadWrite() throws Exception {
|
|
|
final int len = 8192;
|
|
|
|
|
@@ -358,9 +367,9 @@ public class TestRpcProgramNfs3 {
|
|
|
final String encFile1 = "/zone/myfile";
|
|
|
createFileUsingNfs(encFile1, buffer);
|
|
|
commit(encFile1, len);
|
|
|
- assertArrayEquals("encFile1 not equal",
|
|
|
+ assertArrayEquals(
|
|
|
getFileContentsUsingNfs(encFile1, len),
|
|
|
- getFileContentsUsingDfs(encFile1, len));
|
|
|
+ getFileContentsUsingDfs(encFile1, len), "encFile1 not equal");
|
|
|
|
|
|
/*
|
|
|
* Same thing except this time create the encrypted file using DFS.
|
|
@@ -368,9 +377,9 @@ public class TestRpcProgramNfs3 {
|
|
|
final String encFile2 = "/zone/myfile2";
|
|
|
final Path encFile2Path = new Path(encFile2);
|
|
|
DFSTestUtil.createFile(hdfs, encFile2Path, len, (short) 1, 0xFEED);
|
|
|
- assertArrayEquals("encFile2 not equal",
|
|
|
+ assertArrayEquals(
|
|
|
getFileContentsUsingNfs(encFile2, len),
|
|
|
- getFileContentsUsingDfs(encFile2, len));
|
|
|
+ getFileContentsUsingDfs(encFile2, len), "encFile2 not equal");
|
|
|
}
|
|
|
|
|
|
private void createFileUsingNfs(String fileName, byte[] buffer)
|
|
@@ -390,7 +399,7 @@ public class TestRpcProgramNfs3 {
|
|
|
final WRITE3Response response = nfsd.write(xdr_req.asReadOnlyWrap(),
|
|
|
null, 1, securityHandler,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect response: ", null, response);
|
|
|
+ assertEquals(null, response, "Incorrect response: ");
|
|
|
}
|
|
|
|
|
|
private byte[] getFileContentsUsingNfs(String fileName, int len)
|
|
@@ -406,9 +415,9 @@ public class TestRpcProgramNfs3 {
|
|
|
|
|
|
final READ3Response response = nfsd.read(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code: ", Nfs3Status.NFS3_OK,
|
|
|
- response.getStatus());
|
|
|
- assertTrue("expected full read", response.isEof());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response.getStatus(), "Incorrect return code: ");
|
|
|
+ assertTrue(response.isEof(), "expected full read");
|
|
|
return response.getData().array();
|
|
|
}
|
|
|
|
|
@@ -419,7 +428,7 @@ public class TestRpcProgramNfs3 {
|
|
|
in.readFully(ret);
|
|
|
try {
|
|
|
in.readByte();
|
|
|
- Assert.fail("expected end of file");
|
|
|
+ fail("expected end of file");
|
|
|
} catch (EOFException e) {
|
|
|
// expected. Unfortunately there is no associated message to check
|
|
|
}
|
|
@@ -436,15 +445,16 @@ public class TestRpcProgramNfs3 {
|
|
|
final COMMIT3Request req = new COMMIT3Request(handle, 0, len);
|
|
|
req.serialize(xdr_req);
|
|
|
|
|
|
- Channel ch = Mockito.mock(Channel.class);
|
|
|
+ Channel ch = mock(Channel.class);
|
|
|
|
|
|
COMMIT3Response response2 = nfsd.commit(xdr_req.asReadOnlyWrap(),
|
|
|
ch, 1, securityHandler,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect COMMIT3Response:", null, response2);
|
|
|
+ assertEquals(null, response2, "Incorrect COMMIT3Response:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testWrite() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -465,17 +475,18 @@ public class TestRpcProgramNfs3 {
|
|
|
WRITE3Response response1 = nfsd.write(xdr_req.asReadOnlyWrap(),
|
|
|
null, 1, securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
WRITE3Response response2 = nfsd.write(xdr_req.asReadOnlyWrap(),
|
|
|
null, 1, securityHandler,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect response:", null, response2);
|
|
|
+ assertEquals(null, response2, "Incorrect response:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testCreate() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -490,17 +501,18 @@ public class TestRpcProgramNfs3 {
|
|
|
CREATE3Response response1 = nfsd.create(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
CREATE3Response response2 = nfsd.create(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testMkdir() throws Exception {//FixME
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -514,8 +526,8 @@ public class TestRpcProgramNfs3 {
|
|
|
MKDIR3Response response1 = nfsd.mkdir(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
XDR xdr_req2 = new XDR();
|
|
|
MKDIR3Request req2 = new MKDIR3Request(handle, "fubar2", new SetAttr3());
|
|
@@ -524,11 +536,12 @@ public class TestRpcProgramNfs3 {
|
|
|
// Attempt to mkdir by a privileged user should pass.
|
|
|
MKDIR3Response response2 = nfsd.mkdir(xdr_req2.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testSymlink() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -543,17 +556,18 @@ public class TestRpcProgramNfs3 {
|
|
|
SYMLINK3Response response1 = nfsd.symlink(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a privileged user should pass.
|
|
|
SYMLINK3Response response2 = nfsd.symlink(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testRemove() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -567,17 +581,18 @@ public class TestRpcProgramNfs3 {
|
|
|
REMOVE3Response response1 = nfsd.remove(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
REMOVE3Response response2 = nfsd.remove(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testRmdir() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -591,17 +606,18 @@ public class TestRpcProgramNfs3 {
|
|
|
RMDIR3Response response1 = nfsd.rmdir(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a privileged user should pass.
|
|
|
RMDIR3Response response2 = nfsd.rmdir(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testRename() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -615,17 +631,18 @@ public class TestRpcProgramNfs3 {
|
|
|
RENAME3Response response1 = nfsd.rename(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a privileged user should pass.
|
|
|
RENAME3Response response2 = nfsd.rename(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testReaddir() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -639,17 +656,18 @@ public class TestRpcProgramNfs3 {
|
|
|
READDIR3Response response1 = nfsd.readdir(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
READDIR3Response response2 = nfsd.readdir(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testReaddirplus() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo(testdir);
|
|
|
long dirId = status.getFileId();
|
|
@@ -663,17 +681,18 @@ public class TestRpcProgramNfs3 {
|
|
|
READDIRPLUS3Response response1 = nfsd.readdirplus(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a privileged user should pass.
|
|
|
READDIRPLUS3Response response2 = nfsd.readdirplus(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testFsstat() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -687,17 +706,18 @@ public class TestRpcProgramNfs3 {
|
|
|
FSSTAT3Response response1 = nfsd.fsstat(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
FSSTAT3Response response2 = nfsd.fsstat(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testFsinfo() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -711,17 +731,18 @@ public class TestRpcProgramNfs3 {
|
|
|
FSINFO3Response response1 = nfsd.fsinfo(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
FSINFO3Response response2 = nfsd.fsinfo(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testPathconf() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -735,17 +756,18 @@ public class TestRpcProgramNfs3 {
|
|
|
PATHCONF3Response response1 = nfsd.pathconf(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
PATHCONF3Response response2 = nfsd.pathconf(xdr_req.asReadOnlyWrap(),
|
|
|
securityHandler, new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3_OK,
|
|
|
- response2.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3_OK,
|
|
|
+ response2.getStatus(), "Incorrect return code:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout = 60000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 60)
|
|
|
public void testCommit() throws Exception {
|
|
|
HdfsFileStatus status = nn.getRpcServer().getFileInfo("/tmp/bar");
|
|
|
long dirId = status.getFileId();
|
|
@@ -755,23 +777,24 @@ public class TestRpcProgramNfs3 {
|
|
|
COMMIT3Request req = new COMMIT3Request(handle, 0, 5);
|
|
|
req.serialize(xdr_req);
|
|
|
|
|
|
- Channel ch = Mockito.mock(Channel.class);
|
|
|
+ Channel ch = mock(Channel.class);
|
|
|
|
|
|
// Attempt by an unpriviledged user should fail.
|
|
|
COMMIT3Response response1 = nfsd.commit(xdr_req.asReadOnlyWrap(),
|
|
|
ch, 1, securityHandlerUnpriviledged,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect return code:", Nfs3Status.NFS3ERR_ACCES,
|
|
|
- response1.getStatus());
|
|
|
+ assertEquals(Nfs3Status.NFS3ERR_ACCES,
|
|
|
+ response1.getStatus(), "Incorrect return code:");
|
|
|
|
|
|
// Attempt by a priviledged user should pass.
|
|
|
COMMIT3Response response2 = nfsd.commit(xdr_req.asReadOnlyWrap(),
|
|
|
ch, 1, securityHandler,
|
|
|
new InetSocketAddress("localhost", 1234));
|
|
|
- assertEquals("Incorrect COMMIT3Response:", null, response2);
|
|
|
+ assertEquals(null, response2, "Incorrect COMMIT3Response:");
|
|
|
}
|
|
|
|
|
|
- @Test(timeout=10000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 10)
|
|
|
public void testIdempotent() {
|
|
|
Object[][] procedures = {
|
|
|
{ Nfs3Constant.NFSPROC3.NULL, 1 },
|
|
@@ -800,11 +823,9 @@ public class TestRpcProgramNfs3 {
|
|
|
boolean idempotent = procedure[1].equals(Integer.valueOf(1));
|
|
|
Nfs3Constant.NFSPROC3 proc = (Nfs3Constant.NFSPROC3)procedure[0];
|
|
|
if (idempotent) {
|
|
|
- Assert.assertTrue(("Procedure " + proc + " should be idempotent"),
|
|
|
- proc.isIdempotent());
|
|
|
+ assertTrue(proc.isIdempotent(), ("Procedure " + proc + " should be idempotent"));
|
|
|
} else {
|
|
|
- Assert.assertFalse(("Procedure " + proc + " should be non-idempotent"),
|
|
|
- proc.isIdempotent());
|
|
|
+ assertFalse(proc.isIdempotent(), ("Procedure " + proc + " should be non-idempotent"));
|
|
|
}
|
|
|
}
|
|
|
}
|