Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions solr/packaging/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,56 @@ task integrationTests(type: BatsTask) {
environment BATS_LIB_PREFIX: "$nodeProjectDir/node_modules"
}

task testSmokeBats(type: BatsTask) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how much of the below lines of code could be refactored out so we don't list this code twice, once for iTest and a second time for testSmokeBats?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't like repetition; I suspected it but didn't look. I may try to reduce it.

What I want to see happen (separate issue/PR) is what I said in my dev list email -- this tech becoming a kind of gradle build infra that can be used wherever we want -- not just specifically where it lives now. If we do that, then I would imagine a new gradle task type for BATS for Solr that would have such vars built-in and we wouldn't need to say much to add a new gradle target using it.

description = 'Run smoke BATS tests (e.g. rolling upgrade via Docker) separately from the main integration tests'
group = 'verification'
dependsOn installFullDist
dependsOn downloadBats

testDir = 'test/smoke'

def integrationTestOutput = "$buildDir/test-output"
def solrHome = "$integrationTestOutput/solr-home"
def solrTestFailuresDir = "$integrationTestOutput/failure-snapshots"
var solrPort = Integer
.parseInt((String) project.findProperty('bats.port') ?: System.getProperty("bats.port", "-1"))
while (solrPort > 64000 || solrPort < 0) {
try (ServerSocket s = new ServerSocket(0)) {
solrPort = s.getLocalPort()
} catch (Exception e) {
println("WARN: Could not assign random port for Bats tests. Using default port 8983.")
solrPort = 8983
}
}

inputs.dir(distDir)
outputs.dir(integrationTestOutput)
outputs.upToDateWhen { false }

doFirst {
mkdir integrationTestOutput
mkdir solrHome
mkdir solrTestFailuresDir

standardOutput = new TeeOutputStream(System.out,
new FileOutputStream("$integrationTestOutput/test-output-smoke.txt"))
println("Running smoke BATS tests with Solr base port ${solrPort}")
}

environment SOLR_TIP: distDir.toString()
environment SOLR_HOME: solrHome
environment SOLR_PID_DIR: solrHome
environment SOLR_PORT_LISTEN: solrPort
environment SOLR_PORT: solrPort
environment SOLR2_PORT: solrPort + 1
environment SOLR3_PORT: solrPort + 2
environment ZK_PORT: solrPort + 1000
environment SOLR_LOGS_DIR: "$solrHome/logs"
environment TEST_OUTPUT_DIR: integrationTestOutput
environment TEST_FAILURE_DIR: solrTestFailuresDir
environment BATS_LIB_PREFIX: "$nodeProjectDir/node_modules"
}

class BatsTask extends Exec {
@InputDirectory
String testDir = 'test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load bats_helper
load "../bats_helper"

# You can test alternative images via
# You can test alternative images via
# export SOLR_BEGIN_IMAGE="apache/solr-nightly:9.9.0-slim" and then running
# ./gradlew iTest --tests test_rolling_upgrade.bats
# ./gradlew :solr:packaging:testSmokeBats
SOLR_BEGIN_IMAGE="${SOLR_BEGIN_IMAGE:-apache/solr-nightly:9.10.0-SNAPSHOT-slim}"
SOLR_END_IMAGE="${SOLR_END_IMAGE:-apache/solr-nightly:10.0.0-SNAPSHOT-slim}"

Expand Down
Loading