/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ buildscript { repositories { mavenCentral() } } plugins { id "de.undercouch.download" version "3.2.0" id "org.nosphere.apache.rat" version "0.2.0" } // Generated by http://patorjk.com/software/taag/#p=display&f=Bloody&t=Apache%20Bigtop def final ASCII_bigtop = ''' :aass.. =XS22nai,>__. . =n-- +!!!""^-- .vX> . .)e . ..=-?Xo>, . . . .__aaoZe!`=>.+*a>,.-"!Y1XSSX##ZZXXXXXXXXXXXoXXc .{XXXXXX2*?!!"!"^~--- ...__aa2!^- =dX( .+XXc. ~!1nas,,.---~~^""!"!!!?YSXXXXX2+ -"YSXXXo=. ._=sssaaav1!!~- ._aXXe` )SXo>. -~"?Yoouass_s,, _vXXXX2}~ -{XXZoai%%*XXSSSX>.. . - ---=2XXX2^-"|||}"--~{ZXXX1-- .:XXXXo; . )XXXX2` . =XXXXZc nXXXX> =XXXXe..__s=>_...)XXXX1 . .:SXXXo; .)XXXX2.. =XXXXosummmmBmma,)ZXXX1 :XXXX2; )XXXXX. . :XXXXXc . . =oZXXXe; .:test task only * in if the project has smoke.tests properties set. * This is done to avoid running cluster smoke tests during the normal life-cycle * of the project development */ def checkClusterTestProjects = { property -> def suiteName = property.replaceAll('.', '-') FileTree fTree = fileTree(dir: "bigtop-tests/$suiteName", include: '*/build.gradle') fTree.each() { smokeProject -> def parent = smokeProject.getParentFile().name project (":bigtop-tests:$suiteName:$parent") { test { onlyIf {project.hasProperty(suiteName)} } } } } def TESTARTIFACTS_GROUP = 'test artifacts' def DEVENV_GROUP = 'development tools' def DEPLOY_GROUP = 'deployment' def DOCKERBUILD_GROUP = 'docker build' // All packaging logic is separated into its own build module apply from: 'packages.gradle' // Wrapping all release logic to simplify the release process apply from: 'release.gradle' task toolchain(type:Exec, description: 'Setup dev. env via toolchain; Requires: Puppet, sudo', group: DEVENV_GROUP) { def command = [ 'sudo', 'puppet', 'apply', '-d', '--parser', 'future', "--modulepath=${projectDir.absolutePath}:/etc/puppet/modules", '-e', 'include bigtop_toolchain::installer' ] workingDir '.' commandLine command } task "toolchain-puppetmodules"(type:Exec, description: 'Setup puppet modules via toolchain; Requires: Puppet, sudo', group: DEVENV_GROUP) { def command = [ 'sudo', 'puppet', 'apply', '-d', "--modulepath=${projectDir.absolutePath}", '-e', 'include bigtop_toolchain::puppet-modules' ] workingDir '.' commandLine command } task "toolchain-devtools"(type:Exec, description: 'Setup additional dev. tools like Groovy SDK via toolchain; Requires: Puppet, sudo', group: DEVENV_GROUP) { def command = [ 'sudo', 'puppet', 'apply', '-d', "--modulepath=${projectDir.absolutePath}", '-e', 'include bigtop_toolchain::development-tools' ] workingDir '.' commandLine command } task "docker-provisioner"(type:Exec, description: 'Provision a Bigtop cluster on Docker container(s). Default to CentOS and 1 node.\nCreate a 3 node cluster:\n $ ./gradlew -Pnum_instances=3 docker-provisioner\nRun smoke tests on 3 node cluster:\n $ ./gradlew -Pnum_instances=3 -Prun_smoke_tests=true docker-provisioner\nSpecify configuration file (located in provisioner/docker/):\n $ ./gradlew -Pconfig=config_debian8.yaml docker-provisioner', group: DEPLOY_GROUP) { def _config = project.hasProperty("config") ? config : "config.yaml" def _num_instances = project.hasProperty("num_instances") ? num_instances : 1 def command = [ './docker-hadoop.sh', '-C', _config, '--create', _num_instances, ] if ( project.hasProperty("run_smoke_tests") && run_smoke_tests ) { command.add("--smoke-tests") } workingDir 'provisioner/docker' commandLine command } task "docker-provisioner-ssh"(type:Exec, description: 'Show command to get in to the provisioned container', group: DEPLOY_GROUP) { workingDir 'provisioner/docker' def message = "To get in to the container, do: \n\ndocker exec -ti bash \n\nYou can get container name by ./gradlew docker-provisioner-status" def command = [ '/bin/echo', message ] commandLine command } task "docker-provisioner-status"(type:Exec, description: 'Show status of Bigtop Docker cluster', group: DEPLOY_GROUP) { def command = [ './docker-hadoop.sh', '--list', ] workingDir 'provisioner/docker' commandLine command } task "docker-provisioner-destroy"(type:Exec, description: 'Destroy provisioned Bigtop Docker cluster', group: DEPLOY_GROUP) { def command = [ './docker-hadoop.sh', '--destroy' ] workingDir 'provisioner/docker' commandLine command } task installTopLevel(type:Exec) { workingDir "." commandLine 'mvn clean install -f pom.xml'.split(" ") } task installiTest(dependsOn: installTopLevel, type:Exec) { workingDir "." commandLine 'mvn clean install -f bigtop-test-framework/pom.xml -DskipTests'.split(" ") } task installTestArtifacts(dependsOn: installiTest, type:Exec) { workingDir "." commandLine 'mvn clean install -f bigtop-tests/test-artifacts/pom.xml'.split(" ") } task installConf(type:Exec) { workingDir "." commandLine 'mvn clean install -f bigtop-tests/test-execution/conf/pom.xml'.split(" ") } task installCommon(type:Exec) { workingDir "." commandLine 'mvn clean install -f bigtop-tests/test-execution/common/pom.xml'.split(" ") } task installAllLocalArtifacts ( description: "Prepare and locally install all test artifacts", group: TESTARTIFACTS_GROUP) { } /** * Allows user to specify which artifacts to install by dynamically generating tasks. */ def artifactToInstall = { def final BASE_DIR = projectDir.absolutePath def final TEST_DIR = "$BASE_DIR/bigtop-tests/test-artifacts" def project = new XmlSlurper().parse("$TEST_DIR/pom.xml") project.modules.module.each { artifact -> task "install-${artifact}" (description: "Installs ${artifact} artifact with Maven", group: TESTARTIFACTS_GROUP, dependsOn: installiTest ) << { def final PATH = "${TEST_DIR}/$artifact/pom.xml" def final WRAPPER = "mvn clean install -f " + PATH exec { workingDir '.' commandLine WRAPPER.split(" ") } } } } def _NEXUS_URL = project.hasProperty("NEXUS_URL") ? NEXUS_URL : "http://localhost:8081" def generate_nexus_tasks = { name, url, snapshot -> task "configure-nexus-${name}"(type: Exec) { def req = [ data : [ id: name, name: name, repoType: "proxy", repoPolicy : snapshot, browseable: true, "indexable": true, "notFoundCacheTTL": 1440, "artifactMaxAge": 1440, "metadataMaxAge": 1440, "itemMaxAge": 1440, "provider": "maven2", "providerRole": "org.sonatype.nexus.proxy.repository.Repository", "downloadRemoteIndexes": true, "autoBlockActive": true, "fileTypeValidation": true, "exposed": true, "checksumPolicy": "WARN", "remoteStorage": ["remoteStorageUrl": url, "authentication": null, "connectionSettings": null]]] def root = new groovy.json.JsonBuilder(req) def p = root.toString() def _NEXUS_USERPASS = project.hasProperty("NEXUS_USERPASS") ? NEXUS_USERPASS : "admin:admin123" File.createTempFile("temp",".tmp").with { deleteOnExit() write root.toString() workingDir '.' commandLine "curl", "-o", "/dev/null", "-X", "POST", "-d", "@$absolutePath", "--header", "Content-Type: application/json", "-u", "$_NEXUS_USERPASS", "$_NEXUS_URL/service/local/repositories" } } } def repos = [ [ "name": "conjars", "url" : "http://conjars.org", 'snapshot':'RELEASE'], [ "name": "repository.jboss.org", "url": "http://repository.jboss.org/nexus/content/groups/public/", 'snapshot': 'RELEASE'], [ "name": "apache.snapshots.https", "url": "https://repository.apache.org/content/repositories/snapshots", "snapshot": 'SNAPSHOT'], [ "name": "apache.snapshots", "url": "https://repository.apache.org/content/repositories/snapshots", "snapshot": 'SNAPSHOT'], [ "name": "maven2-repository.atlassian", "url": "https://maven.atlassian.com/repository/public", "snapshot": 'RELASE']] repos.each { r-> generate_nexus_tasks( r.name, r.url, r.snapshot) } task "configure-nexus"(dependsOn: tasks.findAll { alltask -> alltask.name.startsWith("configure-nexus-")}*.name, description: 'configure build to use a sonatype nexus server.\n' + ' Use -PNEXUS_URL=http://server:8081 to overwrite default server http://localhost:8081\n' + ' Use -PNEXUS_USERPASS=user:passwd to overwrite default username passwd admin:admin123') << { def m2Dir = System.getProperty("user.home") + "/.m2" mkdir(m2Dir) def writer = new File(m2Dir + "/settings.xml") def writeMirrorLine = { name -> writer.append("$name$_NEXUS_URL/content/repositories/$name/$name") } writer.text = "" writeMirrorLine( "central") repos.each{ r-> writeMirrorLine( r.name) } writer.append("") } task "bigtop-slaves"(type:Exec, description: 'Build bigtop/slaves images.\n' + 'Usage:\n $ ./gradlew -POS=[centos-6|centos-7|fedora-20|debian-8|ubuntu-14.04|opensuse-13.2] -Pprefix=STRING_TO_PREFIX bigtop-slaves\n' + 'Example:\n $ ./gradlew -POS=debian-8 -Pprefix=1.0.0 bigtop-slaves\n' + 'The built image name: bigtop/slaves:1.0.0-debian-8', group: DOCKERBUILD_GROUP) { def _prefix = project.hasProperty("prefix") ? prefix : "trunk" def _OS = project.hasProperty("OS") ? OS : "centos-7" def command = [ 'docker', 'build', '-t', 'bigtop/slaves:' + _prefix + '-' + _OS, '-f', "docker/bigtop-slaves/" + _OS + "/Dockerfile", '--force-rm', '--no-cache', '--pull', '--rm', '.' ] workingDir '.' commandLine command } project.afterEvaluate { checkClusterTestProjects("smoke.tests") artifactToInstall(dependsOn: [installTopLevel, installCommon, installConf, installiTest]) } installAllLocalArtifacts.dependsOn installTopLevel, installCommon, installConf, installiTest, installTestArtifacts help.doFirst { println ASCII_bigtop }