/* * 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 } docker { name = "apache/solr:${version}" files file('include') buildArgs(['BASE_IMAGE' : 'openjdk:11-jre-slim', 'SOLR_PACKAGE_IMAGE' : 'apache/solr-build:local-package', 'SOLR_VERSION': "${version}"]) } // In order to create the solr docker image, the solr package image must be created first. tasks.docker.dependsOn(dockerPackage.tasks.docker) abstract class DockerTestSuite extends DefaultTask { private List tests = new ArrayList<>(); private List ignore = new ArrayList<>(); @OutputDirectory abstract DirectoryProperty getOutputDir() @Option(option = "tests", description = "Only run these specified tests, comma separated.") public void setTests(List tests) { this.tests = tests; } @Input public List getTests() { return tests; } @Option(option = "ignore", description = "Ignore these tests, comma separated.") public void setIgnore(List ignore) { this.ignore = ignore; } @Input public List 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") }