HDDS-1332. Add some logging for flaky test testStartStopDatanodeStateMachine. Contributed by Arpit Agarwal. (#649)

This commit is contained in:
Arpit Agarwal 2019-03-27 08:23:30 -07:00 committed by Nanda kumar
parent b2269581f7
commit b4ed81c4e6
2 changed files with 7 additions and 3 deletions

View File

@ -397,7 +397,6 @@ public class DatanodeStateMachine implements Closeable {
@VisibleForTesting @VisibleForTesting
public boolean isDaemonStopped() { public boolean isDaemonStopped() {
return this.executorService.isShutdown() return this.executorService.isShutdown()
&& this.getContext().getExecutionCount() == 0
&& this.getContext().getState() == DatanodeStates.SHUTDOWN; && this.getContext().getState() == DatanodeStates.SHUTDOWN;
} }

View File

@ -16,6 +16,7 @@
*/ */
package org.apache.hadoop.ozone.container.common; package org.apache.hadoop.ozone.container.common;
import com.google.common.base.Supplier;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -165,8 +166,12 @@ public class TestDatanodeStateMachine {
stateMachine.startDaemon(); stateMachine.startDaemon();
SCMConnectionManager connectionManager = SCMConnectionManager connectionManager =
stateMachine.getConnectionManager(); stateMachine.getConnectionManager();
GenericTestUtils.waitFor(() -> connectionManager.getValues().size() == 1, GenericTestUtils.waitFor(
1000, 30000); () -> {
LOG.info("connectionManager.getValues().size() is {}",
connectionManager.getValues().size());
return connectionManager.getValues().size() == 1;
}, 1000, 30000);
stateMachine.stopDaemon(); stateMachine.stopDaemon();
assertTrue(stateMachine.isDaemonStopped()); assertTrue(stateMachine.isDaemonStopped());