Skip to content

Commit 80dfe11

Browse files
committed
SOLR-17556: Fix smokeTest to use films as example for slim distribution
1 parent 796b788 commit 80dfe11

2 files changed

Lines changed: 39 additions & 10 deletions

File tree

dev-tools/scripts/smokeTestRelease.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
690690
shutil.copytree(unpackPath, java11UnpackPath)
691691
os.chdir(java11UnpackPath)
692692
print(' test solr example w/ Java 11...')
693-
testSolrExample(java11UnpackPath, java.java11_home)
693+
testSolrExample(java11UnpackPath, java.java11_home, isSlim)
694694

695695
if java.run_java17:
696696
print(' copying unpacked distribution for Java 17 ...')
@@ -700,7 +700,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
700700
shutil.copytree(unpackPath, java17UnpackPath)
701701
os.chdir(java17UnpackPath)
702702
print(' test solr example w/ Java 17...')
703-
testSolrExample(java17UnpackPath, java.java17_home)
703+
testSolrExample(java17UnpackPath, java.java17_home, isSlim)
704704

705705
os.chdir(unpackPath)
706706

@@ -742,7 +742,7 @@ def is_port_in_use(port):
742742
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
743743
return s.connect_ex(('localhost', port)) == 0
744744

745-
def testSolrExample(binaryDistPath, javaPath):
745+
def testSolrExample(binaryDistPath, javaPath, isSlim):
746746
# test solr using some examples it comes with
747747
logFile = '%s/solr-example.log' % binaryDistPath
748748
old_cwd = os.getcwd() # So we can back-track
@@ -754,6 +754,10 @@ def testSolrExample(binaryDistPath, javaPath):
754754
env['JAVA_HOME'] = javaPath
755755
env['PATH'] = '%s/bin:%s' % (javaPath, env['PATH'])
756756

757+
example = "techproducts"
758+
if isSlim:
759+
example = "films"
760+
757761
# Stop Solr running on port 8983 (in case a previous run didn't shutdown cleanly)
758762
try:
759763
if not cygwin:
@@ -763,20 +767,20 @@ def testSolrExample(binaryDistPath, javaPath):
763767
except:
764768
print(' Stop failed due to: '+sys.exc_info()[0])
765769

766-
print(' Running techproducts example on port 8983 from %s' % binaryDistPath)
770+
print(' Running %s example on port 8983 from %s' % (example, binaryDistPath))
767771
try:
768772
if not cygwin:
769-
runExampleStatus = subprocess.call(['bin/solr','start','-e','techproducts'])
773+
runExampleStatus = subprocess.call(['bin/solr','start','-e',example])
770774
else:
771-
runExampleStatus = subprocess.call('env "PATH=`cygpath -S -w`:$PATH" bin/solr.cmd -e techproducts', shell=True)
775+
runExampleStatus = subprocess.call('env "PATH=`cygpath -S -w`:$PATH" bin/solr.cmd -e ' + example, shell=True)
772776

773777
if runExampleStatus != 0:
774-
raise RuntimeError('Failed to run the techproducts example, check log for previous errors.')
778+
raise RuntimeError('Failed to run the %s example, check log for previous errors.' % example)
775779

776780
os.chdir('example')
777781
print(' run query...')
778-
s = load('http://localhost:8983/solr/techproducts/select/?q=video')
779-
if s.find('"numFound":3,') == -1:
782+
s = load('http://localhost:8983/solr/%s/select/?q=video' % example)
783+
if s.find('"numFound":%d,' % (8 if isSlim else 3)) == -1:
780784
print('FAILED: response is:\n%s' % s)
781785
raise RuntimeError('query on solr example instance failed')
782786
s = load('http://localhost:8983/api/cores')

solr/core/src/java/org/apache/solr/cli/RunExampleTool.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
382382
+ " }\n"
383383
+ " }");
384384

385-
echo("Adding name, initial_release_date, and film_vector fields to films schema");
385+
echo(
386+
"Adding name, genre, directed_by, initial_release_date, and film_vector fields to films schema");
386387
SolrCLI.postJsonToSolr(
387388
solrClient,
388389
"/" + collectionName + "/schema",
@@ -394,6 +395,18 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
394395
+ " \"stored\":true\n"
395396
+ " },\n"
396397
+ " \"add-field\" : {\n"
398+
+ " \"name\":\"genre\",\n"
399+
+ " \"type\":\"text_general\",\n"
400+
+ " \"multiValued\":true,\n"
401+
+ " \"stored\":true\n"
402+
+ " },\n"
403+
+ " \"add-field\" : {\n"
404+
+ " \"name\":\"directed_by\",\n"
405+
+ " \"type\":\"text_general\",\n"
406+
+ " \"multiValued\":true,\n"
407+
+ " \"stored\":true\n"
408+
+ " },\n"
409+
+ " \"add-field\" : {\n"
397410
+ " \"name\":\"initial_release_date\",\n"
398411
+ " \"type\":\"pdate\",\n"
399412
+ " \"stored\":true\n"
@@ -403,6 +416,18 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
403416
+ " \"type\":\"knn_vector_10\",\n"
404417
+ " \"indexed\":true\n"
405418
+ " \"stored\":true\n"
419+
+ " },\n"
420+
+ " \"add-copy-field\" : {\n"
421+
+ " \"source\":\"genre\",\n"
422+
+ " \"dest\":\"_text_\"\n"
423+
+ " },\n"
424+
+ " \"add-copy-field\" : {\n"
425+
+ " \"source\":\"name\",\n"
426+
+ " \"dest\":\"_text_\"\n"
427+
+ " },\n"
428+
+ " \"add-copy-field\" : {\n"
429+
+ " \"source\":\"directed_by\",\n"
430+
+ " \"dest\":\"_text_\"\n"
406431
+ " }\n"
407432
+ " }");
408433

0 commit comments

Comments
 (0)