use of org.neo4j.kernel.guard.GuardTimeoutException 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.guard.GuardTimeoutException 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.guard.GuardTimeoutException in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateLongRunningQueryWithCustomTimeoutWithoutConfiguredDefault.
@Test
public void terminateLongRunningQueryWithCustomTimeoutWithoutConfiguredDefault() {
GraphDatabaseAPI database = startDatabaseWithoutTimeout();
try (Transaction transaction = database.beginTx(5, TimeUnit.SECONDS)) {
fakeClock.forward(4, TimeUnit.SECONDS);
database.execute("create (n)");
transaction.failure();
}
try (Transaction transaction = database.beginTx(6, TimeUnit.SECONDS)) {
fakeClock.forward(7, 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.guard.GuardTimeoutException in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateLongRunningTransactionWithPeriodicCommit.
@Test
public void terminateLongRunningTransactionWithPeriodicCommit() throws Exception {
GraphDatabaseAPI database = startDatabaseWithTimeoutCustomGuard();
try {
URL url = prepareTestImportFile(8);
database.execute("USING PERIODIC COMMIT 5 LOAD CSV FROM '" + url + "' AS line CREATE ();");
fail("Transaction should be already terminated.");
} catch (GuardTimeoutException ignored) {
}
assertDatabaseDoesNotHaveNodes(database);
}
use of org.neo4j.kernel.guard.GuardTimeoutException in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateTransactionWithCustomTimeoutWithoutConfiguredDefault.
@Test
public void terminateTransactionWithCustomTimeoutWithoutConfiguredDefault() {
GraphDatabaseAPI database = startDatabaseWithoutTimeout();
try (Transaction transaction = database.beginTx(27, TimeUnit.SECONDS)) {
fakeClock.forward(26, TimeUnit.SECONDS);
database.createNode();
transaction.failure();
}
try (Transaction transaction = database.beginTx(27, TimeUnit.SECONDS)) {
fakeClock.forward(28, TimeUnit.SECONDS);
database.createNode();
fail("Transaction should be already terminated.");
} catch (GuardTimeoutException e) {
assertThat(e.getMessage(), startsWith("Transaction timeout."));
}
assertDatabaseDoesNotHaveNodes(database);
}
Aggregations