[TEST] MockRepository should also unblock repositories that are not blocked yet

This commit is contained in:
Yannick Welsch 2016-03-13 14:06:46 +01:00
parent 22ee910f43
commit 625695a92a
3 changed files with 12 additions and 14 deletions

View File

@ -149,15 +149,15 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase {
} }
} }
public void waitForBlockOnAllDataNodes(String repository, TimeValue timeout) throws InterruptedException { public void waitForBlockOnAnyDataNode(String repository, TimeValue timeout) throws InterruptedException {
if (false == awaitBusy(() -> { if (false == awaitBusy(() -> {
for(RepositoriesService repositoriesService : internalCluster().getDataNodeInstances(RepositoriesService.class)) { for(RepositoriesService repositoriesService : internalCluster().getDataNodeInstances(RepositoriesService.class)) {
MockRepository mockRepository = (MockRepository) repositoriesService.repository(repository); MockRepository mockRepository = (MockRepository) repositoriesService.repository(repository);
if (mockRepository.blocked() == false) { if (mockRepository.blocked()) {
return false; return true;
} }
} }
return true; return false;
}, timeout.millis(), TimeUnit.MILLISECONDS)) { }, timeout.millis(), TimeUnit.MILLISECONDS)) {
fail("Timeout waiting for repository block on any data node!!!"); fail("Timeout waiting for repository block on any data node!!!");
} }

View File

@ -1860,7 +1860,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
if (initBlocking) { if (initBlocking) {
waitForBlock(internalCluster().getMasterName(), "test-repo", TimeValue.timeValueMinutes(1)); waitForBlock(internalCluster().getMasterName(), "test-repo", TimeValue.timeValueMinutes(1));
} else { } else {
waitForBlockOnAllDataNodes("test-repo", TimeValue.timeValueMinutes(1)); waitForBlockOnAnyDataNode("test-repo", TimeValue.timeValueMinutes(1));
} }
try { try {
if (allowPartial) { if (allowPartial) {
@ -1957,7 +1957,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
.execute(); .execute();
logger.info("--> waiting for block to kick in"); logger.info("--> waiting for block to kick in");
waitForBlockOnAllDataNodes("test-repo", TimeValue.timeValueMinutes(1)); waitForBlockOnAnyDataNode("test-repo", TimeValue.timeValueMinutes(1));
logger.info("--> close index while restore is running"); logger.info("--> close index while restore is running");
try { try {

View File

@ -176,14 +176,12 @@ public class MockRepository extends FsRepository {
} }
public synchronized void unblockExecution() { public synchronized void unblockExecution() {
if (blocked) { blocked = false;
blocked = false; // Clean blocking flags, so we wouldn't try to block again
// Clean blocking flags, so we wouldn't try to block again blockOnDataFiles = false;
blockOnDataFiles = false; blockOnControlFiles = false;
blockOnControlFiles = false; blockOnInitialization = false;
blockOnInitialization = false; this.notifyAll();
this.notifyAll();
}
} }
public boolean blocked() { public boolean blocked() {