epugh commented on code in PR #5369:
URL: https://github.com/apache/solr/pull/5369#discussion_r4669253678
##########
solr/bin/solr:
##########
@@ -68,7 +68,7 @@ if [ $$ -ne $(ps -o pid='' -p $$ || echo 0) ] ; then
exit 1
fi
-# This helps with debugging when running bats tests however the whole script
is not compliant yet
+# This helps with debugging when running shell tests however the whole script
is not compliant yet
Review Comment:
interesting that "the whole script is not compliant yet", that seems like a
great place to spend some tokens to get to done..
##########
AGENTS.md:
##########
@@ -28,20 +28,17 @@ While README.md and CONTRIBUTING.md are mainly written for
humans, this file is
- See `dev-docs/gradle-help/tests.txt` for hints on running tests
- To run a specific test: `gradlew :solr:core:test --tests
"org.apache.solr.search.TestCaffeineCache"`
- To run CATS (Cross-platform Automated Testing System), the cross-platform
CLI suites: `gradlew -p solr/packaging catsTests --tests "*ZkTest"`
-- To run a specific BATS test (deprecated, replaced by CATS): `gradlew iTest
--tests test_adminconsole_urls.bats`
- The randomization seed is important. To repeat a failing tests, pass the
same seed given in the failure by adding to Gradle:
`-Ptests.seed=HEXADECIMALHERE`.
- Test output goes to
`solr/<module>/build/test-results/test/outputs/OUTPUT-<fully.qualified.TestName>.txt`
(stdout/stderr log) and
`solr/<module>/build/test-results/test/TEST-<fully.qualified.TestName>.xml`
(JUnit XML with pass/fail/error details)
- To scan test output for a specific issue across already-run tests: `grep -rl
"pattern" solr/*/build/test-results/test/outputs/`
## Writing Tests
-**Read `dev-docs/writing-tests.adoc` before writing any test.** It is the
authority on which harness to use — `SolrTestCase` by default,
`SolrCloudTestCase` only when a cluster is needed, `SolrCatsTestCase` for
`bin/solr` and `bin\solr.cmd`, `AdminUiTestBase` for the browser, a
Testcontainers `@ClassRule` for a real external service, and never
`SolrTestCaseJ4`, a new `.bats` file, or `docker run` from a test — and on the
lifecycle, randomization and waiting conventions, with a worked example per
kind.
+**Read `dev-docs/writing-tests.adoc` before writing any test.** It is the
authority on which harness to use — `SolrTestCase` by default,
`SolrCloudTestCase` only when a cluster is needed, `SolrCatsTestCase` for
`bin/solr` and `bin\solr.cmd`, `AdminUiTestBase` for the browser, a
Testcontainers `@ClassRule` for a real external service, and never
`SolrTestCaseJ4` or `docker run` from a test — and on the lifecycle,
randomization and waiting conventions, with a worked example per kind.
When adding a test to a suite that already exists, match the design choices of
the file you are editing.
-- For BATS shell integration tests in `solr/packaging/test/`:
- - Always use `run <command>` followed by `assert_output --partial "..."`
or `refute_output --partial "..."` instead of capturing output into local
variables and using `[[ ]]` comparisons
- - Avoid patterns like `local var=$(cmd | grep ...); [[ "$var" == *"..."*
]]` — use `run cmd` + `assert_output`/`refute_output` instead
+- Shell tests for `bin/solr`/`bin\solr.cmd` are CATS suites
(`SolrCatsTestCase`); BATS was removed, don't add `.bats` files.
Review Comment:
Do we need the BATS were removed text? I guess for now, and maybe in a year
we remove it...
##########
solr/packaging/src/test/org/apache/solr/shell/ModulesTest.java:
##########
@@ -60,32 +58,15 @@ public void icuCollationInAnalysisExtrasModule() {
env("SOLR_INCLUDE", solrIncludeFile.toString());
run("solr start");
- run("solr create -c COLL_NAME -d \"" + analysisExtrasConf() + "\"")
+ copyResource(
Review Comment:
I wonder if we could have a method called `copyResourceForCATS` and just
pass in one variable? If we see the same path duplicated, that seems odd...
`copyResourceForCATS("analysis_extras_config/conf/solrconfig.xml"); `
##########
solr/modules/analysis-extras/src/test/org/apache/solr/update/processor/TestConfiguringDocumentCategorizerUpdateProcessorFactory.java:
##########
@@ -29,7 +29,8 @@
*
* <p>Focused on verifying how DocumentCategorizerUpdateProcessorFactory is
set up to run.
*
- * <p>See test_opennlp.bats for a complete system test of
DocumentCategorizerUpdateProcessorFactory.
+ * <p>See {@code org.apache.solr.shell.OpenNlpTest} in solr/packaging for a
complete system test of
Review Comment:
I wonder if the package should have been `org.apache.solr.cats.OpenNlpTest`?
I was a bit surprised and then figured it out... I know it's a "shell",
but really, in my head it's a "CATS" test... not a "shell" test....
##########
solr/packaging/build.gradle:
##########
@@ -260,110 +257,17 @@ tasks.register('runDev', JavaExec) {
args((project.findProperty('args') ?: '--module=http').split())
}
-tasks.register('downloadBats') {
- group = 'Build Dependency Download'
- description =
- 'Downloads BATS and its helper libraries (bats-support, bats-assert,
bats-file) used by integrationTests'
-
- def batsLibs = [
- [org: 'bats-core', repo: 'bats-core', version:
libs.versions.bats.core.get()],
- [org: 'ztombol', repo: 'bats-support', version:
libs.versions.bats.support.get()],
- [org: 'bats-core', repo: 'bats-assert', version:
libs.versions.bats.assert.get()],
- [org: 'bats-core', repo: 'bats-file', version:
libs.versions.bats.file.get()],
- ]
- def downloadDir = file("$buildDir/bats-downloads")
-
- inputs.property('batsLibs', batsLibs)
- outputs.dir(batsLibsDir)
-
- doLast {
- delete batsLibsDir
- mkdir downloadDir
- batsLibs.each {lib ->
- def archiveUrl =
"https://github.com/${lib.org}/${lib.repo}/archive/refs/tags/v${lib.version}.tar.gz"
- def archiveFile = new File(downloadDir,
"${lib.repo}-${lib.version}.tar.gz")
- ant.get(src: archiveUrl, dest: archiveFile, skipexisting: true)
- copy {
- from(tarTree(resources.gzip(archiveFile))) {
- // Strip the leading "<repo>-<version>/" directory that GitHub's
archive adds.
- eachFile {details -> details.path =
details.path.substring(details.path.indexOf('/') + 1)}
- includeEmptyDirs = false
- }
- into "$batsLibsDir/${lib.repo}"
- }
- }
- }
-}
-
-// Shared configuration for the BATS suites. outputName keeps each suite's
Solr home, logs and
-// reports apart; usePicocli selects the experimental CLI implementation for
the run.
-def configureBatsTask(BatsTask task, String outputName, boolean usePicocli) {
- task.dependsOn installFullDist
- task.dependsOn downloadBats
-
- def integrationTestOutput = "$buildDir/$outputName"
- 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) { // We need room for +1000 for ZK
- 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
- }
- }
-
- if (!Boolean.parseBoolean((String)
project.findProperty('solr.bats.nightly'))) {
- task.filterTags = '!nightly'
- }
-
- task.reportDir = integrationTestOutput
- task.inputs.dir(distDir)
- task.inputs.dir('test') // Track .bats test files and helper as inputs
- task.outputs.dir(integrationTestOutput)
-
- task.doFirst {
- delete integrationTestOutput
- mkdir integrationTestOutput
- mkdir solrHome
- mkdir solrTestFailuresDir
-
- // TODO - if quiet then don't tee
- task.standardOutput = new TeeOutputStream(System.out,
- new FileOutputStream("$integrationTestOutput/test-output.txt"))
- println("Running BATS tests with Solr base port ${solrPort}")
- }
-
- task.environment SOLR_TIP: distDir.toString()
- task.environment SOLR_HOME: solrHome
- task.environment SOLR_PID_DIR: solrHome
- task.environment SOLR_PORT_LISTEN: solrPort
- task.environment SOLR_PORT: solrPort
- task.environment SOLR2_PORT: solrPort + 1
- task.environment SOLR3_PORT: solrPort + 2
- task.environment ZK_PORT: solrPort + 1000
- task.environment SOLR_LOGS_DIR: "$solrHome/logs"
- task.environment TEST_OUTPUT_DIR: integrationTestOutput
- task.environment TEST_FAILURE_DIR: solrTestFailuresDir
- task.environment BATS_LIB_PREFIX: batsLibsDir
- if (!usePicocli) {
- task.environment SOLR_PICOCLI: 'false'
- }
-}
-
// CATS - Cross-platform Automated Testing System - the CLI suites built on the
// org.apache.solr.cats harness and its Solr layer org.apache.solr.shell, both
in
-// solr/test-framework. Like the BATS suites these need the
-// unpacked distribution, so they are not part of 'check' and the stock 'test'
task is turned off.
+// solr/test-framework. They need the unpacked distribution, so they are not
part of 'check' and
+// the stock 'test' task is turned off.
tasks.named('test') {
enabled = false
}
-// Shared configuration for the CATS suites, mirroring configureBatsTask.
outputName keeps
-// each variant's SOLR_HOMEs, port-block counter and failure snapshots apart;
picocli selects the
-// CLI implementation, or null to take whatever bin/solr defaults to.
+// Shared configuration for the CATS suites. outputName keeps each variant's
SOLR_HOMEs, port-block
+// counter and failure snapshots apart; picocli selects the CLI
implementation, or null to take
Review Comment:
small tweak, but "picocli selects the CLI"? Maybe "Defaults to picocli as
the CLI implementation"?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]