mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Fix the run of copyEs and downloadEs gradle task. (#12586)
Avoid the deletion of downaloaded ES artifact during copyEs task and download a new version only if the SHA512 of the local copy differs from the what is retrived from remote repository. This avoid unusefull download of the same ES artifact when run integrationTests task multiple times.
This commit is contained in:
parent
8abfc50d08
commit
c96ae0d4bd
1 changed files with 40 additions and 2 deletions
42
build.gradle
42
build.gradle
|
@ -398,9 +398,46 @@ tasks.register("copyFilebeat", Copy){
|
|||
}
|
||||
}
|
||||
|
||||
tasks.register("checkEsSHA") {
|
||||
dependsOn configureArtifactInfo
|
||||
|
||||
description "Download ES version remote's fingerprint file"
|
||||
|
||||
String downloadedElasticsearchName = "elasticsearch-${project.ext.get("stackArtifactSuffix")}-${project.ext.get("esArchitecture")}"
|
||||
outputs.file("${projectDir}/build/${downloadedElasticsearchName}.tar.gz.SHA-512")
|
||||
|
||||
// find url of build artifact
|
||||
String artifactApiUrl = "${project.ext.get("artifactApiVersionedBuildUrl")}/projects/elasticsearch/packages/${downloadedElasticsearchName}.tar.gz"
|
||||
String apiResponse = artifactApiUrl.toURL().text
|
||||
def buildUrls = new JsonSlurper().parseText(apiResponse)
|
||||
String remoteSHA = buildUrls.package.sha_url.toURL().text
|
||||
|
||||
def localESArchive = new File("${projectDir}/build/${downloadedElasticsearchName}.tar.gz")
|
||||
if (localESArchive.exists()) {
|
||||
// this create a file named localESArchive with ".SHA-512" postfix
|
||||
ant.checksum(file: localESArchive, algorithm: "SHA-512", forceoverwrite: true)
|
||||
|
||||
File localESCalculatedSHAFile = new File("${projectDir}/build/${downloadedElasticsearchName}.tar.gz.SHA-512")
|
||||
String localESCalculatedSHA = localESCalculatedSHAFile.text.trim()
|
||||
def splitted = remoteSHA.split(' ')
|
||||
String remoteSHACode = splitted[0]
|
||||
if (localESCalculatedSHA != remoteSHACode) {
|
||||
println "ES package calculated fingerprint is different from remote, deleting local archive"
|
||||
delete(localESArchive)
|
||||
delete(localESCalculatedSHA)
|
||||
}
|
||||
} else {
|
||||
mkdir project.buildDir
|
||||
// touch the SHA file else downloadEs task doesn't start, this file his input for the other task
|
||||
new File("${projectDir}/build/${downloadedElasticsearchName}.tar.gz.SHA-512").withWriter {w ->
|
||||
w << "${downloadedElasticsearchName} not yet downloaded"
|
||||
w.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("downloadEs", Download) {
|
||||
dependsOn configureArtifactInfo
|
||||
dependsOn = [configureArtifactInfo, checkEsSHA]
|
||||
description "Download ES Snapshot for current branch version: ${version}"
|
||||
|
||||
String downloadedElasticsearchName = "elasticsearch-${project.ext.get("stackArtifactSuffix")}-${project.ext.get("esArchitecture")}"
|
||||
|
@ -418,6 +455,7 @@ tasks.register("downloadEs", Download) {
|
|||
onlyIfNewer true
|
||||
retries 3
|
||||
inputs.file("${projectDir}/versions.yml")
|
||||
// inputs.file("${projectDir}/build/${downloadedElasticsearchName}.tar.gz.SHA-512")
|
||||
outputs.file(project.ext.elasticsearchDownloadLocation)
|
||||
dest new File(project.ext.elasticsearchDownloadLocation)
|
||||
|
||||
|
@ -439,7 +477,7 @@ tasks.register("copyEs", Copy) {
|
|||
file("./build/${project.ext.unpackedElasticsearchName}").renameTo('./build/elasticsearch')
|
||||
System.out.println "Unzipped ${project.ext.elasticsearchDownloadLocation} to ./build/elasticsearch"
|
||||
System.out.println "Deleting ${project.ext.elasticsearchDownloadLocation}"
|
||||
delete(project.ext.elasticsearchDownloadLocation)
|
||||
// delete(project.ext.elasticsearchDownloadLocation)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue