Search in sources :

Example 31 with TestCase

use of alluxio.rest.TestCase in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method getStatus.

@Test
public void getStatus() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    mFileSystemMaster.createFile(uri, CreateFileOptions.defaults());
    mFileSystemMaster.completeFile(uri, CompleteFileOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    String result = new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.GET_STATUS), params, HttpMethod.GET, null).call();
    FileInfo fileInfo = new ObjectMapper().readValue(result, FileInfo.class);
    Assert.assertEquals(uri.getPath(), fileInfo.getPath());
    Assert.assertEquals(0, fileInfo.getLength());
}
Also used : FileInfo(alluxio.wire.FileInfo) HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 32 with TestCase

use of alluxio.rest.TestCase in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method free.

@Test
public void free() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    // Mark the file as persisted so the "free" works.
    mFileSystemMaster.createFile(uri, CreateFileOptions.defaults().setPersisted(true));
    mFileSystemMaster.completeFile(uri, CompleteFileOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    params.put("recursive", "false");
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.FREE), params, HttpMethod.POST, null).run();
}
Also used : HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 33 with TestCase

use of alluxio.rest.TestCase in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method setAttribute.

@Test
public void setAttribute() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    mFileSystemMaster.createFile(uri, CreateFileOptions.defaults());
    mFileSystemMaster.completeFile(uri, CompleteFileOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    params.put("pinned", "true");
    params.put("ttl", "100000");
    params.put("ttlAction", TtlAction.DELETE.toString());
    params.put("persisted", "true");
    params.put("recursive", "false");
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.SET_ATTRIBUTE), params, HttpMethod.POST, null).run();
    FileInfo fileInfo = mFileSystemMaster.getFileInfo(uri);
    Assert.assertEquals(uri.toString(), fileInfo.getPath());
    Assert.assertTrue(fileInfo.isPinned());
    Assert.assertEquals(100000, fileInfo.getTtl());
    Assert.assertEquals(TtlAction.DELETE, fileInfo.getTtlAction());
    Assert.assertTrue(fileInfo.isPersisted());
}
Also used : FileInfo(alluxio.wire.FileInfo) HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 34 with TestCase

use of alluxio.rest.TestCase in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method completeFile.

@Test
public void completeFile() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    long id = mFileSystemMaster.createFile(uri, CreateFileOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    params.put("ufsLength", "1");
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.COMPLETE_FILE), params, HttpMethod.POST, null).run();
    Assert.assertTrue(mFileSystemMaster.getFileInfo(id).isCompleted());
}
Also used : HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 35 with TestCase

use of alluxio.rest.TestCase in project alluxio by Alluxio.

the class FileSystemMasterClientRestApiTest method getNewBlockIdForFile.

@Test
public void getNewBlockIdForFile() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    mFileSystemMaster.createFile(uri, CreateFileOptions.defaults());
    Map<String, String> params = new HashMap<>();
    params.put("path", uri.toString());
    new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.GET_NEW_BLOCK_ID_FOR_FILE), params, HttpMethod.POST, null).call();
}
Also used : HashMap(java.util.HashMap) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Aggregations

TestCase (alluxio.rest.TestCase)44 RestApiTest (alluxio.rest.RestApiTest)40 Test (org.junit.Test)40 HashMap (java.util.HashMap)30 AlluxioURI (alluxio.AlluxioURI)29 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)12 FileInfo (alluxio.wire.FileInfo)7 Config (alluxio.LocalAlluxioClusterResource.Config)5 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)4 List (java.util.List)3 CommandLineJob (alluxio.job.CommandLineJob)2 JobConf (alluxio.job.JobConf)2 BlockWriter (alluxio.worker.block.io.BlockWriter)2 HttpURLConnection (java.net.HttpURLConnection)2 TestCaseOptions (alluxio.rest.TestCaseOptions)1 AlluxioMasterInfo (alluxio.wire.AlluxioMasterInfo)1 AlluxioWorkerInfo (alluxio.wire.AlluxioWorkerInfo)1 BlockInfo (alluxio.wire.BlockInfo)1 LineageInfo (alluxio.wire.LineageInfo)1 LockBlockResult (alluxio.wire.LockBlockResult)1