Skip to content

Commit 776677f

Browse files
committed
Tests: update to Lucene 4.9.0
Closes #107. (cherry picked from commit c3c9a44)
1 parent 11f4e9c commit 776677f

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Replace all occurrences of `access_key`, `secret_key`, `bucket` and `region` wit
242242
To run test:
243243

244244
```sh
245-
mvn -Dtests.aws=true -Des.config=/path/to/config/file/elasticsearch.yml clean test
245+
mvn -Dtests.aws=true -Dtests.config=/path/to/config/file/elasticsearch.yml clean test
246246
```
247247

248248

pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<properties>
3535
<elasticsearch.version>2.0.0-SNAPSHOT</elasticsearch.version>
36-
<lucene.version>4.8.1</lucene.version>
36+
<lucene.version>4.9.0</lucene.version>
3737
<tests.output>onerror</tests.output>
3838
<tests.jvms>1</tests.jvms>
3939
<tests.shuffle>true</tests.shuffle>
@@ -227,6 +227,7 @@
227227
<tests.weekly>${tests.weekly}</tests.weekly>
228228
<tests.slow>${tests.slow}</tests.slow>
229229
<tests.aws>${tests.aws}</tests.aws>
230+
<tests.config>${tests.config}</tests.config>
230231
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
231232
<tests.slow>${tests.slow}</tests.slow>
232233
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>

src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void run() {
5050
try {
5151
ObjectMetadata md = new ObjectMetadata();
5252
if (blobStore.serverSideEncryption()) {
53-
md.setServerSideEncryption(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
53+
md.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
5454
}
5555
md.setContentLength(sizeInBytes);
5656
blobStore.client().putObject(blobStore.bucket(), buildKey(blobName), is, md);

src/test/java/org/elasticsearch/cloud/aws/AbstractAwsTest.java

+21-20
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
package org.elasticsearch.cloud.aws;
2121

2222
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
23+
import org.elasticsearch.common.Strings;
2324
import org.elasticsearch.common.settings.ImmutableSettings;
2425
import org.elasticsearch.common.settings.Settings;
26+
import org.elasticsearch.env.Environment;
27+
import org.elasticsearch.env.FailedToResolveConfigException;
2528
import org.elasticsearch.plugins.PluginsService;
2629
import org.elasticsearch.test.ElasticsearchIntegrationTest;
2730

@@ -37,22 +40,7 @@ public abstract class AbstractAwsTest extends ElasticsearchIntegrationTest {
3740

3841
/**
3942
* Annotation for tests that require AWS to run. AWS tests are disabled by default.
40-
* <p/>
41-
* To enable test add -Dtests.aws=true -Des.config=/path/to/elasticsearch.yml
42-
* <p/>
43-
* The elasticsearch.yml file should contain the following keys
44-
* <pre>
45-
* cloud:
46-
* aws:
47-
* access_key: AKVAIQBF2RECL7FJWGJQ
48-
* secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
49-
* region: "us-west"
50-
*
51-
* repositories:
52-
* s3:
53-
* bucket: "bucket_name"
54-
*
55-
* </pre>
43+
* Look at README file for details on how to run tests
5644
*/
5745
@Documented
5846
@Inherited
@@ -67,12 +55,25 @@ public abstract class AbstractAwsTest extends ElasticsearchIntegrationTest {
6755

6856
@Override
6957
protected Settings nodeSettings(int nodeOrdinal) {
70-
return ImmutableSettings.builder()
58+
ImmutableSettings.Builder settings = ImmutableSettings.builder()
7159
.put(super.nodeSettings(nodeOrdinal))
7260
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
73-
.put( AwsModule.S3_SERVICE_TYPE_KEY, TestAwsS3Service.class)
61+
.put(AwsModule.S3_SERVICE_TYPE_KEY, TestAwsS3Service.class)
7462
.put("cloud.aws.test.random", randomInt())
75-
.put("cloud.aws.test.write_failures", 0.1)
76-
.build();
63+
.put("cloud.aws.test.write_failures", 0.1);
64+
65+
Environment environment = new Environment();
66+
67+
// if explicit, just load it and don't load from env
68+
try {
69+
if (Strings.hasText(System.getProperty("tests.config"))) {
70+
settings.loadFromUrl(environment.resolveConfig(System.getProperty("tests.config")));
71+
} else {
72+
fail("to run integration tests, you need to set -Dtest.aws=true and -Dtests.config=/path/to/elasticsearch.yml");
73+
}
74+
} catch (FailedToResolveConfigException exception) {
75+
fail("your test configuration file is incorrect: " + System.getProperty("tests.config"));
76+
}
77+
return settings.build();
7778
}
7879
}

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
import java.util.List;
4949
import java.util.ArrayList;
5050

51-
import static org.hamcrest.Matchers.equalTo;
52-
import static org.hamcrest.Matchers.greaterThan;
51+
import static org.hamcrest.Matchers.*;
5352

5453
/**
5554
*/
@@ -200,7 +199,7 @@ public void testEncryption() {
200199
logger.info("--> verify encryption for bucket [{}], prefix [{}]", bucketName, basePath);
201200
List<S3ObjectSummary> summaries = s3Client.listObjects(bucketName, basePath).getObjectSummaries();
202201
for (S3ObjectSummary summary : summaries) {
203-
assertThat(s3Client.getObjectMetadata(bucketName, summary.getKey()).getServerSideEncryption(), equalTo("AES256"));
202+
assertThat(s3Client.getObjectMetadata(bucketName, summary.getKey()).getSSEAlgorithm(), equalTo("AES256"));
204203
}
205204

206205
logger.info("--> delete some data");
@@ -387,6 +386,10 @@ public void cleanRepositoryFiles(String basePath) {
387386
String accessKey = bucket.get("access_key", settings.get("cloud.aws.access_key"));
388387
String secretKey = bucket.get("secret_key", settings.get("cloud.aws.secret_key"));
389388
String bucketName = bucket.get("bucket");
389+
390+
// We check that settings has been set in elasticsearch.yml integration test file
391+
// as described in README
392+
assertThat("Your settings in elasticsearch.yml are incorrects. Check README file.", bucketName, notNullValue());
390393
AmazonS3 client = internalCluster().getInstance(AwsS3Service.class).client(region, accessKey, secretKey);
391394
try {
392395
ObjectListing prevListing = null;

0 commit comments

Comments
 (0)