use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class GrpcSecurityTest method createServer.
private GrpcServer createServer(AuthType authType) {
mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, authType.name());
InetSocketAddress bindAddress = new InetSocketAddress(NetworkAddressUtils.getLocalHostName((int) mConfiguration.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS)), 0);
UserState us = UserState.Factory.create(mConfiguration);
GrpcServerBuilder serverBuilder = GrpcServerBuilder.forAddress(GrpcServerAddress.create("localhost", bindAddress), mConfiguration, us);
return serverBuilder.build();
}
use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class RemoteReadIntegrationTest method before.
@Before
public final void before() throws Exception {
mFileSystem = mLocalAlluxioClusterResource.get().getClient();
UserState us = UserState.Factory.create(ServerConfiguration.global());
mFsContext = FileSystemContext.create(us.getSubject(), ServerConfiguration.global());
mWriteAlluxio = CreateFilePOptions.newBuilder().setWriteType(WritePType.MUST_CACHE).setRecursive(true).build();
mWriteUnderStore = CreateFilePOptions.newBuilder().setWriteType(WritePType.THROUGH).setRecursive(true).build();
mReadCache = OpenFilePOptions.newBuilder().setReadType(ReadPType.CACHE_PROMOTE).build();
mReadNoCache = OpenFilePOptions.newBuilder().setReadType(ReadPType.NO_CACHE).build();
}
use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class PersistenceTest method retryPersistJobRenameDelete.
/**
* Tests that a persist file job is retried after the file is renamed and the src directory is
* deleted.
*/
@Test(timeout = 20000)
public void retryPersistJobRenameDelete() throws Exception {
UserState s = UserState.Factory.create(ServerConfiguration.global());
AuthenticatedClientUser.set(s.getUser().getName());
// Create src file and directory, checking the internal state.
AlluxioURI alluxioDirSrc = new AlluxioURI("/src");
mFileSystemMaster.createDirectory(alluxioDirSrc, CreateDirectoryContext.defaults().setWriteType(WriteType.CACHE_THROUGH));
AlluxioURI alluxioFileSrc = new AlluxioURI("/src/in_alluxio");
FileInfo info = mFileSystemMaster.createFile(alluxioFileSrc, CreateFileContext.defaults().setWriteType(WriteType.MUST_CACHE));
Assert.assertEquals(PersistenceState.NOT_PERSISTED.toString(), info.getPersistenceState());
mFileSystemMaster.completeFile(alluxioFileSrc, CompleteFileContext.defaults());
// Schedule the async persistence, checking the internal state.
mFileSystemMaster.scheduleAsyncPersistence(alluxioFileSrc, ScheduleAsyncPersistenceContext.defaults());
checkPersistenceRequested(alluxioFileSrc);
// Mock the job service interaction.
Random random = new Random();
long jobId = random.nextLong();
Mockito.when(mMockJobMasterClient.run(any(JobConfig.class))).thenReturn(jobId);
// Execute the persistence scheduler heartbeat, checking the internal state.
HeartbeatScheduler.execute(HeartbeatContext.MASTER_PERSISTENCE_SCHEDULER);
CommonUtils.waitFor("Scheduler heartbeat", (() -> getPersistJobs().size() > 0));
checkPersistenceInProgress(alluxioFileSrc, jobId);
// Mock the job service interaction.
JobInfo jobInfo = createJobInfo(Status.CREATED);
Mockito.when(mMockJobMasterClient.getJobStatus(Mockito.anyLong())).thenReturn(jobInfo);
// Execute the persistence checker heartbeat, checking the internal state.
HeartbeatScheduler.execute(HeartbeatContext.MASTER_PERSISTENCE_CHECKER);
CommonUtils.waitFor("Checker heartbeat", (() -> getPersistJobs().size() > 0));
checkPersistenceInProgress(alluxioFileSrc, jobId);
// Mock the job service interaction.
jobInfo = createJobInfo(Status.COMPLETED);
Mockito.when(mMockJobMasterClient.getJobStatus(Mockito.anyLong())).thenReturn(jobInfo);
// Create the temporary UFS file.
{
Map<Long, PersistJob> persistJobs = getPersistJobs();
PersistJob job = persistJobs.get(info.getFileId());
UnderFileSystem ufs = UnderFileSystem.Factory.create(job.getTempUfsPath().toString(), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()));
UnderFileSystemUtils.touch(ufs, job.getTempUfsPath());
}
// Rename the src file before the persist is commited.
mFileSystemMaster.createDirectory(new AlluxioURI("/dst"), CreateDirectoryContext.defaults().setWriteType(WriteType.CACHE_THROUGH));
AlluxioURI alluxioFileDst = new AlluxioURI("/dst/in_alluxio");
mFileSystemMaster.rename(alluxioFileSrc, alluxioFileDst, RenameContext.defaults());
// Delete the src directory recursively.
mFileSystemMaster.delete(alluxioDirSrc, DeleteContext.mergeFrom(DeletePOptions.newBuilder().setRecursive(true)));
// Repeatedly execute the persistence checker heartbeat, checking the internal state.
{
// Execute the persistence checker heartbeat, checking the internal state. This should
// write the persist file to renamed destination.
HeartbeatScheduler.execute(HeartbeatContext.MASTER_PERSISTENCE_CHECKER);
waitUntilPersisted(alluxioFileDst);
HeartbeatScheduler.execute(HeartbeatContext.MASTER_PERSISTENCE_CHECKER);
waitUntilPersisted(alluxioFileDst);
}
}
use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class PersistenceTest method before.
@Before
public void before() throws Exception {
UserState s = UserState.Factory.create(ServerConfiguration.global());
AuthenticatedClientUser.set(s.getUser().getName());
TemporaryFolder tmpFolder = new TemporaryFolder();
tmpFolder.create();
File ufsRoot = tmpFolder.newFolder();
ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS);
ServerConfiguration.set(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS, ufsRoot.getAbsolutePath());
ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_INITIAL_INTERVAL_MS, 0);
ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_INTERVAL_MS, 1000);
ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_TOTAL_WAIT_TIME_MS, 1000);
mJournalFolder = tmpFolder.newFolder();
mSafeModeManager = new DefaultSafeModeManager();
mStartTimeMs = System.currentTimeMillis();
mPort = ServerConfiguration.getInt(PropertyKey.MASTER_RPC_PORT);
startServices();
}
use of alluxio.security.user.UserState in project alluxio by Alluxio.
the class GrpcSecurityTest method testAuthenticationRevoked.
@Test
public void testAuthenticationRevoked() throws Exception {
mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
mConfiguration.set(PropertyKey.AUTHENTICATION_INACTIVE_CHANNEL_REAUTHENTICATE_PERIOD, "250ms");
GrpcServer server = createServer(AuthType.SIMPLE);
try {
server.start();
UserState us = UserState.Factory.create(mConfiguration);
GrpcChannel channel = GrpcChannelBuilder.newBuilder(getServerConnectAddress(server), mConfiguration).setSubject(us.getSubject()).build();
Assert.assertTrue(channel.isHealthy());
/*
* Sleeping will ensure that authentication sessions for the channel will expire on the
* server. This should have propagated back to the client and its health status should reflect
* that.
*
* Sleep more than authentication revocation timeout.
*/
Thread.sleep(500);
Assert.assertFalse(channel.isHealthy());
} finally {
server.shutdown();
}
}
Aggregations