Search in sources :

Example 16 with ConfigurationRule

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);
    }
}
Also used : Closeable(java.io.Closeable) CompleteFileContext(alluxio.master.file.contexts.CompleteFileContext) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 17 with ConfigurationRule

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);
    }
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 18 with ConfigurationRule

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);
    }
}
Also used : HashMap(java.util.HashMap) Closeable(java.io.Closeable) FileSystem(alluxio.client.file.FileSystem) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) URIStatus(alluxio.client.file.URIStatus) ConfigurationRule(alluxio.ConfigurationRule) AlluxioURI(alluxio.AlluxioURI) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with ConfigurationRule

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);
    }
}
Also used : HashMap(java.util.HashMap) Closeable(java.io.Closeable) CreateFilePOptions(alluxio.grpc.CreateFilePOptions) URIStatus(alluxio.client.file.URIStatus) ConfigurationRule(alluxio.ConfigurationRule) AlluxioURI(alluxio.AlluxioURI) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 20 with ConfigurationRule

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());
    }
}
Also used : Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Aggregations

ConfigurationRule (alluxio.ConfigurationRule)42 Closeable (java.io.Closeable)42 Test (org.junit.Test)40 HashMap (java.util.HashMap)16 File (java.io.File)6 AlluxioURI (alluxio.AlluxioURI)5 PropertyKey (alluxio.conf.PropertyKey)5 SeekableUnderFileInputStream (alluxio.underfs.SeekableUnderFileInputStream)5 TieredIdentity (alluxio.wire.TieredIdentity)5 InputStream (java.io.InputStream)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)4 LocalityTier (alluxio.wire.TieredIdentity.LocalityTier)4 WorkerNetAddress (alluxio.wire.WorkerNetAddress)4 Random (java.util.Random)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 URIStatus (alluxio.client.file.URIStatus)3 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)2 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)2 ConnectDetails (alluxio.master.MasterInquireClient.ConnectDetails)2