Skip to content

Commit

Permalink
SOLR-17556: Fix smokeTest to use films as example for slim distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
HoustonPutman committed Jan 9, 2025
1 parent 796b788 commit 80dfe11
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
22 changes: 13 additions & 9 deletions dev-tools/scripts/smokeTestRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
shutil.copytree(unpackPath, java11UnpackPath)
os.chdir(java11UnpackPath)
print(' test solr example w/ Java 11...')
testSolrExample(java11UnpackPath, java.java11_home)
testSolrExample(java11UnpackPath, java.java11_home, isSlim)

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

os.chdir(unpackPath)

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

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

example = "techproducts"
if isSlim:
example = "films"

# Stop Solr running on port 8983 (in case a previous run didn't shutdown cleanly)
try:
if not cygwin:
Expand All @@ -763,20 +767,20 @@ def testSolrExample(binaryDistPath, javaPath):
except:
print(' Stop failed due to: '+sys.exc_info()[0])

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

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

os.chdir('example')
print(' run query...')
s = load('http://localhost:8983/solr/techproducts/select/?q=video')
if s.find('"numFound":3,') == -1:
s = load('http://localhost:8983/solr/%s/select/?q=video' % example)
if s.find('"numFound":%d,' % (8 if isSlim else 3)) == -1:
print('FAILED: response is:\n%s' % s)
raise RuntimeError('query on solr example instance failed')
s = load('http://localhost:8983/api/cores')
Expand Down
27 changes: 26 additions & 1 deletion solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
+ " }\n"
+ " }");

echo("Adding name, initial_release_date, and film_vector fields to films schema");
echo(
"Adding name, genre, directed_by, initial_release_date, and film_vector fields to films schema");
SolrCLI.postJsonToSolr(
solrClient,
"/" + collectionName + "/schema",
Expand All @@ -394,6 +395,18 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
+ " \"stored\":true\n"
+ " },\n"
+ " \"add-field\" : {\n"
+ " \"name\":\"genre\",\n"
+ " \"type\":\"text_general\",\n"
+ " \"multiValued\":true,\n"
+ " \"stored\":true\n"
+ " },\n"
+ " \"add-field\" : {\n"
+ " \"name\":\"directed_by\",\n"
+ " \"type\":\"text_general\",\n"
+ " \"multiValued\":true,\n"
+ " \"stored\":true\n"
+ " },\n"
+ " \"add-field\" : {\n"
+ " \"name\":\"initial_release_date\",\n"
+ " \"type\":\"pdate\",\n"
+ " \"stored\":true\n"
Expand All @@ -403,6 +416,18 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
+ " \"type\":\"knn_vector_10\",\n"
+ " \"indexed\":true\n"
+ " \"stored\":true\n"
+ " },\n"
+ " \"add-copy-field\" : {\n"
+ " \"source\":\"genre\",\n"
+ " \"dest\":\"_text_\"\n"
+ " },\n"
+ " \"add-copy-field\" : {\n"
+ " \"source\":\"name\",\n"
+ " \"dest\":\"_text_\"\n"
+ " },\n"
+ " \"add-copy-field\" : {\n"
+ " \"source\":\"directed_by\",\n"
+ " \"dest\":\"_text_\"\n"
+ " }\n"
+ " }");

Expand Down

0 comments on commit 80dfe11

Please sign in to comment.