build.gradle 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.test.ClusterConfiguration
  20. import org.elasticsearch.gradle.test.ClusterFormationTasks
  21. import org.elasticsearch.gradle.test.NodeInfo
  22. esplugin {
  23. description 'Discovery file plugin enables unicast discovery from hosts stored in a file.'
  24. classname 'org.elasticsearch.discovery.file.FileBasedDiscoveryPlugin'
  25. }
  26. bundlePlugin {
  27. from('config/discovery-file') {
  28. into 'config'
  29. }
  30. }
  31. task setupSeedNodeAndUnicastHostsFile(type: DefaultTask) {
  32. mustRunAfter(precommit)
  33. }
  34. // setup the initial cluster with one node that will serve as the seed node
  35. // for unicast discovery
  36. ClusterConfiguration config = new ClusterConfiguration(project)
  37. config.clusterName = 'discovery-file-test-cluster'
  38. List<NodeInfo> nodes = ClusterFormationTasks.setup(project, 'initialCluster', setupSeedNodeAndUnicastHostsFile, config)
  39. File srcUnicastHostsFile = file('build/cluster/unicast_hosts.txt')
  40. // write the unicast_hosts.txt file to a temporary location to be used by the second cluster
  41. setupSeedNodeAndUnicastHostsFile.doLast {
  42. // write the unicast_hosts.txt file to a temp file in the build directory
  43. srcUnicastHostsFile.setText(nodes.get(0).transportUri(), 'UTF-8')
  44. }
  45. // second cluster, which will connect to the first via the unicast_hosts.txt file
  46. integTestCluster {
  47. dependsOn setupSeedNodeAndUnicastHostsFile
  48. clusterName = 'discovery-file-test-cluster'
  49. setting 'discovery.zen.hosts_provider', 'file'
  50. extraConfigFile 'discovery-file/unicast_hosts.txt', srcUnicastHostsFile
  51. }
  52. integTestRunner.finalizedBy ':plugins:discovery-file:initialCluster#stop'