use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method startCustomDatabase.
private GraphDatabaseAPI startCustomDatabase(File storeDir, Map<Setting<?>, String> configMap) {
CustomClockCommunityFacadeFactory customClockCommunityFacadeFactory = new CustomClockCommunityFacadeFactory();
GraphDatabaseBuilder databaseBuilder = new CustomGuardTestTestGraphDatabaseFactory(customClockCommunityFacadeFactory).newImpermanentDatabaseBuilder(storeDir);
configMap.forEach(databaseBuilder::setConfig);
GraphDatabaseAPI database = (GraphDatabaseAPI) databaseBuilder.newGraphDatabase();
cleanupRule.add(database);
return database;
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateLongRunningTransaction.
@Test
public void terminateLongRunningTransaction() {
GraphDatabaseAPI database = startDatabaseWithTimeout();
try (Transaction transaction = database.beginTx()) {
fakeClock.forward(3, TimeUnit.SECONDS);
transaction.success();
database.createNode();
fail("Transaction should be already terminated.");
} catch (GuardTimeoutException e) {
assertThat(e.getMessage(), startsWith("Transaction timeout."));
assertEquals(e.status(), Status.Transaction.TransactionTimedOut);
}
assertDatabaseDoesNotHaveNodes(database);
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateLongRunningQueryTransaction.
@Test
public void terminateLongRunningQueryTransaction() {
GraphDatabaseAPI database = startDatabaseWithTimeout();
try (Transaction transaction = database.beginTx()) {
fakeClock.forward(3, TimeUnit.SECONDS);
transaction.success();
database.execute("create (n)");
fail("Transaction should be already terminated.");
} catch (GuardTimeoutException e) {
assertThat(e.getMessage(), startsWith("Transaction timeout."));
}
assertDatabaseDoesNotHaveNodes(database);
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class BackupServiceIT method shouldHandleBackupWhenLogFilesHaveBeenDeleted.
@Test
public void shouldHandleBackupWhenLogFilesHaveBeenDeleted() throws Exception {
// Given
defaultBackupPortHostParams();
Config defaultConfig = dbRule.getConfigCopy();
dbRule.setConfig(GraphDatabaseSettings.keep_logical_logs, "false");
GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
BackupService backupService = backupService();
createAndIndexNode(db, 1);
// A full backup
backupService.doIncrementalBackupOrFallbackToFull(BACKUP_HOST, backupPort, backupDir.getAbsoluteFile(), ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
// And the log the backup uses is rotated out
createAndIndexNode(db, 2);
db = deleteLogFilesAndRestart();
createAndIndexNode(db, 3);
db = deleteLogFilesAndRestart();
// when
backupService.doIncrementalBackupOrFallbackToFull(BACKUP_HOST, backupPort, backupDir.getAbsoluteFile(), ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
// Then
db.shutdown();
assertEquals(getDbRepresentation(), getBackupDbRepresentation());
}
use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.
the class BackupServiceIT method shouldPrintThatIncrementalBackupIsPerformedAndFallingBackToFull.
@Test
public void shouldPrintThatIncrementalBackupIsPerformedAndFallingBackToFull() throws Exception {
defaultBackupPortHostParams();
Config defaultConfig = dbRule.getConfigCopy();
dbRule.setConfig(GraphDatabaseSettings.keep_logical_logs, "false");
// have logs rotated on every transaction
GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
createAndIndexNode(db, 1);
// A full backup
backupService().doFullBackup(BACKUP_HOST, backupPort, backupDir, ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
// And the log the backup uses is rotated out
createAndIndexNode(db, 2);
rotateAndCheckPoint(db);
createAndIndexNode(db, 3);
rotateAndCheckPoint(db);
createAndIndexNode(db, 4);
rotateAndCheckPoint(db);
final Log log = mock(Log.class);
LogProvider logProvider = new LogProvider() {
@Override
public Log getLog(Class loggingClass) {
return log;
}
@Override
public Log getLog(String name) {
return log;
}
};
backupService(logProvider).doIncrementalBackupOrFallbackToFull(BACKUP_HOST, backupPort, backupDir, ConsistencyCheck.NONE, dbRule.getConfigCopy(), BackupClient.BIG_READ_TIMEOUT, false);
verify(log).info("Previous backup found, trying incremental backup.");
verify(log).info("Existing backup is too far out of date, a new full backup will be performed.");
}
Aggregations