From 776677f7e23acf71aec59a2a4d7b6163d4034c07 Mon Sep 17 00:00:00 2001 From: David Pilato Date: Wed, 30 Jul 2014 13:39:07 +0200 Subject: [PATCH] Tests: update to Lucene 4.9.0 Closes #107. (cherry picked from commit c3c9a44) --- README.md | 2 +- pom.xml | 3 +- .../blobstore/S3ImmutableBlobContainer.java | 2 +- .../cloud/aws/AbstractAwsTest.java | 41 ++++++++++--------- .../s3/S3SnapshotRestoreTest.java | 9 ++-- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d528d37a364..96deb9a872f 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ Replace all occurrences of `access_key`, `secret_key`, `bucket` and `region` wit To run test: ```sh -mvn -Dtests.aws=true -Des.config=/path/to/config/file/elasticsearch.yml clean test +mvn -Dtests.aws=true -Dtests.config=/path/to/config/file/elasticsearch.yml clean test ``` diff --git a/pom.xml b/pom.xml index 6ed6245b5f9..433c3ea5941 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ 2.0.0-SNAPSHOT - 4.8.1 + 4.9.0 onerror 1 true @@ -227,6 +227,7 @@ ${tests.weekly} ${tests.slow} ${tests.aws} + ${tests.config} ${tests.awaitsfix} ${tests.slow} ${tests.timeoutSuite} diff --git a/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java b/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java index 9ea97bd56f9..b011e72a98b 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java +++ b/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java @@ -50,7 +50,7 @@ public class S3ImmutableBlobContainer extends AbstractS3BlobContainer implements try { ObjectMetadata md = new ObjectMetadata(); if (blobStore.serverSideEncryption()) { - md.setServerSideEncryption(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); + md.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } md.setContentLength(sizeInBytes); blobStore.client().putObject(blobStore.bucket(), buildKey(blobName), is, md); diff --git a/src/test/java/org/elasticsearch/cloud/aws/AbstractAwsTest.java b/src/test/java/org/elasticsearch/cloud/aws/AbstractAwsTest.java index 98c794612ce..3ea6470cb58 100644 --- a/src/test/java/org/elasticsearch/cloud/aws/AbstractAwsTest.java +++ b/src/test/java/org/elasticsearch/cloud/aws/AbstractAwsTest.java @@ -20,8 +20,11 @@ package org.elasticsearch.cloud.aws; import com.carrotsearch.randomizedtesting.annotations.TestGroup; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.env.FailedToResolveConfigException; import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.test.ElasticsearchIntegrationTest; @@ -37,22 +40,7 @@ public abstract class AbstractAwsTest extends ElasticsearchIntegrationTest { /** * Annotation for tests that require AWS to run. AWS tests are disabled by default. - *

- * To enable test add -Dtests.aws=true -Des.config=/path/to/elasticsearch.yml - *

- * The elasticsearch.yml file should contain the following keys - *

-     * cloud:
-     *      aws:
-     *          access_key: AKVAIQBF2RECL7FJWGJQ
-     *          secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
-     *          region: "us-west"
-     *
-     * repositories:
-     *      s3:
-     *          bucket: "bucket_name"
-     *
-     * 
+ * Look at README file for details on how to run tests */ @Documented @Inherited @@ -67,12 +55,25 @@ public abstract class AbstractAwsTest extends ElasticsearchIntegrationTest { @Override protected Settings nodeSettings(int nodeOrdinal) { - return ImmutableSettings.builder() + ImmutableSettings.Builder settings = ImmutableSettings.builder() .put(super.nodeSettings(nodeOrdinal)) .put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true) - .put( AwsModule.S3_SERVICE_TYPE_KEY, TestAwsS3Service.class) + .put(AwsModule.S3_SERVICE_TYPE_KEY, TestAwsS3Service.class) .put("cloud.aws.test.random", randomInt()) - .put("cloud.aws.test.write_failures", 0.1) - .build(); + .put("cloud.aws.test.write_failures", 0.1); + + Environment environment = new Environment(); + + // if explicit, just load it and don't load from env + try { + if (Strings.hasText(System.getProperty("tests.config"))) { + settings.loadFromUrl(environment.resolveConfig(System.getProperty("tests.config"))); + } else { + fail("to run integration tests, you need to set -Dtest.aws=true and -Dtests.config=/path/to/elasticsearch.yml"); + } + } catch (FailedToResolveConfigException exception) { + fail("your test configuration file is incorrect: " + System.getProperty("tests.config")); + } + return settings.build(); } } diff --git a/src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreTest.java b/src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreTest.java index 3988c3dcf39..8acd9398acb 100644 --- a/src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreTest.java +++ b/src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreTest.java @@ -48,8 +48,7 @@ import org.junit.Test; import java.util.List; import java.util.ArrayList; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.*; /** */ @@ -200,7 +199,7 @@ public class S3SnapshotRestoreTest extends AbstractAwsTest { logger.info("--> verify encryption for bucket [{}], prefix [{}]", bucketName, basePath); List summaries = s3Client.listObjects(bucketName, basePath).getObjectSummaries(); for (S3ObjectSummary summary : summaries) { - assertThat(s3Client.getObjectMetadata(bucketName, summary.getKey()).getServerSideEncryption(), equalTo("AES256")); + assertThat(s3Client.getObjectMetadata(bucketName, summary.getKey()).getSSEAlgorithm(), equalTo("AES256")); } logger.info("--> delete some data"); @@ -387,6 +386,10 @@ public class S3SnapshotRestoreTest extends AbstractAwsTest { String accessKey = bucket.get("access_key", settings.get("cloud.aws.access_key")); String secretKey = bucket.get("secret_key", settings.get("cloud.aws.secret_key")); String bucketName = bucket.get("bucket"); + + // We check that settings has been set in elasticsearch.yml integration test file + // as described in README + assertThat("Your settings in elasticsearch.yml are incorrects. Check README file.", bucketName, notNullValue()); AmazonS3 client = internalCluster().getInstance(AwsS3Service.class).client(region, accessKey, secretKey); try { ObjectListing prevListing = null;