Revision bc9521e9b037ac833a5a0c1c3d7d1df965c04a96 authored by Mark Vieira on 25 May 2021, 19:43:20 UTC, committed by GitHub on 25 May 2021, 19:43:20 UTC
1 parent 221c571
Raw File
build.gradle
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0 and the Server Side Public License, v 1; you may not use this file except
 * in compliance with, at your election, the Elastic License 2.0 or the Server
 * Side Public License, v 1.
 */

import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-test'
apply plugin: 'elasticsearch.bwc-test'

for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
  String baseName = "v${bwcVersion}"

  testClusters {
    "${baseName}" {
      version = bwcVersion.toString()
      setting 'xpack.security.enabled', 'true'
      user username: 'admin', password: 'admin-password', role: 'superuser'
    }
  }

  tasks.register("${baseName}#integTest", StandaloneRestIntegTestTask) {
    useCluster testClusters."${baseName}"
    nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
    nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
  }

  tasks.register(bwcTaskName(bwcVersion)) {
    dependsOn "${baseName}#integTest"
  }
}

tasks.register("verifyDocsLuceneVersion") {
  doFirst {
    File docsVersionsFile = rootProject.file('docs/Versions.asciidoc')
    List<String> versionLines = docsVersionsFile.readLines('UTF-8')
    String docsLuceneVersion = null
    for (String line : versionLines) {
      if (line.startsWith(':lucene_version:')) {
        docsLuceneVersion = line.split()[1]
      }
    }
    if (docsLuceneVersion == null) {
      throw new GradleException('Could not find lucene version in docs version file')
    }
    String expectedLuceneVersion = VersionProperties.lucene
    // remove potential -snapshot-{gitrev} suffix
    expectedLuceneVersion -= ~/-snapshot-[0-9a-f]+$/
    if (docsLuceneVersion != expectedLuceneVersion) {
      throw new GradleException("Lucene version in docs [${docsLuceneVersion}] does not match version.properties [${expectedLuceneVersion}]")
    }
  }
}

tasks.named("check").configure {
  dependsOn verifyDocsLuceneVersion
}
back to top