Skip to content

Commit d680b94

Browse files
committed
Fix unit tests and some bugs introduced by #128
Closes #119, #147
1 parent 61a307f commit d680b94

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ The following settings are supported:
164164
* `bucket`: The name of the bucket to be used for snapshots. (Mandatory)
165165
* `region`: The region where bucket is located. Defaults to US Standard
166166
* `endpoint`: The endpoint to the S3 API. Defaults to AWS's default S3 endpoint. Note that setting a region overrides the endpoint setting.
167-
* `protocol`: The protocol to use (`http` or `https`). Defaults to `https`.
167+
* `protocol`: The protocol to use (`http` or `https`). Defaults to value of `cloud.aws.protocol` or `cloud.aws.s3.protocol`.
168168
* `base_path`: Specifies the path within bucket to repository data. Defaults to root directory.
169169
* `access_key`: The access key to use for authentication. Defaults to value of `cloud.aws.access_key`.
170170
* `secret_key`: The secret key to use for authentication. Defaults to value of `cloud.aws.secret_key`.
@@ -266,8 +266,10 @@ The bucket needs to exist to register a repository for snapshots. If you did not
266266

267267
### Using other S3 endpoint
268268

269-
If you are using any S3 api compatible service, you can set the endpoint you want to use by setting `cloud.aws.s3.endpoint`
270-
to your URL provider.
269+
If you are using any S3 api compatible service, you can set a global endpoint by setting `cloud.aws.s3.endpoint`
270+
to your URL provider. Note that this setting will be used for all S3 repositories.
271+
272+
Different `endpoint`, `region` and `protocol` settings can be set on a per-repository basis (see [S3 Repository](#s3-repository) section for detail).
271273

272274

273275
## Testing

src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public synchronized AmazonS3 client() {
6060
String account = componentSettings.get("access_key", settings.get("cloud.account"));
6161
String key = componentSettings.get("secret_key", settings.get("cloud.key"));
6262

63-
return getClient(endpoint, "https", account, key, null);
63+
return getClient(endpoint, null, account, key, null);
6464
}
6565

6666
@Override
@@ -94,7 +94,8 @@ private synchronized AmazonS3 getClient(String endpoint, String protocol, String
9494

9595
ClientConfiguration clientConfiguration = new ClientConfiguration();
9696
if (protocol == null) {
97-
protocol = "https";
97+
protocol = componentSettings.get("protocol", "https").toLowerCase();
98+
protocol = componentSettings.get("s3.protocol", protocol).toLowerCase();
9899
}
99100

100101
if ("http".equals(protocol)) {

src/main/java/org/elasticsearch/repositories/s3/S3Repository.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ public S3Repository(RepositoryName name, RepositorySettings repositorySettings,
8080
}
8181

8282
String endpoint = repositorySettings.settings().get("endpoint", componentSettings.get("endpoint"));
83-
String protocol = componentSettings.get("protocol", "https").toLowerCase();
84-
protocol = componentSettings.get("s3.protocol", protocol).toLowerCase();
85-
protocol = repositorySettings.settings().get("protocol", protocol);
83+
String protocol = repositorySettings.settings().get("protocol", componentSettings.get("protocol"));
8684

8785
String region = repositorySettings.settings().get("region", componentSettings.get("region"));
8886
if (region == null) {

src/test/java/org/elasticsearch/repositories/s3/AbstractS3SnapshotRestoreTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,11 @@ public void testRepositoryWithCustomEndpointProtocol() {
287287
logger.info("--> creating s3 repostoriy with endpoint [{}], bucket[{}] and path [{}]", bucketSettings.get("endpoint"), bucketSettings.get("bucket"), basePath);
288288
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
289289
.setType("s3").setSettings(ImmutableSettings.settingsBuilder()
290-
.put("protocol", bucketSettings.get("protocol"))
290+
.put("bucket", bucketSettings.get("bucket"))
291291
.put("endpoint", bucketSettings.get("endpoint"))
292292
.put("access_key", bucketSettings.get("access_key"))
293293
.put("secret_key", bucketSettings.get("secret_key"))
294+
.put("base_path", basePath)
294295
).get();
295296
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
296297
assertRepositoryIsOperational(client, "test-repo");
@@ -445,7 +446,8 @@ public void cleanRepositoryFiles(String basePath) {
445446
Settings[] buckets = {
446447
settings.getByPrefix("repositories.s3."),
447448
settings.getByPrefix("repositories.s3.private-bucket."),
448-
settings.getByPrefix("repositories.s3.remote-bucket.")
449+
settings.getByPrefix("repositories.s3.remote-bucket."),
450+
settings.getByPrefix("repositories.s3.external-bucket.")
449451
};
450452
for (Settings bucket : buckets) {
451453
String endpoint = bucket.get("endpoint", settings.get("repositories.s3.endpoint"));

0 commit comments

Comments
 (0)