build.gradle 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Licensed to Elasticsearch under one or more contributor
  3. * license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright
  5. * ownership. Elasticsearch licenses this file to you under
  6. * the Apache License, Version 2.0 (the "License"); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import java.util.Locale
  20. import org.elasticsearch.gradle.Version
  21. import org.elasticsearch.gradle.VersionProperties
  22. import org.elasticsearch.gradle.test.RestIntegTestTask
  23. apply plugin: 'elasticsearch.standalone-test'
  24. // This is a top level task which we will add dependencies to below.
  25. // It is a single task that can be used to backcompat tests against all versions.
  26. task bwcTest {
  27. description = 'Runs backwards compatibility tests.'
  28. group = 'verification'
  29. }
  30. for (Version version : indexCompatVersions) {
  31. String baseName = "v${version}"
  32. Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) {
  33. mustRunAfter(precommit)
  34. }
  35. configure(extensions.findByName("${baseName}#oldClusterTestCluster")) {
  36. distribution = 'zip'
  37. bwcVersion = version
  38. numBwcNodes = 1
  39. numNodes = 1
  40. clusterName = 'verify-version-constants'
  41. if (version.onOrAfter('5.3.0')) {
  42. setting 'http.content_type.required', 'true'
  43. }
  44. }
  45. Task versionBwcTest = tasks.create(name: "${baseName}#bwcTest") {
  46. dependsOn = [oldClusterTest]
  47. }
  48. bwcTest.dependsOn(versionBwcTest)
  49. }
  50. test.enabled = false
  51. task integTest {
  52. dependsOn = ["v${indexCompatVersions[-1]}#bwcTest"]
  53. }
  54. task verifyDocsLuceneVersion {
  55. doFirst {
  56. File docsVersionsFile = rootProject.file('docs/Versions.asciidoc')
  57. List<String> versionLines = docsVersionsFile.readLines('UTF-8')
  58. String docsLuceneVersion = null
  59. for (String line : versionLines) {
  60. if (line.startsWith(':lucene_version:')) {
  61. docsLuceneVersion = line.split()[1]
  62. }
  63. }
  64. if (docsLuceneVersion == null) {
  65. throw new GradleException('Could not find lucene version in docs version file')
  66. }
  67. String expectedLuceneVersion = VersionProperties.lucene
  68. if (expectedLuceneVersion.contains('-snapshot-')) {
  69. expectedLuceneVersion = expectedLuceneVersion.substring(0, expectedLuceneVersion.lastIndexOf('-'))
  70. expectedLuceneVersion = expectedLuceneVersion.toUpperCase(Locale.ROOT)
  71. }
  72. if (docsLuceneVersion != expectedLuceneVersion) {
  73. throw new GradleException("Lucene version in docs [${docsLuceneVersion}] does not match version.properties [${expectedLuceneVersion}]")
  74. }
  75. }
  76. }
  77. check.dependsOn integTest, verifyDocsLuceneVersion