-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move repository-azure fixture test to QA project (#30253)
Similarly to what has been done in for the repository-s3 plugin, this pull request moves the fixture test into a dedicated repository-azure/qa/microsoft-azure-storage project. It also exposes some environment variables which allows to execute the integration tests against the real Azure Storage service. When the environment variables are not defined, the integration tests are executed using the fixture added in #29347. Closes #29349
- Loading branch information
Showing
9 changed files
with
313 additions
and
279 deletions.
There are no files selected for viewing
This file contains 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
Empty file.
85 changes: 85 additions & 0 deletions
85
plugins/repository-azure/qa/microsoft-azure-storage/build.gradle
This file contains 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,85 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import org.elasticsearch.gradle.MavenFilteringHack | ||
import org.elasticsearch.gradle.test.AntFixture | ||
|
||
apply plugin: 'elasticsearch.standalone-rest-test' | ||
apply plugin: 'elasticsearch.rest-test' | ||
|
||
dependencies { | ||
testCompile project(path: ':plugins:repository-azure', configuration: 'runtime') | ||
} | ||
|
||
integTestCluster { | ||
plugin ':plugins:repository-azure' | ||
} | ||
|
||
forbiddenApisTest { | ||
// we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage | ||
bundledSignatures -= 'jdk-non-portable' | ||
bundledSignatures += 'jdk-internal' | ||
} | ||
|
||
boolean useFixture = false | ||
|
||
String azureAccount = System.getenv("azure_storage_account") | ||
String azureKey = System.getenv("azure_storage_key") | ||
String azureContainer = System.getenv("azure_storage_container") | ||
String azureBasePath = System.getenv("azure_storage_base_path") | ||
|
||
if (!azureAccount && !azureKey && !azureContainer && !azureBasePath) { | ||
azureAccount = 'azure_integration_test_account' | ||
azureKey = 'YXp1cmVfaW50ZWdyYXRpb25fdGVzdF9rZXk=' // The key is "azure_integration_test_key" encoded using base64 | ||
azureContainer = 'container_test' | ||
azureBasePath = 'integration_test' | ||
useFixture = true | ||
} | ||
|
||
/** A task to start the fixture which emulates an Azure Storage service **/ | ||
task azureStorageFixture(type: AntFixture) { | ||
dependsOn compileTestJava | ||
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }" | ||
executable = new File(project.runtimeJavaHome, 'bin/java') | ||
args 'org.elasticsearch.repositories.azure.AzureStorageFixture', baseDir, azureContainer | ||
} | ||
|
||
Map<String, Object> expansions = [ | ||
'container': azureContainer, | ||
'base_path': azureBasePath | ||
] | ||
processTestResources { | ||
inputs.properties(expansions) | ||
MavenFilteringHack.filter(it, expansions) | ||
} | ||
|
||
integTestCluster { | ||
keystoreSetting 'azure.client.integration_test.account', azureAccount | ||
keystoreSetting 'azure.client.integration_test.key', azureKey | ||
|
||
if (useFixture) { | ||
dependsOn azureStorageFixture | ||
// Use a closure on the string to delay evaluation until tests are executed. The endpoint_suffix is used | ||
// in a hacky way to change the protocol and endpoint. We must fix that. | ||
setting 'azure.client.integration_test.endpoint_suffix', | ||
"ignored;DefaultEndpointsProtocol=http;BlobEndpoint=http://${ -> azureStorageFixture.addressAndPort }" | ||
} else { | ||
println "Using an external service to test the repository-azure plugin" | ||
} | ||
} |
File renamed without changes.
48 changes: 48 additions & 0 deletions
48
...ava/org/elasticsearch/repositories/azure/AzureStorageRepositoryClientYamlTestSuiteIT.java
This file contains 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,48 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.repositories.azure; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.Name; | ||
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; | ||
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; | ||
|
||
public class AzureStorageRepositoryClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { | ||
|
||
public AzureStorageRepositoryClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { | ||
super(testCandidate); | ||
} | ||
|
||
@ParametersFactory | ||
public static Iterable<Object[]> parameters() throws Exception { | ||
return ESClientYamlSuiteTestCase.createParameters(); | ||
} | ||
|
||
@Override | ||
protected Settings restClientSettings() { | ||
// Give more time to repository-azure to complete the snapshot operations | ||
return Settings.builder().put(super.restClientSettings()) | ||
.put(ESRestTestCase.CLIENT_RETRY_TIMEOUT, "60s") | ||
.put(ESRestTestCase.CLIENT_SOCKET_TIMEOUT, "60s") | ||
.build(); | ||
} | ||
} |
File renamed without changes.
174 changes: 174 additions & 0 deletions
174
...ft-azure-storage/src/test/resources/rest-api-spec/test/repository_azure/10_repository.yml
This file contains 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,174 @@ | ||
# Integration tests for repository-azure | ||
--- | ||
"Snapshot/Restore with repository-azure": | ||
|
||
# Register repository | ||
- do: | ||
snapshot.create_repository: | ||
repository: repository | ||
body: | ||
type: azure | ||
settings: | ||
container: ${container} | ||
client: "integration_test" | ||
base_path: ${base_path} | ||
|
||
- match: { acknowledged: true } | ||
|
||
# Get repository | ||
- do: | ||
snapshot.get_repository: | ||
repository: repository | ||
|
||
- match: { repository.settings.container: ${container} } | ||
- match: { repository.settings.client : "integration_test" } | ||
- match: { repository.settings.base_path : ${base_path} } | ||
|
||
# Index documents | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: docs | ||
_type: doc | ||
_id: 1 | ||
- snapshot: one | ||
- index: | ||
_index: docs | ||
_type: doc | ||
_id: 2 | ||
- snapshot: one | ||
- index: | ||
_index: docs | ||
_type: doc | ||
_id: 3 | ||
- snapshot: one | ||
|
||
- do: | ||
count: | ||
index: docs | ||
|
||
- match: {count: 3} | ||
|
||
# Create a first snapshot | ||
- do: | ||
snapshot.create: | ||
repository: repository | ||
snapshot: snapshot-one | ||
wait_for_completion: true | ||
|
||
- match: { snapshot.snapshot: snapshot-one } | ||
- match: { snapshot.state : SUCCESS } | ||
- match: { snapshot.include_global_state: true } | ||
- match: { snapshot.shards.failed : 0 } | ||
|
||
- do: | ||
snapshot.status: | ||
repository: repository | ||
snapshot: snapshot-one | ||
|
||
- is_true: snapshots | ||
- match: { snapshots.0.snapshot: snapshot-one } | ||
- match: { snapshots.0.state : SUCCESS } | ||
|
||
# Index more documents | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: docs | ||
_type: doc | ||
_id: 4 | ||
- snapshot: two | ||
- index: | ||
_index: docs | ||
_type: doc | ||
_id: 5 | ||
- snapshot: two | ||
- index: | ||
_index: docs | ||
_type: doc | ||
_id: 6 | ||
- snapshot: two | ||
- index: | ||
_index: docs | ||
_type: doc | ||
_id: 7 | ||
- snapshot: two | ||
|
||
- do: | ||
count: | ||
index: docs | ||
|
||
- match: {count: 7} | ||
|
||
# Create a second snapshot | ||
- do: | ||
snapshot.create: | ||
repository: repository | ||
snapshot: snapshot-two | ||
wait_for_completion: true | ||
|
||
- match: { snapshot.snapshot: snapshot-two } | ||
- match: { snapshot.state : SUCCESS } | ||
- match: { snapshot.shards.failed : 0 } | ||
|
||
- do: | ||
snapshot.get: | ||
repository: repository | ||
snapshot: snapshot-one,snapshot-two | ||
|
||
- is_true: snapshots | ||
- match: { snapshots.0.state : SUCCESS } | ||
- match: { snapshots.1.state : SUCCESS } | ||
|
||
# Delete the index | ||
- do: | ||
indices.delete: | ||
index: docs | ||
|
||
# Restore the second snapshot | ||
- do: | ||
snapshot.restore: | ||
repository: repository | ||
snapshot: snapshot-two | ||
wait_for_completion: true | ||
|
||
- do: | ||
count: | ||
index: docs | ||
|
||
- match: {count: 7} | ||
|
||
# Delete the index again | ||
- do: | ||
indices.delete: | ||
index: docs | ||
|
||
# Restore the first snapshot | ||
- do: | ||
snapshot.restore: | ||
repository: repository | ||
snapshot: snapshot-one | ||
wait_for_completion: true | ||
|
||
- do: | ||
count: | ||
index: docs | ||
|
||
- match: {count: 3} | ||
|
||
# Remove the snapshots | ||
- do: | ||
snapshot.delete: | ||
repository: repository | ||
snapshot: snapshot-two | ||
master_timeout: 5m | ||
|
||
- do: | ||
snapshot.delete: | ||
repository: repository | ||
snapshot: snapshot-one | ||
master_timeout: 5m |
Oops, something went wrong.