use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class GroupMappingServiceTest method group.
/**
* Tests the {@link GroupMappingService#getGroups(String)} method.
*/
@Test
public void group() throws Throwable {
String userName = "alluxio-user1";
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
try (Closeable mConfigurationRule = new ConfigurationRule(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, IdentityUserGroupsMapping.class.getName(), conf).toResource()) {
GroupMappingService groups = GroupMappingService.Factory.get(conf);
assertNotNull(groups);
assertNotNull(groups.getGroups(userName));
assertEquals(groups.getGroups(userName).size(), 1);
assertEquals(groups.getGroups(userName).get(0), userName);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UnderFileSystemConfigurationTest method getValueWhenGlobalConfOverridesPropertyWithDefaultValue.
@Test
public void getValueWhenGlobalConfOverridesPropertyWithDefaultValue() throws Exception {
// Set property in global configuration
try (Closeable c = new ConfigurationRule(PropertyKey.UNDERFS_LISTING_LENGTH, "2000", mConfiguration).toResource()) {
UnderFileSystemConfiguration conf = UnderFileSystemConfiguration.defaults(mConfiguration);
assertEquals("2000", conf.get(PropertyKey.UNDERFS_LISTING_LENGTH));
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UfsInputStreamCacheTest method releaseExpiredDifferentFile.
@Test
public void releaseExpiredDifferentFile() throws Exception {
try (Closeable r = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.WORKER_UFS_INSTREAM_CACHE_EXPIRARTION_TIME, "2");
}
}, ServerConfiguration.global()).toResource()) {
mManager = new UfsInputStreamCache();
// check out a stream
InputStream instream = mManager.acquire(mUfs, FILE_NAME, FILE_ID, OpenOptions.defaults().setOffset(2));
// wait a bit for a stream to be expired
Thread.sleep(100);
// check out another stream should trigger the timeout
mManager.acquire(mUfs, FILE_NAME + "2", FILE_ID + 1, OpenOptions.defaults().setOffset(4));
// wait a bit so release occurs after removal listener
Thread.sleep(100);
mManager.release(instream);
// verify the stream was closed once
verify(mSeekableInStreams[0], timeout(2000).times(1)).close();
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UfsInputStreamCacheTest method concurrencyWithExpiration.
@Test
public void concurrencyWithExpiration() throws Exception {
try (Closeable r = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.WORKER_UFS_INSTREAM_CACHE_EXPIRARTION_TIME, "20");
}
}, ServerConfiguration.global()).toResource()) {
mManager = new UfsInputStreamCache();
List<Thread> threads = new ArrayList<>();
int numCheckOutPerThread = 4;
for (int i = 0; i < mNumOfInputStreams / numCheckOutPerThread; i++) {
Runnable runnable = () -> {
for (int j = 0; j < numCheckOutPerThread; j++) {
InputStream instream;
try {
instream = mManager.acquire(mUfs, FILE_NAME, FILE_ID, OpenOptions.defaults().setOffset(j));
mManager.release(instream);
Thread.sleep(200);
} catch (Exception e) {
// the input streams created should not be more than mNumOfInputStreams
Assert.fail("input stream check in and out failed." + e);
}
}
};
threads.add(new Thread(runnable));
}
ConcurrencyUtils.assertConcurrent(threads, 30);
// ensure at least one expired in stream is closed
verify(mSeekableInStreams[0], timeout(2000)).close();
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class UfsInputStreamCacheTest method expire.
@Test
public void expire() throws Exception {
try (Closeable r = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.WORKER_UFS_INSTREAM_CACHE_EXPIRARTION_TIME, "2");
}
}, ServerConfiguration.global()).toResource()) {
mManager = new UfsInputStreamCache();
// check out a stream
InputStream instream = mManager.acquire(mUfs, FILE_NAME, FILE_ID, OpenOptions.defaults().setOffset(2));
// check in back
mManager.release(instream);
Thread.sleep(10);
// check out another stream should trigger the timeout
mManager.acquire(mUfs, FILE_NAME, FILE_ID, OpenOptions.defaults().setOffset(4));
verify(mSeekableInStreams[0], timeout(2000).times(1)).close();
}
}
Aggregations