1
+ import org.elasticsearch.gradle.MavenFilteringHack
1
2
import org.elasticsearch.gradle.info.BuildParams
2
3
4
+ import static org.elasticsearch.gradle.PropertyNormalization.DEFAULT
5
+ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
6
+
3
7
/*
4
8
* Licensed to Elasticsearch under one or more contributor
5
9
* license agreements. See the NOTICE file distributed with
@@ -34,7 +38,7 @@ dependencies {
34
38
35
39
restResources {
36
40
restApi {
37
- includeCore ' _common' , ' cluster' , ' nodes'
41
+ includeCore ' _common' , ' cluster' , ' nodes' , ' snapshot ' , ' bulk ' , ' count ' , ' indices '
38
42
}
39
43
}
40
44
@@ -69,16 +73,13 @@ thirdPartyAudit {
69
73
)
70
74
}
71
75
72
- check {
73
- // also execute the QA tests when testing the plugin
74
- dependsOn ' qa:microsoft-azure-storage:check'
75
- }
76
+ boolean useFixture = false
76
77
77
- testClusters {
78
- integTest {
79
- keystore ' azure.client.integration_test.account ' , ' azure_account '
80
- keystore ' azure.client.integration_test.key ' , ' azure_key '
81
- }
78
+ def azureAddress = {
79
+ assert useFixture : ' closure should not be used without a fixture '
80
+ int ephemeralPort = project( ' :test:fixtures: azure-fixture ' ) . postProcessFixture . ext . " test.fixtures.azure-fixture.tcp.8091 "
81
+ assert ephemeralPort > 0
82
+ return ' ignored;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1: ' + ephemeralPort + ' / '
82
83
}
83
84
84
85
String azureAccount = System . getenv(" azure_storage_account" )
@@ -87,19 +88,60 @@ String azureContainer = System.getenv("azure_storage_container")
87
88
String azureBasePath = System . getenv(" azure_storage_base_path" )
88
89
String azureSasToken = System . getenv(" azure_storage_sas_token" )
89
90
91
+ if (! azureAccount && ! azureKey && ! azureContainer && ! azureBasePath && ! azureSasToken) {
92
+ azureAccount = ' azure_integration_test_account'
93
+ azureKey = ' YXp1cmVfaW50ZWdyYXRpb25fdGVzdF9rZXk=' // The key is "azure_integration_test_key" encoded using base64
94
+ azureContainer = ' container'
95
+ azureBasePath = ' '
96
+ azureSasToken = ' '
97
+ useFixture = true
98
+
99
+ apply plugin : ' elasticsearch.test.fixtures'
100
+ testFixtures. useFixture ' :test:fixtures:azure-fixture' , ' azure-fixture'
101
+ }
102
+
103
+ Map<String , Object > expansions = [
104
+ ' container' : azureContainer,
105
+ ' base_path' : azureBasePath + " _integration_tests"
106
+ ]
107
+
108
+ processTestResources {
109
+ inputs. properties(expansions)
110
+ MavenFilteringHack . filter(it, expansions)
111
+ }
112
+
90
113
test {
114
+ // this is tested explicitly in a separate test task
91
115
exclude ' **/AzureStorageCleanupThirdPartyTests.class'
92
116
}
93
117
94
- task thirdPartyTest (type : Test ) {
118
+ testClusters {
119
+ integTest {
120
+ keystore ' azure.client.integration_test.account' , azureAccount
121
+ if (azureKey != null && azureKey. isEmpty() == false ) {
122
+ keystore ' azure.client.integration_test.key' , azureKey
123
+ }
124
+ if (azureSasToken != null && azureSasToken. isEmpty() == false ) {
125
+ keystore ' azure.client.integration_test.sas_token' , azureSasToken
126
+ }
127
+ if (useFixture) {
128
+ setting ' azure.client.integration_test.endpoint_suffix' , azureAddress
129
+ String firstPartOfSeed = BuildParams . testSeed. tokenize(' :' ). get(0 )
130
+ setting ' thread_pool.repository_azure.max' , (Math . abs(Long . parseUnsignedLong(firstPartOfSeed, 16 ) % 10 ) + 1 ). toString(), System . getProperty(' ignore.tests.seed' ) == null ? DEFAULT : IGNORE_VALUE
131
+ }
132
+ }
133
+ }
134
+
135
+ task azureThirdPartyTest (type : Test ) {
136
+ dependsOn tasks. integTest
95
137
include ' **/AzureStorageCleanupThirdPartyTests.class'
96
138
systemProperty ' test.azure.account' , azureAccount ? azureAccount : " "
97
139
systemProperty ' test.azure.key' , azureKey ? azureKey : " "
98
140
systemProperty ' test.azure.sas_token' , azureSasToken ? azureSasToken : " "
99
141
systemProperty ' test.azure.container' , azureContainer ? azureContainer : " "
100
142
systemProperty ' test.azure.base' , (azureBasePath ? azureBasePath : " " ) + " _third_party_tests_" + BuildParams . testSeed
143
+ if (useFixture) {
144
+ nonInputProperties. systemProperty ' test.azure.endpoint_suffix' , " ${ -> azureAddress.call() } "
145
+ }
101
146
}
102
-
103
- if (azureAccount || azureKey || azureContainer || azureBasePath || azureSasToken) {
104
- check. dependsOn(thirdPartyTest)
105
- }
147
+ check. dependsOn(azureThirdPartyTest)
0 commit comments