use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class PermissionCheckTest method completeFileFail.
@Test
public void completeFileFail() throws Exception {
// set unmask
try (Closeable c = new ConfigurationRule(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066", ServerConfiguration.global()).toResource()) {
String file = PathUtils.concatPath(TEST_DIR_URI, "/testComplete1");
verifyCreateFile(TEST_USER_1, file, false);
CompleteFileContext expect = getNonDefaultCompleteFileContext();
mThrown.expect(AccessControlException.class);
mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.WRITE, file, "testComplete1")));
verifyCompleteFile(TEST_USER_2, file, expect);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class PermissionCheckTest method setStateFail.
@Test
public void setStateFail() throws Exception {
// set unmask
try (Closeable c = new ConfigurationRule(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, "066", ServerConfiguration.global()).toResource()) {
String file = PathUtils.concatPath(TEST_DIR_URI, "testState1");
verifyCreateFile(TEST_USER_1, file, false);
SetAttributePOptions expect = getNonDefaultSetState();
mThrown.expect(AccessControlException.class);
mThrown.expectMessage(ExceptionMessage.PERMISSION_DENIED.getMessage(toExceptionMessage(TEST_USER_2.getUser(), Mode.Bits.WRITE, file, "testState1")));
verifySetState(TEST_USER_2, file, expect);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UfsFallbackFileOutStreamIntegrationTest method shortCircuitWrite.
@Ignore
@Test
public void shortCircuitWrite() throws Exception {
try (Closeable c = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT, mBlockSize);
}
}, ServerConfiguration.global()).toResource()) {
FileSystem fs = FileSystem.Factory.create(ServerConfiguration.global());
AlluxioURI filePath = new AlluxioURI(PathUtils.uniqPath());
CreateFilePOptions op = CreateFilePOptions.newBuilder().setWriteType(WritePType.ASYNC_THROUGH).setRecursive(true).build();
writeIncreasingBytesToFile(fs, filePath, mFileLength, op);
CommonUtils.sleepMs(1);
// check the file is completed but not persisted
URIStatus status = mFileSystem.getStatus(filePath);
Assert.assertEquals(PersistenceState.TO_BE_PERSISTED.toString(), status.getPersistenceState());
Assert.assertTrue(status.isCompleted());
IntegrationTestUtils.waitForPersist(mLocalAlluxioClusterResource, filePath);
status = mFileSystem.getStatus(filePath);
Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
checkFileInAlluxio(filePath, mFileLength);
checkFileInUnderStorage(filePath, mFileLength);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UfsFallbackFileOutStreamIntegrationTest method grpcWrite.
@Ignore("Files may be lost due to evicting and committing before file is complete.")
@Test
public void grpcWrite() throws Exception {
try (Closeable c = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.USER_FILE_BUFFER_BYTES, mUserFileBufferSize);
put(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT, mBlockSize);
put(PropertyKey.USER_SHORT_CIRCUIT_ENABLED, false);
}
}, ServerConfiguration.global()).toResource()) {
AlluxioURI filePath = new AlluxioURI(PathUtils.uniqPath());
CreateFilePOptions op = CreateFilePOptions.newBuilder().setWriteType(WritePType.ASYNC_THROUGH).setRecursive(true).build();
writeIncreasingBytesToFile(filePath, mFileLength, op);
CommonUtils.sleepMs(1);
// check the file is completed but not persisted
URIStatus status = mFileSystem.getStatus(filePath);
Assert.assertEquals(PersistenceState.TO_BE_PERSISTED.toString(), status.getPersistenceState());
Assert.assertTrue(status.isCompleted());
IntegrationTestUtils.waitForPersist(mLocalAlluxioClusterResource, filePath);
status = mFileSystem.getStatus(filePath);
Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
checkFileInAlluxio(filePath, mFileLength);
checkFileInUnderStorage(filePath, mFileLength);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class DailyMetadataBackupTest method test.
@Test
public void test() throws Exception {
int fileToRetain = 1;
try (Closeable c = new ConfigurationRule(ImmutableMap.of(PropertyKey.MASTER_BACKUP_DIRECTORY, mBackupDir, PropertyKey.MASTER_DAILY_BACKUP_ENABLED, true, PropertyKey.MASTER_DAILY_BACKUP_FILES_RETAINED, fileToRetain), ServerConfiguration.global()).toResource()) {
DailyMetadataBackup dailyBackup = new DailyMetadataBackup(mMetaMaster, mScheduler, mUfsManager);
dailyBackup.start();
int backUpFileNum = 0;
when(mUfs.listStatus(mBackupDir)).thenReturn(generateUfsStatuses(++backUpFileNum));
mScheduler.jumpAndExecute(1, TimeUnit.DAYS);
verify(mMetaMaster, times(backUpFileNum)).backup(any(), any());
int deleteFileNum = getNumOfDeleteFile(backUpFileNum, fileToRetain);
verify(mUfs, times(deleteFileNum)).deleteFile(any());
when(mUfs.listStatus(mBackupDir)).thenReturn(generateUfsStatuses(++backUpFileNum));
mScheduler.jumpAndExecute(1, TimeUnit.DAYS);
verify(mMetaMaster, times(backUpFileNum)).backup(any(), any());
deleteFileNum += getNumOfDeleteFile(backUpFileNum, fileToRetain);
verify(mUfs, times(deleteFileNum)).deleteExistingFile(any());
when(mUfs.listStatus(mBackupDir)).thenReturn(generateUfsStatuses(++backUpFileNum));
mScheduler.jumpAndExecute(1, TimeUnit.DAYS);
verify(mMetaMaster, times(backUpFileNum)).backup(any(), any());
deleteFileNum += getNumOfDeleteFile(backUpFileNum, fileToRetain);
verify(mUfs, times(deleteFileNum)).deleteExistingFile(any());
}
}
Aggregations