mirror of https://github.com/apache/lucene.git
104 lines
3.1 KiB
Groovy
104 lines
3.1 KiB
Groovy
/*
|
|
* 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.
|
|
*/
|
|
|
|
apply plugin: 'base'
|
|
apply plugin: 'com.palantir.docker'
|
|
|
|
subprojects {
|
|
apply plugin: 'base'
|
|
apply plugin: 'com.palantir.docker'
|
|
}
|
|
|
|
description = 'Solr Docker image'
|
|
|
|
def dockerPackage = project(':solr:docker:package')
|
|
|
|
dependencies {
|
|
docker dockerPackage
|
|
}
|
|
|
|
def dockerImageName = "apache/solr:${version}"
|
|
def baseDockerImage = 'openjdk:11-jre-slim'
|
|
|
|
docker {
|
|
name = dockerImageName
|
|
files file('include')
|
|
buildArgs(['BASE_IMAGE' : baseDockerImage, 'SOLR_PACKAGE_IMAGE' : 'apache/solr-build:local-package', 'SOLR_VERSION': "${version}"])
|
|
}
|
|
|
|
tasks.docker {
|
|
// In order to create the solr docker image, the solr package image must be created first.
|
|
dependsOn(dockerPackage.tasks.docker)
|
|
|
|
// Print information on the image after it has been created
|
|
doLast {
|
|
project.logger.lifecycle("Solr Docker Image Created")
|
|
project.logger.lifecycle("\tName: $dockerImageName")
|
|
project.logger.lifecycle("\tBase Image: $baseDockerImage")
|
|
}
|
|
}
|
|
|
|
abstract class DockerTestSuite extends DefaultTask {
|
|
private List<String> tests = new ArrayList<>();
|
|
private List<String> ignore = new ArrayList<>();
|
|
|
|
@OutputDirectory
|
|
abstract DirectoryProperty getOutputDir()
|
|
|
|
@Option(option = "tests", description = "Only run these specified tests, comma separated.")
|
|
public void setTests(List<String> tests) {
|
|
this.tests = tests;
|
|
}
|
|
|
|
@Input
|
|
public List<String> getTests() {
|
|
return tests;
|
|
}
|
|
|
|
@Option(option = "ignore", description = "Ignore these tests, comma separated.")
|
|
public void setIgnore(List<String> ignore) {
|
|
this.ignore = ignore;
|
|
}
|
|
|
|
@Input
|
|
public List<String> getIgnore() {
|
|
return ignore;
|
|
}
|
|
|
|
@TaskAction
|
|
void execute() {
|
|
def sourceDir = project.file("tests/cases")
|
|
sourceDir.eachFile { file ->
|
|
def testName = file.getName()
|
|
def testCaseBuildDir = outputDir.dir(testName).get().toString()
|
|
|
|
// If specific tests are specified, only run those. Otherwise run all that are not ignored.
|
|
def runTest = !this.tests.isEmpty() ? tests.contains(testName) : !ignore.contains(testName)
|
|
if (runTest) {
|
|
project.exec {
|
|
environment "TEST_DIR", "$file"
|
|
environment "BUILD_DIR", "$testCaseBuildDir"
|
|
commandLine "bash", "$file/test.sh", "apache/solr:${project.version}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task testDocker(type: DockerTestSuite) {
|
|
outputDir = project.file("$buildDir/tmp/tests")
|
|
} |