Search in sources :

Example 6 with TestUserState

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());
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) CoreMasterContext(alluxio.master.CoreMasterContext) WorkerNetAddress(alluxio.wire.WorkerNetAddress) TestUserState(alluxio.security.user.TestUserState) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) StorageList(alluxio.grpc.StorageList) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory)

Example 7 with TestUserState

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
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Example 8 with TestUserState

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);
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState)

Example 9 with TestUserState

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());
}
Also used : TestUserState(alluxio.security.user.TestUserState) Before(org.junit.Before)

Example 10 with TestUserState

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();
}
Also used : UserState(alluxio.security.user.UserState) TestUserState(alluxio.security.user.TestUserState) FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) TestUserState(alluxio.security.user.TestUserState) AlluxioURI(alluxio.AlluxioURI)

Aggregations

TestUserState (alluxio.security.user.TestUserState)11 FileSystem (alluxio.client.file.FileSystem)6 AlluxioURI (alluxio.AlluxioURI)4 Test (org.junit.Test)4 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)2 FileSystemShellUtilsTest (alluxio.client.cli.fs.FileSystemShellUtilsTest)2 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)2 CoreMasterContext (alluxio.master.CoreMasterContext)2 MasterRegistry (alluxio.master.MasterRegistry)2 BlockMasterFactory (alluxio.master.block.BlockMasterFactory)2 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)2 UserState (alluxio.security.user.UserState)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 Before (org.junit.Before)2 URIStatus (alluxio.client.file.URIStatus)1 StorageList (alluxio.grpc.StorageList)1 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1