Search in sources :

Example 11 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class LineageFileSystemTest method getDummyOutStream.

/**
   * Tests that a {@link DummyFileOutputStream} is returned.
   */
@Test
public void getDummyOutStream() throws Exception {
    AlluxioURI path = new AlluxioURI("test");
    Mockito.when(mLineageMasterClient.reinitializeFile("test", TEST_BLOCK_SIZE, 0, TtlAction.DELETE)).thenReturn(-1L);
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(TEST_BLOCK_SIZE).setTtl(0);
    FileOutStream outStream = mAlluxioLineageFileSystem.createFile(path, options);
    Assert.assertTrue(outStream instanceof DummyFileOutputStream);
    // verify client is released
    Mockito.verify(mLineageContext).releaseMasterClient(mLineageMasterClient);
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class LineageFileSystemTest method getLineageOutStream.

/**
   * Tests that a {@link LineageFileOutStream} is returned.
   */
@Test
public void getLineageOutStream() throws Exception {
    AlluxioURI path = new AlluxioURI("test");
    Mockito.when(mLineageMasterClient.reinitializeFile("test", TEST_BLOCK_SIZE, 0, TtlAction.FREE)).thenReturn(1L);
    CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(TEST_BLOCK_SIZE).setTtl(0).setTtlAction(alluxio.wire.TtlAction.FREE);
    FileOutStream outStream = mAlluxioLineageFileSystem.createFile(path, options);
    Assert.assertTrue(outStream instanceof LineageFileOutStream);
    // verify client is released
    Mockito.verify(mLineageContext).releaseMasterClient(mLineageMasterClient);
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class MasterFaultToleranceIntegrationTest method faultTestDataCreation.

/**
   * Creates 10 files in the folder.
   *
   * @param folderName the folder name to create
   * @param answer the results, the mapping from file id to file path
   */
private void faultTestDataCreation(AlluxioURI folderName, List<Pair<Long, AlluxioURI>> answer) throws IOException, AlluxioException {
    mFileSystem.createDirectory(folderName);
    answer.add(new Pair<>(mFileSystem.getStatus(folderName).getFileId(), folderName));
    for (int k = 0; k < 10; k++) {
        AlluxioURI path = new AlluxioURI(PathUtils.concatPath(folderName, folderName.toString().substring(1) + k));
        mFileSystem.createFile(path).close();
        answer.add(new Pair<>(mFileSystem.getStatus(path).getFileId(), path));
    }
}
Also used : AlluxioURI(alluxio.AlluxioURI)

Example 14 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class FileInStreamConcurrencyIntegrationTest method FileInStreamConcurrency.

/**
   * Tests the concurrent read of {@link FileInStream}.
   */
@Test
public void FileInStreamConcurrency() throws Exception {
    String uniqPath = PathUtils.uniqPath();
    FileSystemTestUtils.createByteFile(sFileSystem, uniqPath, BLOCK_SIZE * 2, sWriteAlluxio);
    List<Thread> threads = new ArrayList<>();
    for (int i = 0; i < sNumReadThreads; i++) {
        threads.add(new Thread(new FileRead(new AlluxioURI(uniqPath))));
    }
    ConcurrencyTestUtils.assertConcurrent(threads, 100);
}
Also used : ArrayList(java.util.ArrayList) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 15 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class KeyValueSystemIntegrationTest method deleteStore.

/**
   * Tests that a store of various sizes (including empty store) can be correctly deleted.
   */
@Test
public void deleteStore() throws Exception {
    List<AlluxioURI> storeUris = new ArrayList<>();
    storeUris.add(createStoreOfSize(0, null));
    storeUris.add(createStoreOfSize(2, null));
    storeUris.add(createStoreOfMultiplePartitions(3, null));
    for (AlluxioURI storeUri : storeUris) {
        testDeleteStore(storeUri);
    }
}
Also used : ArrayList(java.util.ArrayList) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1552 Test (org.junit.Test)1094 URIStatus (alluxio.client.file.URIStatus)356 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)303 IOException (java.io.IOException)154 FileInStream (alluxio.client.file.FileInStream)152 FileInfo (alluxio.wire.FileInfo)130 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)124 ArrayList (java.util.ArrayList)120 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)119 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)114 File (java.io.File)107 FileSystem (alluxio.client.file.FileSystem)99 FileOutStream (alluxio.client.file.FileOutStream)97 AlluxioException (alluxio.exception.AlluxioException)92 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)76 InvalidPathException (alluxio.exception.InvalidPathException)68 AbstractAlluxioShellTest (alluxio.shell.AbstractAlluxioShellTest)63 UnderFileSystem (alluxio.underfs.UnderFileSystem)63 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)62