dsmiley commented on code in PR #4227:
URL: https://github.com/apache/solr/pull/4227#discussion_r3285137101


##########
dev-tools/scripts/checkTestExternalClient.py:
##########
@@ -0,0 +1,118 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# 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.
+
+"""
+Standalone smoke-test for Solr Maven artifacts: builds the 
test-external-client project
+against locally published Solr artifacts to verify that solr-solrj and 
solr-test-framework
+can be consumed from their published POMs.
+
+This test can be run independently of the full smokeTestRelease.py suite.
+It uses the test-external-client project checked into the repository root, 
which has
+both Maven (pom.xml) and Gradle (build.gradle.kts) build files.  Both are 
exercised.
+
+Set JAVA_HOME if you need to point at a specific JDK.
+
+Usage examples:
+
+  # Test against a local Maven repository (produced by "gradlew 
mavenToLocalFolder"):
+  python3 checkTestExternalClient.py --maven-dir build/maven-local 10.0.0
+
+  # Test against a release-candidate Maven staging URL (artifacts are 
downloaded):
+  python3 checkTestExternalClient.py --url 
https://dist.apache.org/repos/dist/dev/solr/solr-10.0.0-RC1-rev-abc1234/maven 
10.0.0
+
+Requirements: Maven (mvn) or Docker must be available for the Maven build.  
The Gradle
+build uses the gradlew wrapper in the repository root.
+"""
+
+import argparse
+import os
+import sys
+import tempfile
+import textwrap
+
+# Import utilities from smokeTestRelease located in the same directory
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+import smokeTestRelease
+
+
+def parse_config():
+  epilog = textwrap.dedent('''
+    Examples:
+      # Use locally published Maven artifacts (run "gradlew 
mavenToLocalFolder" first):
+      python3 checkTestExternalClient.py --maven-dir build/maven-local 10.0.0
+
+      # Download Maven artifacts from a release-candidate staging URL:
+      python3 checkTestExternalClient.py --url 
https://dist.apache.org/repos/dist/dev/solr/solr-10.0.0-RC1-rev-abc1234/maven 
10.0.0
+  ''')
+  parser = argparse.ArgumentParser(
+    description='Build the test-external-client project against Solr Maven 
artifacts.',
+    epilog=epilog,
+    formatter_class=argparse.RawDescriptionHelpFormatter)
+
+  parser.add_argument('version', metavar='X.Y.Z',
+                      help='Solr version to test (e.g. 10.0.0)')
+
+  source = parser.add_mutually_exclusive_group(required=True)
+  source.add_argument('--maven-dir', metavar='DIR',
+                      help='Local Maven repository directory whose root 
contains '
+                           'org/apache/solr/ (e.g. the output of "gradlew 
mavenToLocalFolder")')
+  source.add_argument('--url', metavar='URL',

Review Comment:
   in retrospect, I suggest "repo-url"



##########
dev-tools/scripts/smokeTestRelease.py:
##########
@@ -633,7 +633,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, 
version, testArgs):
   #     in_root_folder.remove(fileName)
 
   if isSrc:
-    expected_src_root_folders = ['build-tools', 'changelog', 'dev-docs', 
'dev-tools', 'gradle', 'solr']
+    expected_src_root_folders = ['build-tools', 'changelog', 'dev-docs', 
'dev-tools', 'gradle', 'solr', 'test-external-client']

Review Comment:
   I don't want this to be underneath `solr/` somewhere because of the 
ExternalPaths bug.  Even the [current 
code](https://github.com/apache/solr/blob/1da74ce73a6dffd78568b9f17b4be2dbe307c10a/solr/test-framework/src/java/org/apache/solr/util/ExternalPaths.java#L86)
 wouldn't be properly tested if placed there.
   
   Happy to hear suggestions.  I surmise you want it moved out of a matter of 
taste/preference.  I think at the top level it communicates a separation that 
is the point. 



##########
dev-tools/scripts/smokeTestRelease.py:
##########
@@ -788,6 +788,66 @@ def testSolrExample(binaryDistPath, javaPath, isSlim):
   os.chdir(old_cwd)
 
 
+def findMaven():
+  """Find the mvn executable in PATH. Returns the command path, or None if not 
found."""
+  import shutil as shutil_util
+  return shutil_util.which('mvn')
+
+
+def _dockerAvailable():
+  """Check whether Docker is installed and the daemon is running."""
+  import shutil as shutil_util
+  if shutil_util.which('docker') is None:
+    return False
+  return os.system('docker info > /dev/null 2>&1') == 0
+
+
+def testMavenBuild(mavenDir, tmpDir, version):
+  """
+  Runs the test-external-client project with both Maven and Gradle to verify 
that the
+  published POMs for solr-solrj and solr-test-framework declare correct 
transitive
+  dependencies.
+
+  mavenDir: root of the local Maven repository (contains org/apache/solr/...)
+  tmpDir: temp directory for log files
+  version: Solr version string (e.g. "10.0.0")
+  """
+  print('    test external client project (verify POMs are consumable)...')
+
+  scriptDir = os.path.dirname(os.path.abspath(__file__))
+  projectDir = os.path.normpath(os.path.join(scriptDir, '..', '..', 
'test-external-client'))

Review Comment:
   I don't see the version extraction you speak of where you are commenting.  
Version is passed as a param.



##########
test-external-client/README.md:
##########
@@ -0,0 +1,44 @@
+# Solr dependency smoke test (Maven + Gradle)
+
+This mini project validates that a standalone build can resolve Solr artifacts 
from a Maven-style local directory tree and run a basic test using them.
+
+## Inputs
+
+- `solr.version` (required): version of `solr-solrj` and `solr-test-framework`
+- `local.solr.repo` (optional): filesystem path to a Maven-layout repository 
(default: `~/.m2/repository`)
+
+## Run with Maven
+
+```bash
+# build local artifacts to build/maven-local
+./gradlew mavenToLocalFolder
+
+(cd test-external-client && mvn \
+  -Dsolr.version=11.0.0-SNAPSHOT \
+  -Dlocal.solr.repo="$PWD/../build/maven-local" \
+  test)
+```
+
+To force Maven to avoid online repos while resolving, add `-o` (offline).
+
+## Run with Gradle
+
+```bash
+# build local artifacts to build/maven-local
+./gradlew mavenToLocalFolder
+
+(cd test-external-client && ../gradlew \
+  -Psolr.version=11.0.0-SNAPSHOT \
+  -Plocal.solr.repo="$PWD/../build/maven-local" \
+  test)
+```
+
+## Optional: use Maven Wrapper

Review Comment:
   I should remove this; no point.  Chicken & egg :-)



##########
test-external-client/README.md:
##########
@@ -0,0 +1,44 @@
+# Solr dependency smoke test (Maven + Gradle)
+
+This mini project validates that a standalone build can resolve Solr artifacts 
from a Maven-style local directory tree and run a basic test using them.
+
+## Inputs
+
+- `solr.version` (required): version of `solr-solrj` and `solr-test-framework`
+- `local.solr.repo` (optional): filesystem path to a Maven-layout repository 
(default: `~/.m2/repository`)
+

Review Comment:
   good point but will standardize on ~/.m2/repository



##########
test-external-client/pom.xml:
##########
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.solr</groupId>
+  <artifactId>test-external-client</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Solr Dependency Smoke Test</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.release>21</maven.compiler.release>
+    <local.solr.repo>${user.home}/.m2/repository</local.solr.repo>
+    <solr.version>11.0.0-SNAPSHOT</solr.version>
+  </properties>

Review Comment:
   ehh; unlikely a real issue



##########
dev-tools/scripts/checkTestExternalClient.py:
##########
@@ -0,0 +1,118 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# 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.
+
+"""
+Standalone smoke-test for Solr Maven artifacts: builds the 
test-external-client project
+against locally published Solr artifacts to verify that solr-solrj and 
solr-test-framework
+can be consumed from their published POMs.
+
+This test can be run independently of the full smokeTestRelease.py suite.
+It uses the test-external-client project checked into the repository root, 
which has
+both Maven (pom.xml) and Gradle (build.gradle.kts) build files.  Both are 
exercised.
+
+Set JAVA_HOME if you need to point at a specific JDK.
+
+Usage examples:
+
+  # Test against a local Maven repository (produced by "gradlew 
mavenToLocalFolder"):
+  python3 checkTestExternalClient.py --maven-dir build/maven-local 10.0.0
+
+  # Test against a release-candidate Maven staging URL (artifacts are 
downloaded):
+  python3 checkTestExternalClient.py --url 
https://dist.apache.org/repos/dist/dev/solr/solr-10.0.0-RC1-rev-abc1234/maven 
10.0.0
+
+Requirements: Maven (mvn) or Docker must be available for the Maven build.  
The Gradle
+build uses the gradlew wrapper in the repository root.
+"""
+
+import argparse
+import os
+import sys
+import tempfile
+import textwrap
+
+# Import utilities from smokeTestRelease located in the same directory
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+import smokeTestRelease
+
+
+def parse_config():
+  epilog = textwrap.dedent('''
+    Examples:
+      # Use locally published Maven artifacts (run "gradlew 
mavenToLocalFolder" first):
+      python3 checkTestExternalClient.py --maven-dir build/maven-local 10.0.0
+
+      # Download Maven artifacts from a release-candidate staging URL:
+      python3 checkTestExternalClient.py --url 
https://dist.apache.org/repos/dist/dev/solr/solr-10.0.0-RC1-rev-abc1234/maven 
10.0.0
+  ''')
+  parser = argparse.ArgumentParser(
+    description='Build the test-external-client project against Solr Maven 
artifacts.',
+    epilog=epilog,
+    formatter_class=argparse.RawDescriptionHelpFormatter)
+
+  parser.add_argument('version', metavar='X.Y.Z',
+                      help='Solr version to test (e.g. 10.0.0)')
+
+  source = parser.add_mutually_exclusive_group(required=True)
+  source.add_argument('--maven-dir', metavar='DIR',

Review Comment:
   in retro-spect, I suggest "repo-dir" so as to not confuse what's in the dir 
with maven itself or a maven project perhaps.



##########
dev-tools/scripts/smokeTestRelease.py:
##########
@@ -809,6 +869,8 @@ def checkMaven(baseURL, tmpDir, gitRevision, version, 
isSigned, keysFile):
 
   checkAllJARs('%s/maven/org/apache/solr' % tmpDir, gitRevision, version)
 
+  testMavenBuild('%s/maven' % tmpDir, tmpDir, version)

Review Comment:
   good point; opt-out -- agree.



##########
test-external-client/pom.xml:
##########
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.solr</groupId>
+  <artifactId>test-external-client</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Solr Dependency Smoke Test</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.release>21</maven.compiler.release>
+    <local.solr.repo>${user.home}/.m2/repository</local.solr.repo>
+    <solr.version>11.0.0-SNAPSHOT</solr.version>

Review Comment:
   agree



##########
dev-tools/scripts/smokeTestRelease.py:
##########
@@ -788,6 +788,66 @@ def testSolrExample(binaryDistPath, javaPath, isSlim):
   os.chdir(old_cwd)
 
 
+def findMaven():
+  """Find the mvn executable in PATH. Returns the command path, or None if not 
found."""
+  import shutil as shutil_util
+  return shutil_util.which('mvn')
+
+
+def _dockerAvailable():
+  """Check whether Docker is installed and the daemon is running."""
+  import shutil as shutil_util
+  if shutil_util.which('docker') is None:
+    return False
+  return os.system('docker info > /dev/null 2>&1') == 0
+
+
+def testMavenBuild(mavenDir, tmpDir, version):
+  """
+  Runs the test-external-client project with both Maven and Gradle to verify 
that the
+  published POMs for solr-solrj and solr-test-framework declare correct 
transitive
+  dependencies.
+
+  mavenDir: root of the local Maven repository (contains org/apache/solr/...)
+  tmpDir: temp directory for log files
+  version: Solr version string (e.g. "10.0.0")
+  """
+  print('    test external client project (verify POMs are consumable)...')
+
+  scriptDir = os.path.dirname(os.path.abspath(__file__))
+  projectDir = os.path.normpath(os.path.join(scriptDir, '..', '..', 
'test-external-client'))
+  if not os.path.isdir(projectDir):
+    raise RuntimeError('test-external-client directory not found at: %s' % 
projectDir)
+
+  # Run Maven build
+  mvnCmd = findMaven()
+  if mvnCmd is not None:
+    print('      using local Maven: %s' % mvnCmd)
+    run('%s -B -f "%s/pom.xml" -Dsolr.version="%s" -Dlocal.solr.repo="%s" test'
+        % (mvnCmd, projectDir, version, mavenDir), os.path.join(tmpDir, 
'maven-build.log'))
+  elif _dockerAvailable():
+    print('      Maven not found; using Docker Maven image...')
+    # Note: the Docker image already includes Java 21
+    # Project is mounted writable so Maven can write its build output directory
+    run('docker run --rm'
+        ' -v "%s":/project'
+        ' -v "%s":/solr-local-release:ro'
+        ' maven:3.9-eclipse-temurin-21'
+        ' mvn -B -f /project/pom.xml -Dsolr.version="%s" 
-Dlocal.solr.repo=/solr-local-release test'
+        % (projectDir, mavenDir, version), os.path.join(tmpDir, 
'maven-build.log'))
+  else:
+    print('      WARNING: Neither Maven nor Docker found; skipping Maven 
build.')
+    print('               Install Maven or Docker to enable this check.')
+
+  # Also run Gradle build
+  gradlew = os.path.normpath(os.path.join(projectDir, '..', 'gradlew'))
+  print('      using Gradle: %s' % gradlew)
+  run('"%s" --no-daemon -p "%s" -Psolr.version="%s" -Plocal.solr.repo="%s" 
test'
+      % (gradlew, projectDir, version, mavenDir), os.path.join(tmpDir, 
'gradle-build.log'))
+
+  print('    external client project: SUCCESS')

Review Comment:
   ehh; at least the gradle one always runs so that's fine.



-- 
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]

Reply via email to