-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add S3 integration tests for searchable snapshots #52263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tlrx
merged 3 commits into
elastic:feature/searchable-snapshots
from
tlrx:add-searchable-snapshots-integ-tests-for-s3
Feb 18, 2020
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...c/test/java/org/elasticsearch/xpack/searchablesnapshots/rest/FsSearchableSnapshotsIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.searchablesnapshots.rest; | ||
|
||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.unit.ByteSizeUnit; | ||
import org.elasticsearch.repositories.fs.FsRepository; | ||
import org.elasticsearch.xpack.searchablesnapshots.AbstractSearchableSnapshotsRestTestCase; | ||
|
||
public class FsSearchableSnapshotsIT extends AbstractSearchableSnapshotsRestTestCase { | ||
|
||
@Override | ||
protected String repositoryType() { | ||
return FsRepository.TYPE; | ||
} | ||
|
||
@Override | ||
protected Settings repositorySettings() { | ||
final Settings.Builder settings = Settings.builder(); | ||
settings.put("location", System.getProperty("tests.path.repo")); | ||
if (randomBoolean()) { | ||
settings.put("compress", randomBoolean()); | ||
} | ||
if (randomBoolean()) { | ||
settings.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES); | ||
} | ||
return settings.build(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE | ||
|
||
apply plugin: 'elasticsearch.standalone-rest-test' | ||
apply plugin: 'elasticsearch.rest-test' | ||
|
||
final Project fixture = project(':test:fixtures:s3-fixture') | ||
final Project repositoryPlugin = project(':plugins:repository-s3') | ||
|
||
dependencies { | ||
testCompile project(path: xpackModule('searchable-snapshots'), configuration: 'testArtifacts') | ||
testCompile repositoryPlugin | ||
} | ||
|
||
boolean useFixture = false | ||
String s3AccessKey = System.getenv("amazon_s3_access_key") | ||
String s3SecretKey = System.getenv("amazon_s3_secret_key") | ||
String s3Bucket = System.getenv("amazon_s3_bucket") | ||
String s3BasePath = System.getenv("amazon_s3_base_path") | ||
|
||
if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) { | ||
s3AccessKey = 'access_key' | ||
s3SecretKey = 'secret_key' | ||
s3Bucket = 'bucket' | ||
s3BasePath = 'base_path' | ||
useFixture = true | ||
|
||
} else if (!s3AccessKey || !s3SecretKey || !s3Bucket || !s3BasePath) { | ||
throw new IllegalArgumentException("not all options specified to run against external S3 service are present") | ||
} | ||
|
||
if (useFixture) { | ||
apply plugin: 'elasticsearch.test.fixtures' | ||
testFixtures.useFixture(fixture.path, 's3-fixture-other') | ||
} | ||
|
||
integTest { | ||
dependsOn repositoryPlugin.bundlePlugin | ||
runner { | ||
systemProperty 'test.s3.bucket', s3Bucket | ||
systemProperty 'test.s3.base_path', s3BasePath + "/searchable_snapshots_tests" | ||
} | ||
} | ||
|
||
testClusters.integTest { | ||
testDistribution = 'DEFAULT' | ||
plugin file(repositoryPlugin.bundlePlugin.archiveFile) | ||
|
||
keystore 's3.client.searchable_snapshots.access_key', s3AccessKey | ||
keystore 's3.client.searchable_snapshots.secret_key', s3SecretKey | ||
|
||
if (useFixture) { | ||
def fixtureAddress = { fixtureName -> | ||
assert useFixture: 'closure should not be used without a fixture' | ||
int ephemeralPort = fixture.postProcessFixture.ext."test.fixtures.${fixtureName}.tcp.80" | ||
assert ephemeralPort > 0 | ||
'127.0.0.1:' + ephemeralPort | ||
} | ||
|
||
setting 's3.client.searchable_snapshots.protocol', 'http' | ||
setting 's3.client.searchable_snapshots.endpoint', { "${-> fixtureAddress('s3-fixture-other')}" }, IGNORE_VALUE | ||
|
||
} else { | ||
println "Using an external service to test " + project.name | ||
} | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
...src/test/java/org/elasticsearch/xpack/searchablesnapshots/s3/S3SearchableSnapshotsIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.searchablesnapshots.s3; | ||
|
||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.xpack.searchablesnapshots.AbstractSearchableSnapshotsRestTestCase; | ||
|
||
import static org.hamcrest.Matchers.blankOrNullString; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
public class S3SearchableSnapshotsIT extends AbstractSearchableSnapshotsRestTestCase { | ||
|
||
@Override | ||
protected String repositoryType() { | ||
return "s3"; | ||
} | ||
|
||
@Override | ||
protected Settings repositorySettings() { | ||
final String bucket = System.getProperty("test.s3.bucket"); | ||
assertThat(bucket, not(blankOrNullString())); | ||
|
||
final String basePath = System.getProperty("test.s3.base_path"); | ||
assertThat(basePath, not(blankOrNullString())); | ||
|
||
return Settings.builder() | ||
.put("client", "searchable_snapshots") | ||
.put("bucket", bucket) | ||
.put("base_path", basePath) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps
s3-fixture-searchable-snapshots
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to not mention searchable snapshots in open source code, so I'll keep "other" if that's ok for you.