Search in sources :

Example 1 with Statvfs

use of alluxio.jnifuse.struct.Statvfs in project alluxio by Alluxio.

the class AlluxioJniFuseFileSystemTest method statfs.

@Test
public void statfs() throws Exception {
    ByteBuffer buffer = ByteBuffer.allocateDirect(4 * Constants.KB);
    buffer.clear();
    Statvfs stbuf = Statvfs.of(buffer);
    int blockSize = 4 * Constants.KB;
    int totalBlocks = 4;
    int freeBlocks = 3;
    BlockMasterClient blockMasterClient = PowerMockito.mock(BlockMasterClient.class);
    PowerMockito.mockStatic(BlockMasterClient.Factory.class);
    when(BlockMasterClient.Factory.create(any())).thenReturn(blockMasterClient);
    BlockMasterInfo blockMasterInfo = new BlockMasterInfo();
    blockMasterInfo.setCapacityBytes(totalBlocks * blockSize);
    blockMasterInfo.setFreeBytes(freeBlocks * blockSize);
    when(blockMasterClient.getBlockMasterInfo(any())).thenReturn(blockMasterInfo);
    assertEquals(0, mFuseFs.statfs("/", stbuf));
    assertEquals(blockSize, stbuf.f_bsize.intValue());
    assertEquals(blockSize, stbuf.f_frsize.intValue());
    assertEquals(totalBlocks, stbuf.f_blocks.longValue());
    assertEquals(freeBlocks, stbuf.f_bfree.longValue());
    assertEquals(freeBlocks, stbuf.f_bavail.longValue());
    assertEquals(AlluxioJniFuseFileSystem.UNKNOWN_INODES, stbuf.f_files.intValue());
    assertEquals(AlluxioJniFuseFileSystem.UNKNOWN_INODES, stbuf.f_ffree.intValue());
    assertEquals(AlluxioJniFuseFileSystem.UNKNOWN_INODES, stbuf.f_favail.intValue());
    assertEquals(AlluxioJniFuseFileSystem.MAX_NAME_LENGTH, stbuf.f_namemax.intValue());
}
Also used : BlockMasterInfo(alluxio.wire.BlockMasterInfo) BlockMasterClient(alluxio.client.block.BlockMasterClient) Statvfs(alluxio.jnifuse.struct.Statvfs) ByteBuffer(java.nio.ByteBuffer) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BlockMasterClient (alluxio.client.block.BlockMasterClient)1 Statvfs (alluxio.jnifuse.struct.Statvfs)1 BlockMasterInfo (alluxio.wire.BlockMasterInfo)1 ByteBuffer (java.nio.ByteBuffer)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1