/** * Starts a corfu server and increments the epoch from 0 to 1. * The server is then reset and the new layout fetch is expected to return a layout with * epoch 0 as all state should have been cleared. * * @throws Exception */ @Test public void resetTest() throws Exception { final int PORT_0 = 9000; Process corfuServer = runPersistentServer(corfuSingleNodeHost, PORT_0, true); CorfuRuntime corfuRuntime = createDefaultRuntime(); incrementClusterEpoch(corfuRuntime); corfuRuntime.getLayoutView().getRuntimeLayout().getBaseClient("localhost:9000") .reset().get(); corfuRuntime = createDefaultRuntime(); // The shutdown and reset can take an unknown amount of time and there is a chance that the // newer runtime may also connect to the older corfu server (before reset). // Hence the while loop. for (int i = 0; i < PARAMETERS.NUM_ITERATIONS_MODERATE; i++) { if (corfuRuntime.getLayoutView().getLayout().getEpoch() == 0L) { break; } Thread.sleep(PARAMETERS.TIMEOUT_SHORT.toMillis()); corfuRuntime = createDefaultRuntime(); } assertThat(corfuRuntime.getLayoutView().getLayout().getEpoch()).isEqualTo(0L); assertThat(shutdownCorfuServer(corfuServer)).isTrue(); }