use of alluxio.rest.TestCase in project alluxio by Alluxio.
the class FileSystemMasterClientRestApiTest method rename.
@Test
public void rename() throws Exception {
AlluxioURI uri1 = new AlluxioURI("/file1");
AlluxioURI uri2 = new AlluxioURI("/file2");
mFileSystemMaster.createFile(uri1, CreateFileOptions.defaults());
mFileSystemMaster.completeFile(uri1, CompleteFileOptions.defaults());
Map<String, String> params = new HashMap<>();
params.put("srcPath", uri1.toString());
params.put("dstPath", uri2.toString());
new TestCase(mHostname, mPort, getEndpoint(FileSystemMasterClientRestServiceHandler.RENAME), params, HttpMethod.POST, null).run();
try {
mFileSystemMaster.getFileInfo(uri1);
Assert.fail("file should have been removed");
} catch (FileDoesNotExistException e) {
// Expected
}
mFileSystemMaster.getFileInfo(uri2);
}
use of alluxio.rest.TestCase in project alluxio by Alluxio.
the class BlockWorkerClientRestApiTest method readBlock.
@Test
public void readBlock() throws Exception {
// Write a block and acquire a lock for it.
mBlockWorker.createBlock(SESSION_ID, BLOCK_ID, TIER_ALIAS, INITIAL_BYTES);
BlockWriter writer = mBlockWorker.getTempBlockWriterRemote(SESSION_ID, BLOCK_ID);
writer.append(BYTE_BUFFER);
writer.close();
mBlockWorker.commitBlock(SESSION_ID, BLOCK_ID);
long lockId = mBlockWorker.lockBlock(SESSION_ID, BLOCK_ID);
Map<String, String> params = new HashMap<>();
params.put("blockId", Long.toString(BLOCK_ID));
params.put("sessionId", Long.toString(SESSION_ID));
params.put("lockId", Long.toString(lockId));
params.put("offset", "0");
params.put("length", Long.toString(INITIAL_BYTES));
TestCase testCase = new TestCase(mHostname, mPort, getEndpoint(BlockWorkerClientRestServiceHandler.READ_BLOCK), params, HttpMethod.GET, BYTE_BUFFER);
HttpURLConnection connection = (HttpURLConnection) testCase.createURL().openConnection();
connection.setRequestMethod(testCase.getMethod());
connection.connect();
Assert.assertEquals(testCase.getEndpoint(), Response.Status.OK.getStatusCode(), connection.getResponseCode());
Assert.assertEquals(new String(BYTE_BUFFER.array()), testCase.getResponse(connection));
}
use of alluxio.rest.TestCase in project alluxio by Alluxio.
the class BlockWorkerClientRestApiTest method cacheBlock.
@Test
public void cacheBlock() throws Exception {
mBlockWorker.createBlock(SESSION_ID, BLOCK_ID, TIER_ALIAS, INITIAL_BYTES);
mBlockWorker.commitBlock(SESSION_ID, BLOCK_ID);
Map<String, String> params = new HashMap<>();
params.put("blockId", Long.toString(BLOCK_ID));
params.put("sessionId", Long.toString(SESSION_ID));
new TestCase(mHostname, mPort, getEndpoint(BlockWorkerClientRestServiceHandler.CACHE_BLOCK), params, HttpMethod.POST, null).run();
}
use of alluxio.rest.TestCase in project alluxio by Alluxio.
the class BlockWorkerClientRestApiTest method unlockBlock.
@Test
public void unlockBlock() throws Exception {
// Write a block and acquire a lock for it.
mBlockWorker.createBlock(SESSION_ID, BLOCK_ID, TIER_ALIAS, INITIAL_BYTES);
BlockWriter writer = mBlockWorker.getTempBlockWriterRemote(SESSION_ID, BLOCK_ID);
writer.append(BYTE_BUFFER);
writer.close();
mBlockWorker.commitBlock(SESSION_ID, BLOCK_ID);
mBlockWorker.lockBlock(SESSION_ID, BLOCK_ID);
Map<String, String> params = new HashMap<>();
params.put("blockId", Long.toString(BLOCK_ID));
params.put("sessionId", Long.toString(SESSION_ID));
new TestCase(mHostname, mPort, getEndpoint(BlockWorkerClientRestServiceHandler.UNLOCK_BLOCK), params, HttpMethod.POST, null).run();
}
use of alluxio.rest.TestCase in project alluxio by Alluxio.
the class BlockWorkerClientRestApiTest method accessBlock.
@Test
public void accessBlock() throws Exception {
mBlockWorker.createBlock(SESSION_ID, BLOCK_ID, TIER_ALIAS, INITIAL_BYTES);
mBlockWorker.commitBlock(SESSION_ID, BLOCK_ID);
Map<String, String> params = new HashMap<>();
params.put("blockId", Long.toString(BLOCK_ID));
new TestCase(mHostname, mPort, getEndpoint(BlockWorkerClientRestServiceHandler.ACCESS_BLOCK), params, HttpMethod.POST, null).run();
}
Aggregations