19
19
20
20
package org .elasticsearch .snapshots ;
21
21
22
- import com .carrotsearch .randomizedtesting .annotations .Repeat ;
23
22
import org .apache .logging .log4j .LogManager ;
24
23
import org .apache .logging .log4j .Logger ;
25
24
import org .elasticsearch .Version ;
107
106
import org .elasticsearch .cluster .service .ClusterApplierService ;
108
107
import org .elasticsearch .cluster .service .ClusterService ;
109
108
import org .elasticsearch .cluster .service .MasterService ;
109
+ import org .elasticsearch .common .Nullable ;
110
110
import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
111
111
import org .elasticsearch .common .network .NetworkModule ;
112
112
import org .elasticsearch .common .settings .ClusterSettings ;
193
193
import static org .hamcrest .Matchers .hasSize ;
194
194
import static org .mockito .Mockito .mock ;
195
195
196
- @ Repeat (iterations = 5000 )
197
196
public class SnapshotResiliencyTests extends ESTestCase {
198
197
199
198
private DeterministicTaskQueue deterministicTaskQueue ;
@@ -203,16 +202,15 @@ public class SnapshotResiliencyTests extends ESTestCase {
203
202
private Path tempDir ;
204
203
205
204
/**
206
- * Whether to use eventually consistent blob store in tests.
205
+ * Context shared by all the node's {@link Repository} instances if the eventually consistent blobstore is to be used.
206
+ * {@code null} if not using the eventually consistent blobstore.
207
207
*/
208
- private boolean eventuallyConsistent ;
208
+ @ Nullable private MockEventuallyConsistentRepository . Context blobStoreContext ;
209
209
210
- private MockEventuallyConsistentRepository .Context blobStoreContext ;
211
210
@ Before
212
211
public void createServices () {
213
212
tempDir = createTempDir ();
214
- eventuallyConsistent = randomBoolean ();
215
- if (eventuallyConsistent ) {
213
+ if (randomBoolean ()) {
216
214
blobStoreContext = new MockEventuallyConsistentRepository .Context ();
217
215
}
218
216
deterministicTaskQueue =
@@ -1086,16 +1084,9 @@ searchTransportService, new SearchPhaseController(searchService::createReduceCon
1086
1084
client .initialize (actions , () -> clusterService .localNode ().getId (), transportService .getRemoteClusterService ());
1087
1085
}
1088
1086
1089
- private Repository .Factory getRepoFactory (final Environment environment ) {
1087
+ private Repository .Factory getRepoFactory (Environment environment ) {
1090
1088
// Run half the tests with the eventually consistent repository
1091
- if (eventuallyConsistent ) {
1092
- return metaData -> {
1093
- final Repository repository = new MockEventuallyConsistentRepository (
1094
- metaData , environment , xContentRegistry (), deterministicTaskQueue , blobStoreContext );
1095
- repository .start ();
1096
- return repository ;
1097
- };
1098
- } else {
1089
+ if (blobStoreContext == null ) {
1099
1090
return metaData -> {
1100
1091
final Repository repository = new FsRepository (metaData , environment , xContentRegistry (), threadPool ) {
1101
1092
@ Override
@@ -1106,6 +1097,13 @@ protected void assertSnapshotOrGenericThread() {
1106
1097
repository .start ();
1107
1098
return repository ;
1108
1099
};
1100
+ } else {
1101
+ return metaData -> {
1102
+ final Repository repository = new MockEventuallyConsistentRepository (
1103
+ metaData , environment , xContentRegistry (), deterministicTaskQueue , blobStoreContext );
1104
+ repository .start ();
1105
+ return repository ;
1106
+ };
1109
1107
}
1110
1108
}
1111
1109
public void restart () {
0 commit comments