Search in sources :

Example 6 with TestCase

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

the class FileSystemClientRestApiTest method setAttribute.

@Test
public void setAttribute() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    writeFile(uri, null);
    new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.SET_ATTRIBUTE, NO_PARAMS, HttpMethod.POST, null, TestCaseOptions.defaults().setBody(SetAttributeOptions.defaults().setMode(Mode.defaults()))).run();
    FileInfo fileInfo = mFileSystemMaster.getFileInfo(uri);
    Assert.assertEquals(uri.toString(), fileInfo.getPath());
}
Also used : FileInfo(alluxio.wire.FileInfo) TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 7 with TestCase

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

the class FileSystemClientRestApiTest method unmount.

@Test
public void unmount() throws Exception {
    AlluxioURI uri = new AlluxioURI("/mount");
    mFileSystemMaster.mount(uri, new AlluxioURI(mFolder.newFolder().getAbsolutePath()), alluxio.master.file.options.MountOptions.defaults());
    new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.UNMOUNT, NO_PARAMS, HttpMethod.POST, null, TestCaseOptions.defaults().setBody(UnmountOptions.defaults())).run();
}
Also used : TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 8 with TestCase

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

the class FileSystemClientRestApiTest method free.

@Test
public void free() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    writeFile(uri, null);
    new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.FREE, NO_PARAMS, HttpMethod.POST, null, TestCaseOptions.defaults().setBody(FreeOptions.defaults())).run();
}
Also used : TestCase(alluxio.rest.TestCase) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 9 with TestCase

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

the class FileSystemClientRestApiTest method upload.

@Test
public void upload() throws Exception {
    AlluxioURI uri = new AlluxioURI("/file");
    String message = "Greetings traveller!";
    writeFile(uri, message.getBytes());
    String result = new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.GET_STATUS, NO_PARAMS, HttpMethod.POST, null).call();
    FileInfo fileInfo = new ObjectMapper().readValue(result, FileInfo.class);
    Assert.assertEquals(message.length(), fileInfo.getLength());
}
Also used : FileInfo(alluxio.wire.FileInfo) TestCase(alluxio.rest.TestCase) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 10 with TestCase

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

the class FileSystemClientRestApiTest method rename.

@Test
public void rename() throws Exception {
    AlluxioURI uri1 = new AlluxioURI("/file1");
    AlluxioURI uri2 = new AlluxioURI("/file2");
    writeFile(uri1, null);
    Map<String, String> params = new HashMap<>();
    params.put("dst", uri2.toString());
    new TestCase(mHostname, mPort, PATHS_PREFIX + uri1.toString() + "/" + PathsRestServiceHandler.RENAME, params, HttpMethod.POST, null, TestCaseOptions.defaults().setBody(RenameOptions.defaults())).run();
    try {
        mFileSystemMaster.getFileInfo(uri1);
        Assert.fail("file should have been removed");
    } catch (FileDoesNotExistException e) {
    // Expected
    }
    mFileSystemMaster.getFileInfo(uri2);
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) 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