use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class InternalFlatFileRealmIT method setup.
@Before
public void setup() throws Throwable {
fs = new EvilFileSystem(new EphemeralFileSystemAbstraction());
userStoreFile = new File("dbms", "auth");
roleStoreFile = new File("dbms", "roles");
final UserRepository userRepository = new FileUserRepository(fs, userStoreFile, logProvider);
final RoleRepository roleRepository = new FileRoleRepository(fs, roleStoreFile, logProvider);
final UserRepository initialUserRepository = CommunitySecurityModule.getInitialUserRepository(Config.defaults(), logProvider, fs);
final UserRepository defaultAdminRepository = EnterpriseSecurityModule.getDefaultAdminRepository(Config.defaults(), logProvider, fs);
final PasswordPolicy passwordPolicy = new BasicPasswordPolicy();
AuthenticationStrategy authenticationStrategy = new RateLimitedAuthenticationStrategy(Clocks.systemClock(), 3);
realm = new InternalFlatFileRealm(userRepository, roleRepository, passwordPolicy, authenticationStrategy, true, true, jobScheduler, initialUserRepository, defaultAdminRepository);
realm.init();
realm.start();
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class AuthProceduresIT method setup.
@Before
public void setup() throws InvalidAuthTokenException, IOException {
fs = new EphemeralFileSystemAbstraction();
db = (GraphDatabaseAPI) createGraphDatabase(fs);
authManager = db.getDependencyResolver().resolveDependency(BasicAuthManager.class);
admin = login("neo4j", "neo4j");
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class SegmentedRaftLogCursorIT method createRaftLog.
private SegmentedRaftLog createRaftLog(long rotateAtSize, String pruneStrategy) {
if (fileSystem == null) {
fileSystem = new EphemeralFileSystemAbstraction();
}
File directory = new File(RAFT_LOG_DIRECTORY_NAME);
fileSystem.mkdir(directory);
LogProvider logProvider = getInstance();
CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(pruneStrategy, logProvider).newInstance();
SegmentedRaftLog newRaftLog = new SegmentedRaftLog(fileSystem, directory, rotateAtSize, new DummyRaftableContentSerializer(), logProvider, 8, Clocks.systemClock(), new OnDemandJobScheduler(), pruningStrategy);
life.add(newRaftLog);
life.init();
life.start();
return newRaftLog;
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class SegmentedRaftLogRotationTruncationPruneTest method createRaftLog.
private RaftLog createRaftLog() throws Exception {
File directory = new File(RAFT_LOG_DIRECTORY_NAME);
FileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
fileSystem.mkdir(directory);
LogProvider logProvider = getInstance();
CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory("1 entries", logProvider).newInstance();
SegmentedRaftLog newRaftLog = new SegmentedRaftLog(fileSystem, directory, 1, new DummyRaftableContentSerializer(), logProvider, 8, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
newRaftLog.start();
return newRaftLog;
}
use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.
the class DurableStateStorageIT method shouldProperlyRecoveryAfterCrashOnFileForceDuringWrite.
@Test
public void shouldProperlyRecoveryAfterCrashOnFileForceDuringWrite() throws Exception {
EphemeralFileSystemAbstraction normalFSA = fileSystemRule.get();
/*
* Magic number warning. For a rotation threshold of 14, 990 operations on file A falls on a force() of the
* current active file. This has been discovered via experimentation. The end result is that there is a
* flush (but not write) a value. This should be recoverable. Interestingly, the failure semantics are a bit
* unclear on what should happen to that value. We assume that exception during persistence requires recovery
* to discover if the last argument made it to disk or not. Since we use an EFSA, force is not necessary and
* the value that caused the failure is actually "persisted" and recovered.
*/
AdversarialFileSystemAbstraction breakingFSA = new AdversarialFileSystemAbstraction(new MethodGuardedAdversary(new CountingAdversary(40, true), StoreChannel.class.getMethod("force", boolean.class)), normalFSA);
SelectiveFileSystemAbstraction combinedFSA = new SelectiveFileSystemAbstraction(new File(new File(testDir.directory(), "long-state"), "long.a"), breakingFSA, normalFSA);
long lastValue = 0;
try (LongState persistedState = new LongState(combinedFSA, testDir.directory(), 14)) {
while (// it will break from the Exception that AFS will throw
true) {
long tempValue = lastValue + 1;
persistedState.setTheState(tempValue);
lastValue = tempValue;
}
} catch (Exception expected) {
// this stack trace should contain force()
ensureStackTraceContainsExpectedMethod(expected.getStackTrace(), "force");
}
try (LongState restoredState = new LongState(normalFSA, testDir.directory(), 14)) {
assertThat(restoredState.getTheState(), greaterThanOrEqualTo(lastValue));
}
}
Aggregations