use of alluxio.security.user.TestUserState in project alluxio by Alluxio.
the class FileSystemMasterTest method startServices.
private void startServices() throws Exception {
mRegistry = new MasterRegistry();
mJournalSystem = JournalTestUtils.createJournalSystem(mJournalFolder);
CoreMasterContext masterContext = MasterTestUtils.testMasterContext(mJournalSystem, new TestUserState(TEST_USER, ServerConfiguration.global()));
mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
mRegistry.add(MetricsMaster.class, mMetricsMaster);
mMetrics = Lists.newArrayList();
mBlockMaster = new BlockMasterFactory().create(mRegistry, masterContext);
mExecutorService = Executors.newFixedThreadPool(4, ThreadFactoryUtils.build("DefaultFileSystemMasterTest-%d", true));
mFileSystemMaster = new DefaultFileSystemMaster(mBlockMaster, masterContext, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
mInodeStore = mFileSystemMaster.getInodeStore();
mInodeTree = mFileSystemMaster.getInodeTree();
mRegistry.add(FileSystemMaster.class, mFileSystemMaster);
mJournalSystem.start();
mJournalSystem.gainPrimacy();
mRegistry.start(true);
// set up workers
mWorkerId1 = mBlockMaster.getWorkerId(new WorkerNetAddress().setHost("localhost").setRpcPort(80).setDataPort(81).setWebPort(82));
mBlockMaster.workerRegister(mWorkerId1, Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.MB, Constants.MEDIUM_SSD, (long) Constants.MB), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.KB, Constants.MEDIUM_SSD, (long) Constants.KB), ImmutableMap.of(), new HashMap<String, StorageList>(), RegisterWorkerPOptions.getDefaultInstance());
mWorkerId2 = mBlockMaster.getWorkerId(new WorkerNetAddress().setHost("remote").setRpcPort(80).setDataPort(81).setWebPort(82));
mBlockMaster.workerRegister(mWorkerId2, Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.MB, Constants.MEDIUM_SSD, (long) Constants.MB), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.KB, Constants.MEDIUM_SSD, (long) Constants.KB), ImmutableMap.of(), new HashMap<String, StorageList>(), RegisterWorkerPOptions.getDefaultInstance());
}
use of alluxio.security.user.TestUserState in project alluxio by Alluxio.
the class LsCommandSecurityIntegrationTest method lsWithExtendedAcl.
@Test
public void lsWithExtendedAcl() throws IOException, AlluxioException {
int size = 50;
FileSystem fs = sLocalAlluxioCluster.getClient(FileSystemContext.create(new TestUserState("test_user_ls", ServerConfiguration.global()).getSubject(), ServerConfiguration.global()));
FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", WritePType.MUST_CACHE, 20);
FileSystemTestUtils.createByteFile(fs, "/testRoot/testFile", WritePType.MUST_CACHE, size, size);
sFsShell.run("ls", "--sort", "path", "/testRoot");
// CHECKSTYLE.OFF: LineLengthExceed - Improve readability
checkOutput("drwxr-xr-x test_user_ls test_user_ls 1 NOT_PERSISTED .+ .+ DIR /testRoot/testDir", "-rw-r--r-- test_user_ls test_user_ls 50 NOT_PERSISTED .+ .+ 100% /testRoot/testFile");
// CHECKSTYLE.ON: LineLengthExceed
mOutput.reset();
fs.setAcl(new AlluxioURI("/testRoot/testDir"), SetAclAction.MODIFY, Arrays.asList(AclEntry.fromCliString("default:user:nameduser:rwx")));
fs.setAcl(new AlluxioURI("/testRoot/testFile"), SetAclAction.MODIFY, Arrays.asList(AclEntry.fromCliString("user:nameduser:rwx")));
sFsShell.run("ls", "--sort", "path", "/testRoot");
// CHECKSTYLE.OFF: LineLengthExceed - Improve readability
checkOutput("drwxr-xr-x\\+ test_user_ls test_user_ls 1 NOT_PERSISTED .+ .+ DIR /testRoot/testDir", "-rw-r--r--\\+ test_user_ls test_user_ls 50 NOT_PERSISTED .+ .+ 100% /testRoot/testFile");
// CHECKSTYLE.ON: LineLengthExceed
}
use of alluxio.security.user.TestUserState in project alluxio by Alluxio.
the class LsCommandSecurityIntegrationTest method createFiles.
// Helper function to create a set of files in the file system
private void createFiles() throws Exception {
FileSystem fs = sLocalAlluxioCluster.getClient(FileSystemContext.create(new TestUserState("test_user_ls", ServerConfiguration.global()).getSubject(), ServerConfiguration.global()));
FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WritePType.MUST_CACHE, 10);
FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", WritePType.MUST_CACHE, 20);
FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", WritePType.THROUGH, 30);
}
use of alluxio.security.user.TestUserState in project alluxio by Alluxio.
the class BlockWorkerClientCloseIntegrationTest method before.
@Before
public void before() throws Exception {
mWorkerNetAddress = mClusterResource.get().getWorkerAddress();
mFsContext = FileSystemContext.create(new TestUserState("test", ServerConfiguration.global()).getSubject(), ServerConfiguration.global());
}
use of alluxio.security.user.TestUserState in project alluxio by Alluxio.
the class MasterClientAuthenticationIntegrationTest method authenticationOperationTest.
/**
* Tests Alluxio client connects or disconnects to the Master. When the client connects
* successfully to the Master, it can successfully create file or not.
*
* @param filename the name of the file
*/
private void authenticationOperationTest(String filename) throws Exception {
UserState s = new TestUserState(SUPERUSER, ServerConfiguration.global());
FileSystemMasterClient masterClient = FileSystemMasterClient.Factory.create(MasterClientContext.newBuilder(ClientContext.create(s.getSubject(), ServerConfiguration.global())).build());
Assert.assertFalse(masterClient.isConnected());
masterClient.connect();
Assert.assertTrue(masterClient.isConnected());
masterClient.createFile(new AlluxioURI(filename), FileSystemOptions.createFileDefaults(ServerConfiguration.global()));
Assert.assertNotNull(masterClient.getStatus(new AlluxioURI(filename), FileSystemOptions.getStatusDefaults(ServerConfiguration.global())));
masterClient.disconnect();
masterClient.close();
}
Aggregations