Skip to content

Commit

Permalink
improve integ test setup to not install plugin via a different cluster
Browse files Browse the repository at this point in the history
name
  • Loading branch information
rjernst committed Sep 18, 2015
1 parent c7652ad commit 7e32e47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class BuildPlugin implements Plugin<Project> {
void apply(Project project) {
project.pluginManager.apply('java')
project.pluginManager.apply('carrotsearch.randomizedtesting')
project.pluginManager.apply('de.thetaphi.forbiddenapis')
//project.pluginManager.apply('de.thetaphi.forbiddenapis')
// TODO: license checker

Closure testConfig = createSharedTestConfig(project)
RandomizedTestingTask test = configureTest(project.tasks, testConfig)
RandomizedTestingTask integTest = configureIntegTest(project.tasks, getIntegTestClass(), test, testConfig)

List<Task> precommitTasks = new ArrayList<>()
precommitTasks.add(configureForbiddenApis(project))
//precommitTasks.add(configureForbiddenApis(project))
precommitTasks.add(configureForbiddenPatterns(project.tasks))

Map precommitOptions = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.elasticsearch.gradle

import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.Task
Expand Down Expand Up @@ -33,16 +34,21 @@ class ClusterFormationTasks {

static void addNodeStartupTasks(Task task, ClusterConfiguration config, File baseDir) {
Project project = task.project
Task install = project.tasks.create(name: task.name + '#setup', type: Copy, dependsOn: project.configurations.elasticsearchZip.buildDependencies) {
String clusterName = "${task.path.replace(':', '_').substring(1)}"
File home = new File(baseDir, "elasticsearch-${ElasticsearchProperties.version}")
Task setup = project.tasks.create(name: task.name + '#setup', type: Copy, dependsOn: project.configurations.elasticsearchZip.buildDependencies) {
from project.zipTree(project.configurations.elasticsearchZip.asPath)
into baseDir
}
File home = new File(baseDir, "elasticsearch-${ElasticsearchProperties.version}")
Task clean = project.tasks.create(name: "${task.name}#clean", type: Delete, dependsOn: install) {
// chain setup tasks to maintain their order
setup = project.tasks.create(name: "${task.name}#clean", type: Delete, dependsOn: setup) {
delete new File(home, 'plugins'), new File(home, 'data'), new File(home, 'logs')
}

Task setup = clean // chain setup tasks to maintain their order
setup = project.tasks.create(name: "${task.name}#configure", type: DefaultTask, dependsOn: setup) << {
File configFile = new File(home, 'config' + File.separator + 'elasticsearch.yml')
logger.info("Configuring ${configFile}")
configFile.text = "cluster.name: ${clusterName}"
}
for (Map.Entry<String, String> command : config.setupConfig.commands.entrySet()) {
Task nextSetup = project.tasks.create(name: "${task.name}#${command.getKey()}", type: Exec, dependsOn: setup) {
workingDir home
Expand All @@ -64,15 +70,13 @@ class ClusterFormationTasks {
setup = nextSetup
}

String clusterName = "test${task.path.replace(':', '_')}"
File pidFile = pidFile(baseDir)
Task start = project.tasks.create(name: "${task.name}#start", type: Exec, dependsOn: setup) {
workingDir home
executable 'sh'
List esArgs = [
'bin/elasticsearch',
'-d', // daemonize!
"-Des.cluster.name=${clusterName}",
"-Des.http.port=${config.httpPort}",
"-Des.transport.tcp.port=${config.transportPort}",
"-Des.pidfile=${pidFile}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

public class MacAddressProvider {

private static final ESLogger logger = Loggers.getLogger(MacAddressProvider.class);

private static byte[] getMacAddress() throws SocketException {
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
if (en != null) {
Expand Down Expand Up @@ -66,11 +64,15 @@ public static byte[] getSecureMungedAddress() {
try {
address = getMacAddress();
} catch( SocketException se ) {
// only grab the logger when necessary, since the logging system may not be setup yet
ESLogger logger = Loggers.getLogger(MacAddressProvider.class);
logger.warn("Unable to get mac address, will use a dummy address", se);
// address will be set below
}

if (!isValidAddress(address)) {
// only grab the logger when necessary, since the logging system may not be setup yet
ESLogger logger = Loggers.getLogger(MacAddressProvider.class);
logger.warn("Unable to get a valid mac address, will use a dummy address");
address = constructDummyMulticastAddress();
}
Expand Down

0 comments on commit 7e32e47

Please sign in to comment.