build.gradle 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 org.elasticsearch.gradle.Version
  20. import org.elasticsearch.gradle.info.BuildParams
  21. import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
  22. apply plugin: 'elasticsearch.testclusters'
  23. apply plugin: 'elasticsearch.standalone-test'
  24. apply from : "$rootDir/gradle/bwc-test.gradle"
  25. for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
  26. String baseName = "v${bwcVersion}"
  27. testClusters {
  28. "${baseName}" {
  29. versions = [bwcVersion.toString(), project.version]
  30. numberOfNodes = 2
  31. // some tests rely on the translog not being flushed
  32. setting 'indices.memory.shard_inactive_time', '60m'
  33. setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
  34. }
  35. }
  36. tasks.register("${baseName}#oldClusterTest", StandaloneRestIntegTestTask) {
  37. useCluster testClusters."${baseName}"
  38. mustRunAfter(precommit)
  39. doFirst {
  40. delete("${buildDir}/cluster/shared/repo/${baseName}")
  41. }
  42. systemProperty 'tests.is_old_cluster', 'true'
  43. }
  44. tasks.register("${baseName}#upgradedClusterTest", StandaloneRestIntegTestTask) {
  45. useCluster testClusters."${baseName}"
  46. dependsOn "${baseName}#oldClusterTest"
  47. doFirst {
  48. testClusters."${baseName}".goToNextVersion()
  49. }
  50. systemProperty 'tests.is_old_cluster', 'false'
  51. }
  52. String oldVersion = bwcVersion.toString().minus("-SNAPSHOT")
  53. tasks.matching { it.name.startsWith(baseName) && it.name.endsWith("ClusterTest") }.configureEach {
  54. it.systemProperty 'tests.old_cluster_version', oldVersion
  55. it.systemProperty 'tests.path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
  56. it.nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
  57. it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
  58. }
  59. tasks.register(bwcTaskName(bwcVersion)) {
  60. dependsOn tasks.named("${baseName}#upgradedClusterTest")
  61. }
  62. }
  63. configurations {
  64. testArtifacts.extendsFrom testRuntime
  65. testArtifacts.extendsFrom testImplementation
  66. }
  67. TaskProvider testJar = tasks.register("testJar", Jar) {
  68. appendix 'test'
  69. from sourceSets.test.output
  70. }
  71. artifacts {
  72. testArtifacts testJar
  73. }