35
35
import org .elasticsearch .common .settings .ImmutableSettings ;
36
36
import org .elasticsearch .common .settings .Settings ;
37
37
import org .elasticsearch .common .util .concurrent .UncategorizedExecutionException ;
38
+ import org .elasticsearch .plugins .PluginsService ;
38
39
import org .elasticsearch .repositories .RepositoryMissingException ;
39
40
import org .elasticsearch .snapshots .SnapshotState ;
40
41
import org .elasticsearch .test .ElasticsearchIntegrationTest .ClusterScope ;
53
54
/**
54
55
*/
55
56
@ AwsTest
56
- @ ClusterScope (scope = Scope .SUITE , numDataNodes = 2 )
57
+ @ ClusterScope (scope = Scope .SUITE , numDataNodes = 2 , numClientNodes = 0 , transportClientRatio = 0.0 )
57
58
public class S3SnapshotRestoreTest extends AbstractAwsTest {
58
59
59
60
@ Override
@@ -64,6 +65,7 @@ public Settings indexSettings() {
64
65
.put (MockDirectoryHelper .RANDOM_PREVENT_DOUBLE_WRITE , false )
65
66
.put (MockDirectoryHelper .RANDOM_NO_DELETE_OPEN_FILE , false )
66
67
.put ("cloud.enabled" , true )
68
+ .put ("plugins." + PluginsService .LOAD_PLUGIN_FROM_CLASSPATH , true )
67
69
.build ();
68
70
}
69
71
@@ -85,7 +87,7 @@ public final void wipeAfter() {
85
87
@ Test
86
88
public void testSimpleWorkflow () {
87
89
Client client = client ();
88
- logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , cluster ().getInstance (Settings .class ).get ("repositories.s3.bucket" ), basePath );
90
+ logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , internalCluster ().getInstance (Settings .class ).get ("repositories.s3.bucket" ), basePath );
89
91
PutRepositoryResponse putRepositoryResponse = client .admin ().cluster ().preparePutRepository ("test-repo" )
90
92
.setType ("s3" ).setSettings (ImmutableSettings .settingsBuilder ()
91
93
.put ("base_path" , basePath )
@@ -157,7 +159,7 @@ public void testSimpleWorkflow() {
157
159
@ Test
158
160
public void testEncryption () {
159
161
Client client = client ();
160
- logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , cluster ().getInstance (Settings .class ).get ("repositories.s3.bucket" ), basePath );
162
+ logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , internalCluster ().getInstance (Settings .class ).get ("repositories.s3.bucket" ), basePath );
161
163
PutRepositoryResponse putRepositoryResponse = client .admin ().cluster ().preparePutRepository ("test-repo" )
162
164
.setType ("s3" ).setSettings (ImmutableSettings .settingsBuilder ()
163
165
.put ("base_path" , basePath )
@@ -187,9 +189,9 @@ public void testEncryption() {
187
189
188
190
assertThat (client .admin ().cluster ().prepareGetSnapshots ("test-repo" ).setSnapshots ("test-snap" ).get ().getSnapshots ().get (0 ).state (), equalTo (SnapshotState .SUCCESS ));
189
191
190
- Settings settings = cluster ().getInstance (Settings .class );
192
+ Settings settings = internalCluster ().getInstance (Settings .class );
191
193
Settings bucket = settings .getByPrefix ("repositories.s3." );
192
- AmazonS3 s3Client = cluster ().getInstance (AwsS3Service .class ).client (
194
+ AmazonS3 s3Client = internalCluster ().getInstance (AwsS3Service .class ).client (
193
195
bucket .get ("region" , settings .get ("repositories.s3.region" )),
194
196
bucket .get ("access_key" , settings .get ("cloud.aws.access_key" )),
195
197
bucket .get ("secret_key" , settings .get ("cloud.aws.secret_key" )));
@@ -248,7 +250,7 @@ public void testEncryption() {
248
250
@ Test (expected = UncategorizedExecutionException .class )
249
251
public void assertRepositoryWithCustomCredentialsIsNotAccessibleByDefaultCredentials () {
250
252
Client client = client ();
251
- Settings bucketSettings = cluster ().getInstance (Settings .class ).getByPrefix ("repositories.s3.private-bucket." );
253
+ Settings bucketSettings = internalCluster ().getInstance (Settings .class ).getByPrefix ("repositories.s3.private-bucket." );
252
254
logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , bucketSettings .get ("bucket" ), basePath );
253
255
PutRepositoryResponse putRepositoryResponse = client .admin ().cluster ().preparePutRepository ("test-repo" )
254
256
.setType ("s3" ).setSettings (ImmutableSettings .settingsBuilder ()
@@ -263,7 +265,7 @@ public void assertRepositoryWithCustomCredentialsIsNotAccessibleByDefaultCredent
263
265
@ Test
264
266
public void testRepositoryWithCustomCredentials () {
265
267
Client client = client ();
266
- Settings bucketSettings = cluster ().getInstance (Settings .class ).getByPrefix ("repositories.s3.private-bucket." );
268
+ Settings bucketSettings = internalCluster ().getInstance (Settings .class ).getByPrefix ("repositories.s3.private-bucket." );
267
269
logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , bucketSettings .get ("bucket" ), basePath );
268
270
PutRepositoryResponse putRepositoryResponse = client .admin ().cluster ().preparePutRepository ("test-repo" )
269
271
.setType ("s3" ).setSettings (ImmutableSettings .settingsBuilder ()
@@ -285,7 +287,7 @@ public void testRepositoryWithCustomCredentials() {
285
287
@ Test (expected = UncategorizedExecutionException .class )
286
288
public void assertRepositoryInRemoteRegionIsRemote () {
287
289
Client client = client ();
288
- Settings bucketSettings = cluster ().getInstance (Settings .class ).getByPrefix ("repositories.s3.remote-bucket." );
290
+ Settings bucketSettings = internalCluster ().getInstance (Settings .class ).getByPrefix ("repositories.s3.remote-bucket." );
289
291
logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , bucketSettings .get ("bucket" ), basePath );
290
292
PutRepositoryResponse putRepositoryResponse = client .admin ().cluster ().preparePutRepository ("test-repo" )
291
293
.setType ("s3" ).setSettings (ImmutableSettings .settingsBuilder ()
@@ -302,7 +304,7 @@ public void assertRepositoryInRemoteRegionIsRemote() {
302
304
@ Test
303
305
public void testRepositoryInRemoteRegion () {
304
306
Client client = client ();
305
- Settings settings = cluster ().getInstance (Settings .class );
307
+ Settings settings = internalCluster ().getInstance (Settings .class );
306
308
Settings bucketSettings = settings .getByPrefix ("repositories.s3.remote-bucket." );
307
309
logger .info ("--> creating s3 repository with bucket[{}] and path [{}]" , bucketSettings .get ("bucket" ), basePath );
308
310
PutRepositoryResponse putRepositoryResponse = client .admin ().cluster ().preparePutRepository ("test-repo" )
@@ -374,7 +376,7 @@ public static void wipeRepositories(String... repositories) {
374
376
* Deletes content of the repository files in the bucket
375
377
*/
376
378
public void cleanRepositoryFiles (String basePath ) {
377
- Settings settings = cluster ().getInstance (Settings .class );
379
+ Settings settings = internalCluster ().getInstance (Settings .class );
378
380
Settings [] buckets = {
379
381
settings .getByPrefix ("repositories.s3." ),
380
382
settings .getByPrefix ("repositories.s3.private-bucket." ),
@@ -385,7 +387,7 @@ public void cleanRepositoryFiles(String basePath) {
385
387
String accessKey = bucket .get ("access_key" , settings .get ("cloud.aws.access_key" ));
386
388
String secretKey = bucket .get ("secret_key" , settings .get ("cloud.aws.secret_key" ));
387
389
String bucketName = bucket .get ("bucket" );
388
- AmazonS3 client = cluster ().getInstance (AwsS3Service .class ).client (region , accessKey , secretKey );
390
+ AmazonS3 client = internalCluster ().getInstance (AwsS3Service .class ).client (region , accessKey , secretKey );
389
391
try {
390
392
ObjectListing prevListing = null ;
391
393
//From http://docs.amazonwebservices.com/AmazonS3/latest/dev/DeletingMultipleObjectsUsingJava.html
0 commit comments