Search in sources :

Example 1 with Statvfs

use of ru.serce.jnrfuse.struct.Statvfs in project alluxio by Alluxio.

the class AlluxioFuseFileSystemTest method statfs.

@Test
public void statfs() throws Exception {
    Runtime runtime = Runtime.getSystemRuntime();
    Pointer pointer = runtime.getMemoryManager().allocateTemporary(4 * Constants.KB, true);
    Statvfs stbuf = Statvfs.of(pointer);
    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(AlluxioFuseFileSystem.UNKNOWN_INODES, stbuf.f_files.intValue());
    assertEquals(AlluxioFuseFileSystem.UNKNOWN_INODES, stbuf.f_ffree.intValue());
    assertEquals(AlluxioFuseFileSystem.UNKNOWN_INODES, stbuf.f_favail.intValue());
    assertEquals(AlluxioFuseFileSystem.MAX_NAME_LENGTH, stbuf.f_namemax.intValue());
}
Also used : BlockMasterInfo(alluxio.wire.BlockMasterInfo) Runtime(jnr.ffi.Runtime) BlockMasterClient(alluxio.client.block.BlockMasterClient) Pointer(jnr.ffi.Pointer) Statvfs(ru.serce.jnrfuse.struct.Statvfs) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BlockMasterClient (alluxio.client.block.BlockMasterClient)1 BlockMasterInfo (alluxio.wire.BlockMasterInfo)1 Pointer (jnr.ffi.Pointer)1 Runtime (jnr.ffi.Runtime)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Statvfs (ru.serce.jnrfuse.struct.Statvfs)1