Use fixture to test the repository-gcs plugin#28788
Merged
tlrx merged 2 commits intoelastic:masterfrom Mar 9, 2018
Merged
Conversation
This commit adds a GoogleCloudStorageFixture that uses the logic of a GoogleCloudStorageTestServer (added in elastic#28576) to emulate a remote Google Cloud Storage service. By adding this fixture and a new integration test, we should be able to catch more bugs when upgrading the client library. In consequence the old REST test RepositoryGcsClientYamlTestSuiteIT has been removed. The GoogleCloudStorageTestServer has to be adapted a bit for batch requests. The fixture is started by the googleCloudStorageFixture task and a custom Service Account file is created and added to the Elasticsearch keystore for each test.
rjernst
approved these changes
Feb 26, 2018
plugins/repository-gcs/build.gradle
Outdated
| } | ||
|
|
||
| /** A service account file that points to the Google Cloud Storage service emulated by the fixture **/ | ||
| File serviceAccountFile = new File(project.buildDir, "/generated-resources/service_account_test.json") |
plugins/repository-gcs/build.gradle
Outdated
| ' "private_key": "-----BEGIN PRIVATE KEY-----\\n' + encodedKey + '\\n-----END PRIVATE KEY-----\\n",\n' + | ||
| ' "client_email": "integration_test@appspot.gserviceaccount.com",\n' + | ||
| ' "client_id": "123456789101112130594",\n' + | ||
| " \"auth_uri\": \"http://${ -> googleCloudStorageFixture.addressAndPort }/o/oauth2/auth\",\n" + |
Member
There was a problem hiding this comment.
I don't think the closures are necessary here, since setText takes String and thus these will immediately be resolved.
| import static org.apache.http.entity.ContentType.APPLICATION_JSON; | ||
| import static org.hamcrest.Matchers.containsString; | ||
|
|
||
| public class GoogleCloudStorageIT extends ESRestTestCase { |
Member
There was a problem hiding this comment.
Is there anything that prevents this from still being in a yaml test?
Member
Author
There was a problem hiding this comment.
Not really. I thought we reserved YAML tests to test the REST API.
I reverted this change and added back the yaml test in a more complete fashion.
| */ | ||
| GoogleCloudStorageTestServer(final String endpoint, final boolean prefixWithEndpoint) { | ||
| this.handlers = defaultHandlers(endpoint, prefixWithEndpoint, buckets); | ||
| GoogleCloudStorageTestServer(final String endpoint) { |
Member
There was a problem hiding this comment.
Long term (not in this PR) I think it would be good to move this into the fixture, and use a more pure unit testing mock for the service calls inside the unit tests.
Member
Author
|
Thanks @rjernst |
tlrx
added a commit
that referenced
this pull request
Mar 9, 2018
This commit adds a GoogleCloudStorageFixture that uses the logic of a GoogleCloudStorageTestServer (added in #28576) to emulate a remote Google Cloud Storage service. By adding this fixture and a more complete integration test, we should be able to catch more bugs when upgrading the client library. The fixture is started by the googleCloudStorageFixture task and a custom Service Account file is created and added to the Elasticsearch keystore for each test.
Member
Author
|
This change has been backported to 6.x in be8ae87 |
sebasjm
pushed a commit
to sebasjm/elasticsearch
that referenced
this pull request
Mar 10, 2018
This commit adds a GoogleCloudStorageFixture that uses the logic of a GoogleCloudStorageTestServer (added in elastic#28576) to emulate a remote Google Cloud Storage service. By adding this fixture and a more complete integration test, we should be able to catch more bugs when upgrading the client library. The fixture is started by the googleCloudStorageFixture task and a custom Service Account file is created and added to the Elasticsearch keystore for each test.
jasontedor
added a commit
to jasontedor/elasticsearch
that referenced
this pull request
Mar 12, 2018
* master: (28 commits) Maybe die before failing engine (elastic#28973) Remove special handling for _all in nodes info Remove Booleans use from XContent and ToXContent (elastic#28768) Update Gradle Testing Docs (elastic#28970) Make primary-replica resync failures less lenient (elastic#28534) Remove temporary file 10_basic.yml~ Use different pipeline id in test. (pipelines do not get removed between tests extending from ESIntegTestCase) Use fixture to test the repository-gcs plugin (elastic#28788) Use String.join() to describe a list of tasks (elastic#28941) Fixed incorrect test try-catch statement Plugins: Consolidate plugin and module loading code (elastic#28815) percolator: Take `matchAllDocs` and `verified` of the sub result into account when analyzing a function_score query. Build: Remove rest tests on archive distribution projects (elastic#28952) Remove FastStringReader in favor of vanilla StringReader (elastic#28944) Remove FastCharArrayReader and FastCharArrayWriter (elastic#28951) Continue registering pipelines after one pipeline parse failure. (elastic#28752) Build: Fix ability to ignore when no tests are run (elastic#28930) [rest-api-spec] update doc link for /_rank_eval Switch XContentBuilder from BytesStreamOutput to ByteArrayOutputStream (elastic#28945) Factor UnknownNamedObjectException into its own class (elastic#28931) ...
tlrx
added a commit
to tlrx/elasticsearch
that referenced
this pull request
Mar 29, 2018
This commit adds a new fixture that emulates a S3 service in order to improve the existing integration tests. This is very similar to what has been made for Google Cloud Storage in elastic#28788, and such tests would have helped a lot to catch bugs like elastic#22534. The AmazonS3Fixture is brittle and only implements the very necessary stuff for the S3 repository to work, but at least it works and can be adapted for specific tests needs.
tlrx
added a commit
that referenced
this pull request
Apr 3, 2018
This commit adds a new fixture that emulates a S3 service in order to improve the existing integration tests. This is very similar to what has been made for Google Cloud Storage in #28788, and such tests would have helped a lot to catch bugs like #22534. The AmazonS3Fixture is brittle and only implements the very necessary stuff for the S3 repository to work, but at least it works and can be adapted for specific tests needs.
3 tasks
tlrx
added a commit
to tlrx/elasticsearch
that referenced
this pull request
Apr 6, 2018
This commit adds a new fixture that emulates an Azure Storage service in order to improve the existing integration tests. This is very similar to what has been made for Google Cloud Storage in elastic#28788 and for Amazon S3 in elastic#29296, and it would have helped a lot to catch bugs like elastic#22534.
tlrx
added a commit
that referenced
this pull request
Apr 30, 2018
Similarly to what has been done in for the repository-s3 plugin, this commit moves the fixture test into a dedicated repository-gcs/qa/google-cloud-storage project. It also exposes some environment variables which allows to execute the integration tests against the real Google Cloud Storage service. When the environment variables are not defined, the integration tests are executed using the fixture added in #28788. Related to #29349.
tlrx
added a commit
that referenced
this pull request
Apr 30, 2018
Similarly to what has been done in for the repository-s3 plugin, this commit moves the fixture test into a dedicated repository-gcs/qa/google-cloud-storage project. It also exposes some environment variables which allows to execute the integration tests against the real Google Cloud Storage service. When the environment variables are not defined, the integration tests are executed using the fixture added in #28788. Related to #29349.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit adds a
GoogleCloudStorageFixturethat uses the logic of aGoogleCloudStorageTestServer(added in #28576) to emulate a remote Google Cloud Storage service.By adding this fixture and a new integration test, we should be able to catch more bugs when upgrading the client library. In consequence the old REST test
RepositoryGcsClientYamlTestSuiteIThas been removed. Sadly theGoogleCloudStorageTestServerhas to be adapted for a better handling of batch requests. The fixture is started by thegoogleCloudStorageFixturetask and a custom Service Account file is created and added to the Elasticsearch keystore before the integration test.The fixture resides in the repository-gcs plugin project.