use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class MasterInfoServiceTest method masterShouldRespond404AndFalseWhenSlave.
@Test
public void masterShouldRespond404AndFalseWhenSlave() throws Exception {
// given
HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
when(database.role()).thenReturn("slave");
MasterInfoService service = new MasterInfoService(null, database);
// when
Response response = service.isMaster();
// then
assertEquals(404, response.getStatus());
assertEquals("false", String.valueOf(response.getEntity()));
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class MasterInfoServiceTest method shouldReportNonMasterOrSlaveAsUnavailableForTransactionProcessing.
@Test
public void shouldReportNonMasterOrSlaveAsUnavailableForTransactionProcessing() throws Exception {
// given
HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
when(database.role()).thenReturn("unknown");
MasterInfoService service = new MasterInfoService(null, database);
// when
Response response = service.isAvailable();
// then
assertEquals(404, response.getStatus());
assertEquals("UNKNOWN", String.valueOf(response.getEntity()));
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class MasterInfoServiceTest method slaveShouldRespond404AndFalseWhenMaster.
@Test
public void slaveShouldRespond404AndFalseWhenMaster() throws Exception {
// given
HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
when(database.role()).thenReturn("master");
MasterInfoService service = new MasterInfoService(null, database);
// when
Response response = service.isSlave();
// then
assertEquals(404, response.getStatus());
assertEquals("false", String.valueOf(response.getEntity()));
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class MasterInfoServiceTest method slaveShouldRespond200AndTrueWhenSlave.
@Test
public void slaveShouldRespond200AndTrueWhenSlave() throws Exception {
// given
HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
when(database.role()).thenReturn("slave");
MasterInfoService service = new MasterInfoService(null, database);
// when
Response response = service.isSlave();
// then
assertEquals(200, response.getStatus());
assertEquals("true", String.valueOf(response.getEntity()));
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TestPullUpdates method pullUpdatesShellAppPullsUpdates.
@Test
public void pullUpdatesShellAppPullsUpdates() throws Throwable {
ClusterManager.ManagedCluster cluster = clusterRule.withCluster(clusterOfSize(2)).withSharedSetting(HaSettings.pull_interval, "0").withSharedSetting(HaSettings.tx_push_factor, "0").withSharedSetting(ShellSettings.remote_shell_enabled, Settings.TRUE).withInstanceSetting(ShellSettings.remote_shell_port, oneBasedServerId -> oneBasedServerId >= 1 && oneBasedServerId <= 2 ? "" + (SHELL_PORT + oneBasedServerId) : null).startCluster();
long commonNodeId = createNodeOnMaster(cluster);
setProperty(cluster.getMaster(), commonNodeId, 1);
callPullUpdatesViaShell(2);
HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
try (Transaction tx = slave.beginTx()) {
assertEquals(1, slave.getNodeById(commonNodeId).getProperty("i"));
tx.success();
}
}
Aggregations