"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.3/x-pack/plugin/build.gradle" (29 Aug 2019, 8300 Bytes) of package /linux/www/elasticsearch-6.8.3-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Java source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "build.gradle": 6.8.2_vs_6.8.3.

    1 import org.elasticsearch.gradle.LoggedExec
    2 import org.elasticsearch.gradle.plugin.PluginBuildPlugin
    3 import org.elasticsearch.gradle.test.NodeInfo
    4 
    5 import java.nio.charset.StandardCharsets
    6 
    7 apply plugin: 'elasticsearch.standalone-rest-test'
    8 apply plugin: 'elasticsearch.rest-test'
    9 
   10 archivesBaseName = 'x-pack'
   11 
   12 dependencies {
   13   testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
   14 }
   15 
   16 subprojects {
   17   afterEvaluate {
   18     if (project.plugins.hasPlugin(PluginBuildPlugin)) {
   19       // see the root Gradle file for additional logic regarding this configuration
   20       project.configurations.create('featureAwarePlugin')
   21       project.dependencies.add('featureAwarePlugin', project.configurations.compileClasspath)
   22       project.dependencies.add(
   23               'featureAwarePlugin',
   24               "org.elasticsearch.xpack.test:feature-aware:${org.elasticsearch.gradle.VersionProperties.elasticsearch}")
   25       project.dependencies.add('featureAwarePlugin', project.sourceSets.main.output.getClassesDirs())
   26 
   27       final Task featureAwareTask = project.tasks.create("featureAwareCheck", LoggedExec) {
   28         description = "Runs FeatureAwareCheck on main classes."
   29         dependsOn project.configurations.featureAwarePlugin
   30 
   31         final File successMarker = new File(project.buildDir, 'markers/featureAware')
   32         outputs.file(successMarker)
   33 
   34         executable = new File(project.runtimeJavaHome, 'bin/java')
   35 
   36         // default to main class files if such a source set exists
   37         final List files = []
   38         if (project.sourceSets.findByName("main")) {
   39           files.add(project.sourceSets.main.output.classesDirs)
   40           dependsOn project.tasks.classes
   41         }
   42         // filter out non-existent classes directories from empty source sets
   43         final FileCollection classDirectories = project.files(files).filter { it.exists() }
   44 
   45         onlyIf {
   46           /*
   47            * The latest version of ASM does not understand JDK 14. However, Gradle can not distinguish between JDK 13 and JDK 14 (treating
   48            * anything above JDK 12 as JDK 13). So, to exclude JDK 14 until a newer version of ASM is available, we also have to exclude JDK
   49            * 13. See https://github.com/elastic/elasticsearch/issues/45927.
   50            */
   51           Integer.parseInt(project.runtimeJavaVersion.getMajorVersion()) < 13
   52         }
   53         doFirst {
   54           args('-cp', project.configurations.featureAwarePlugin.asPath, 'org.elasticsearch.xpack.test.feature_aware.FeatureAwareCheck')
   55           classDirectories.each { args it.getAbsolutePath() }
   56         }
   57         doLast {
   58           successMarker.parentFile.mkdirs()
   59           successMarker.setText("", 'UTF-8')
   60         }
   61       }
   62 
   63       project.precommit.dependsOn featureAwareTask
   64     }
   65   }
   66 }
   67 
   68 // https://github.com/elastic/x-plugins/issues/724
   69 configurations {
   70   testArtifacts.extendsFrom testRuntime
   71 }
   72 
   73 task testJar(type: Jar) {
   74   appendix 'test'
   75   from sourceSets.test.output
   76   /*
   77    * Stick the license and notice file in the jar. This isn't strictly
   78    * needed because we don't publish it but it makes our super-paranoid
   79    * tests happy.
   80    */
   81   metaInf {
   82     from(project.licenseFile.parent) {
   83       include project.licenseFile.name
   84       rename { 'LICENSE.txt' }
   85     }
   86     from(project.noticeFile.parent) {
   87       include project.noticeFile.name
   88     }
   89   }
   90 }
   91 artifacts {
   92   testArtifacts testJar
   93 }
   94 
   95 integTestRunner {
   96   /*
   97    * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
   98    * other if we allow them to set the number of available processors as it's set-once in Netty.
   99    */
  100   systemProperty 'es.set.netty.runtime.available.processors', 'false'
  101 
  102 
  103   // TODO: fix this rest test to not depend on a hardcoded port!
  104   def blacklist = ['getting_started/10_monitor_cluster_health/*']
  105   boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"))
  106   if (!snapshot) {
  107     // these tests attempt to install basic/internal licenses signed against the dev/public.key
  108     // Since there is no infrastructure in place (anytime soon) to generate licenses using the production
  109     // private key, these tests are whitelisted in non-snapshot test runs
  110     blacklist.addAll(['xpack/15_basic/*', 'license/20_put_license/*'])
  111   }
  112   systemProperty 'tests.rest.blacklist', blacklist.join(',')
  113 }
  114 
  115 // location for keys and certificates
  116 File keystoreDir = new File(project.buildDir, 'keystore')
  117 File nodeKey = file("$keystoreDir/testnode.pem")
  118 File nodeCert = file("$keystoreDir/testnode.crt")
  119 
  120 // Add key and certs to test classpath: it expects them there
  121 // User cert and key PEM files instead of a JKS Keystore for the cluster's trust material so that
  122 // it can run in a FIPS 140 JVM
  123 // TODO: Remove all existing uses of cross project file references when the new approach for referencing static files is available
  124 // https://github.com/elastic/elasticsearch/pull/32201
  125 task copyKeyCerts(type: Copy) {
  126   from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) {
  127     include 'testnode.crt', 'testnode.pem'
  128     }
  129   into keystoreDir
  130 }
  131 // Add keystores to test classpath: it expects it there
  132 sourceSets.test.resources.srcDir(keystoreDir)
  133 processTestResources.dependsOn(copyKeyCerts)
  134 
  135 integTestCluster {
  136   dependsOn copyKeyCerts
  137   setting 'xpack.ml.enabled', 'true'
  138   setting 'xpack.security.enabled', 'true'
  139   // Integration tests are supposed to enable/disable exporters before/after each test
  140   setting 'xpack.monitoring.exporters._local.type', 'local'
  141   setting 'xpack.monitoring.exporters._local.enabled', 'false'
  142   setting 'xpack.security.authc.token.enabled', 'true'
  143   setting 'xpack.security.authc.api_key.enabled', 'true'
  144   setting 'xpack.security.transport.ssl.enabled', 'true'
  145   setting 'xpack.security.transport.ssl.key', nodeKey.name
  146   setting 'xpack.security.transport.ssl.certificate', nodeCert.name
  147   setting 'xpack.security.transport.ssl.verification_mode', 'certificate'
  148   setting 'xpack.security.transport.ssl.supported_protocols', 'TLSv1.2,TLSv1.1,TLSv1'
  149   setting 'xpack.security.audit.enabled', 'true'
  150   setting 'xpack.license.self_generated.type', 'trial'
  151   keystoreSetting 'bootstrap.password', 'x-pack-test-password'
  152   keystoreSetting 'xpack.security.authc.token.passphrase', 'x-pack-token-service-password'
  153   keystoreSetting 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode'
  154   distribution = 'zip' // this is important since we use the reindex module in ML
  155 
  156   setupCommand 'setupTestUser', 'bin/elasticsearch-users', 'useradd', 'x_pack_rest_user', '-p', 'x-pack-test-password', '-r', 'superuser'
  157 
  158   extraConfigFile nodeKey.name, nodeKey
  159   extraConfigFile nodeCert.name, nodeCert
  160 
  161   waitCondition = { NodeInfo node, AntBuilder ant ->
  162       File tmpFile = new File(node.cwd, 'wait.success')
  163 
  164       for (int i = 0; i < 10; i++) {
  165         // we use custom wait logic here as the elastic user is not available immediately and ant.get will fail when a 401 is returned
  166         HttpURLConnection httpURLConnection = null;
  167         try {
  168           httpURLConnection = (HttpURLConnection) new URL("http://${node.httpUri()}/_cluster/health?wait_for_nodes=${numNodes}&wait_for_status=yellow").openConnection();
  169           httpURLConnection.setRequestProperty("Authorization", "Basic " +
  170                   Base64.getEncoder().encodeToString("x_pack_rest_user:x-pack-test-password".getBytes(StandardCharsets.UTF_8)));
  171           httpURLConnection.setRequestMethod("GET");
  172           httpURLConnection.connect();
  173           if (httpURLConnection.getResponseCode() == 200) {
  174             tmpFile.withWriter StandardCharsets.UTF_8.name(), {
  175               it.write(httpURLConnection.getInputStream().getText(StandardCharsets.UTF_8.name()))
  176             }
  177           }
  178         } catch (Exception e) {
  179           if (i == 9) {
  180             logger.error("final attempt of calling cluster health failed", e)
  181           } else {
  182             logger.debug("failed to call cluster health", e)
  183           }
  184         } finally {
  185           if (httpURLConnection != null) {
  186             httpURLConnection.disconnect();
  187           }
  188         }
  189 
  190         // did not start, so wait a bit before trying again
  191         Thread.sleep(500L);
  192       }
  193       return tmpFile.exists()
  194   }
  195 }