Skip to content

Commit

Permalink
Fix unit tests and some bugs introduced by #128
Browse files Browse the repository at this point in the history
Closes #119, #147
  • Loading branch information
tlrx committed Nov 26, 2014
1 parent 61a307f commit d680b94
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ The following settings are supported:
* `bucket`: The name of the bucket to be used for snapshots. (Mandatory)
* `region`: The region where bucket is located. Defaults to US Standard
* `endpoint`: The endpoint to the S3 API. Defaults to AWS's default S3 endpoint. Note that setting a region overrides the endpoint setting.
* `protocol`: The protocol to use (`http` or `https`). Defaults to `https`.
* `protocol`: The protocol to use (`http` or `https`). Defaults to value of `cloud.aws.protocol` or `cloud.aws.s3.protocol`.
* `base_path`: Specifies the path within bucket to repository data. Defaults to root directory.
* `access_key`: The access key to use for authentication. Defaults to value of `cloud.aws.access_key`.
* `secret_key`: The secret key to use for authentication. Defaults to value of `cloud.aws.secret_key`.
Expand Down Expand Up @@ -266,8 +266,10 @@ The bucket needs to exist to register a repository for snapshots. If you did not

### Using other S3 endpoint

If you are using any S3 api compatible service, you can set the endpoint you want to use by setting `cloud.aws.s3.endpoint`
to your URL provider.
If you are using any S3 api compatible service, you can set a global endpoint by setting `cloud.aws.s3.endpoint`
to your URL provider. Note that this setting will be used for all S3 repositories.

Different `endpoint`, `region` and `protocol` settings can be set on a per-repository basis (see [S3 Repository](#s3-repository) section for detail).


## Testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public synchronized AmazonS3 client() {
String account = componentSettings.get("access_key", settings.get("cloud.account"));
String key = componentSettings.get("secret_key", settings.get("cloud.key"));

return getClient(endpoint, "https", account, key, null);
return getClient(endpoint, null, account, key, null);
}

@Override
Expand Down Expand Up @@ -94,7 +94,8 @@ private synchronized AmazonS3 getClient(String endpoint, String protocol, String

ClientConfiguration clientConfiguration = new ClientConfiguration();
if (protocol == null) {
protocol = "https";
protocol = componentSettings.get("protocol", "https").toLowerCase();
protocol = componentSettings.get("s3.protocol", protocol).toLowerCase();
}

if ("http".equals(protocol)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ public S3Repository(RepositoryName name, RepositorySettings repositorySettings,
}

String endpoint = repositorySettings.settings().get("endpoint", componentSettings.get("endpoint"));
String protocol = componentSettings.get("protocol", "https").toLowerCase();
protocol = componentSettings.get("s3.protocol", protocol).toLowerCase();
protocol = repositorySettings.settings().get("protocol", protocol);
String protocol = repositorySettings.settings().get("protocol", componentSettings.get("protocol"));

String region = repositorySettings.settings().get("region", componentSettings.get("region"));
if (region == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,11 @@ public void testRepositoryWithCustomEndpointProtocol() {
logger.info("--> creating s3 repostoriy with endpoint [{}], bucket[{}] and path [{}]", bucketSettings.get("endpoint"), bucketSettings.get("bucket"), basePath);
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
.setType("s3").setSettings(ImmutableSettings.settingsBuilder()
.put("protocol", bucketSettings.get("protocol"))
.put("bucket", bucketSettings.get("bucket"))
.put("endpoint", bucketSettings.get("endpoint"))
.put("access_key", bucketSettings.get("access_key"))
.put("secret_key", bucketSettings.get("secret_key"))
.put("base_path", basePath)
).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
assertRepositoryIsOperational(client, "test-repo");
Expand Down Expand Up @@ -445,7 +446,8 @@ public void cleanRepositoryFiles(String basePath) {
Settings[] buckets = {
settings.getByPrefix("repositories.s3."),
settings.getByPrefix("repositories.s3.private-bucket."),
settings.getByPrefix("repositories.s3.remote-bucket.")
settings.getByPrefix("repositories.s3.remote-bucket."),
settings.getByPrefix("repositories.s3.external-bucket.")
};
for (Settings bucket : buckets) {
String endpoint = bucket.get("endpoint", settings.get("repositories.s3.endpoint"));
Expand Down

0 comments on commit d680b94

Please sign in to comment.