use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class NeoStoreDataSourceTest method shouldLogCorrectTransactionLogDiagnosticsForTransactionsInOldestLog.
@Test
public void shouldLogCorrectTransactionLogDiagnosticsForTransactionsInOldestLog() throws Exception {
// GIVEN
long logVersion = 2, prevLogLastTxId = 45;
NeoStoreDataSource dataSource = neoStoreDataSourceWithLogFilesContainingLowestTxId(logWithTransactions(logVersion, prevLogLastTxId));
AssertableLogProvider logProvider = new AssertableLogProvider();
Logger logger = logProvider.getLog(getClass()).infoLogger();
// WHEN
Diagnostics.TRANSACTION_RANGE.dump(dataSource, logger);
// THEN
logProvider.assertContainsMessageContaining("transaction " + (prevLogLastTxId + 1));
logProvider.assertContainsMessageContaining("version " + logVersion);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class NeoStoreDataSourceTest method shouldLogCorrectTransactionLogDiagnosticsForTransactionsInSecondOldestLog.
@Test
public void shouldLogCorrectTransactionLogDiagnosticsForTransactionsInSecondOldestLog() throws Exception {
// GIVEN
long logVersion = 2, prevLogLastTxId = 45;
NeoStoreDataSource dataSource = neoStoreDataSourceWithLogFilesContainingLowestTxId(logWithTransactionsInNextToOldestLog(logVersion, prevLogLastTxId));
AssertableLogProvider logProvider = new AssertableLogProvider();
Logger logger = logProvider.getLog(getClass()).infoLogger();
// WHEN
Diagnostics.TRANSACTION_RANGE.dump(dataSource, logger);
// THEN
logProvider.assertContainsMessageContaining("transaction " + (prevLogLastTxId + 1));
logProvider.assertContainsMessageContaining("version " + (logVersion + 1));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class NeoStoreDataSourceTest method shouldLogCorrectTransactionLogDiagnosticsForNoTransactionLogs.
@Test
public void shouldLogCorrectTransactionLogDiagnosticsForNoTransactionLogs() throws Exception {
// GIVEN
NeoStoreDataSource dataSource = neoStoreDataSourceWithLogFilesContainingLowestTxId(noLogs());
AssertableLogProvider logProvider = new AssertableLogProvider();
Logger logger = logProvider.getLog(getClass()).infoLogger();
// WHEN
Diagnostics.TRANSACTION_RANGE.dump(dataSource, logger);
// THEN
logProvider.assertContainsMessageContaining("No transactions");
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class SlaveLocksClientTest method setUp.
@Before
public void setUp() throws Exception {
master = mock(Master.class);
availabilityGuard = new AvailabilityGuard(Clocks.fakeClock(), getInstance());
lockManager = new CommunityLockManger(Config.defaults(), Clocks.systemClock());
local = spy(lockManager.newClient());
logProvider = new AssertableLogProvider();
LockResult lockResultOk = new LockResult(LockStatus.OK_LOCKED);
TransactionStreamResponse<LockResult> responseOk = new TransactionStreamResponse<>(lockResultOk, null, TransactionStream.EMPTY, ResourceReleaser.NO_OP);
whenMasterAcquireShared().thenReturn(responseOk);
whenMasterAcquireExclusive().thenReturn(responseOk);
client = new SlaveLocksClient(master, local, lockManager, mock(RequestContextFactory.class), availabilityGuard, logProvider);
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class HighAvailabilityModeSwitcherTest method shouldTakeNoActionIfSwitchingToSlaveForItselfAsMaster.
@Test
public void shouldTakeNoActionIfSwitchingToSlaveForItselfAsMaster() throws Throwable {
// Given
// A HAMS
SwitchToSlaveCopyThenBranch switchToSlave = mock(SwitchToSlaveCopyThenBranch.class);
AssertableLogProvider logProvider = new AssertableLogProvider();
SimpleLogService logService = new SimpleLogService(NullLogProvider.getInstance(), logProvider);
HighAvailabilityModeSwitcher toTest = new HighAvailabilityModeSwitcher(switchToSlave, mock(SwitchToMaster.class), mock(Election.class), mock(ClusterMemberAvailability.class), mock(ClusterClient.class), storeSupplierMock(), new InstanceId(2), new ComponentSwitcherContainer(), neoStoreDataSourceSupplierMock(), logService);
// That is properly started
toTest.init();
toTest.start();
/*
* This is the URI at which we are registered as server - includes our own id, but we don't necessarily listen
* there
*/
URI serverHaUri = URI.create("ha://server2?serverId=2");
toTest.listeningAt(serverHaUri);
// When
// The HAMS tries to switch to slave for a master that is itself
toTest.masterIsAvailable(new HighAvailabilityMemberChangeEvent(PENDING, TO_SLAVE, new InstanceId(2), serverHaUri));
// Then
// No switching to slave must happen
verifyZeroInteractions(switchToSlave);
// And an error must be logged
logProvider.assertAtLeastOnce(inLog(HighAvailabilityModeSwitcher.class).error("I (ha://server2?serverId=2) tried to switch to " + "slave for myself as master (ha://server2?serverId=2)"));
}
Aggregations