[TEST] add retries to MockRepository getRepositoryData to try to
diagnose a NotXContentException being thrown
This commit is contained in:
parent
a0c83c4511
commit
554a5e3039
|
@ -42,6 +42,7 @@ import org.elasticsearch.common.blobstore.BlobContainer;
|
|||
import org.elasticsearch.common.blobstore.BlobMetaData;
|
||||
import org.elasticsearch.common.blobstore.BlobPath;
|
||||
import org.elasticsearch.common.blobstore.BlobStore;
|
||||
import org.elasticsearch.common.compress.NotXContentException;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
|
@ -51,6 +52,7 @@ import org.elasticsearch.env.Environment;
|
|||
import org.elasticsearch.plugins.RepositoryPlugin;
|
||||
import org.elasticsearch.repositories.Repository;
|
||||
import org.elasticsearch.repositories.IndexId;
|
||||
import org.elasticsearch.repositories.RepositoryData;
|
||||
import org.elasticsearch.repositories.fs.FsRepository;
|
||||
import org.elasticsearch.snapshots.SnapshotId;
|
||||
|
||||
|
@ -162,6 +164,33 @@ public class MockRepository extends FsRepository {
|
|||
blockOnDataFiles = blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryData getRepositoryData() {
|
||||
final int numIterations = 5;
|
||||
int count = 0;
|
||||
NotXContentException ex = null;
|
||||
RepositoryData repositoryData = null;
|
||||
while (count < numIterations) {
|
||||
try {
|
||||
repositoryData = super.getRepositoryData();
|
||||
} catch (NotXContentException e) {
|
||||
ex = e;
|
||||
}
|
||||
if (repositoryData != null) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
if (ex != null) {
|
||||
throw ex;
|
||||
}
|
||||
return repositoryData;
|
||||
}
|
||||
|
||||
public void blockOnControlFiles(boolean blocked) {
|
||||
blockOnControlFiles = blocked;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue