janhoy commented on code in PR #3810:
URL: https://github.com/apache/solr/pull/3810#discussion_r2481616848
##########
solr/packaging/powershell-tests/Zk.Tests.ps1:
##########
@@ -42,6 +42,81 @@ BeforeAll {
$script:ZK_PORT = if ($env:ZK_PORT) { $env:ZK_PORT } else { "9983" }
$script:SOLR_PORT = if ($env:SOLR_PORT) { $env:SOLR_PORT } else { "8983" }
+ # Check if Solr is already running
+ $solrAlreadyRunning = $false
+ try {
+ $response = Invoke-WebRequest -Uri "http://localhost:$SOLR_PORT/solr/"
-UseBasicParsing -TimeoutSec 2 -ErrorAction SilentlyContinue
+ if ($response.StatusCode -eq 200) {
+ $solrAlreadyRunning = $true
+ Write-Host "Solr is already running on port $SOLR_PORT"
+ }
+ } catch {
+ $solrAlreadyRunning = $false
+ }
+
+ $script:SolrStartedByTests = $false
+
+ # Start Solr if it's not already running
+ if (-not $solrAlreadyRunning) {
+ Write-Host "Starting Solr in cloud mode..."
+
+ # Start Solr with embedded ZooKeeper using Start-Process to run
asynchronously
+ $startArgs = @("start", "-p", "$SOLR_PORT")
+ Write-Host "Running: $SolrCmd $($startArgs -join ' ')"
+
+ # Use Start-Job with cmd.exe to properly parse arguments and maintain
process hierarchy
+ $solrJob = Start-Job -ScriptBlock {
+ param($cmd, $argString)
+ cmd /c "`"$cmd`" $argString" 2>&1
+ } -ArgumentList $SolrCmd, $startArgs
+
+ # Wait a bit for Solr to start
+ Start-Sleep -Seconds 5
+
+ Write-Host "Solr starting on port $SOLR_PORT (Job ID: $($solrJob.Id))"
+
+ # Check if there were any immediate errors
+ $jobOutput = Receive-Job -Job $solrJob -Keep
+ if ($jobOutput) {
+ Write-Host "Solr output: $jobOutput"
+ }
+
+ $script:SolrStartedByTests = $true
+
+ # Wait for Solr to be ready (max 60 seconds)
+ Write-Host "Waiting for Solr to be ready..."
+ $maxWaitTime = 60
+ $waitInterval = 2
+ $elapsed = 0
+ $solrReady = $false
+
+ while ($elapsed -lt $maxWaitTime) {
+ Start-Sleep -Seconds $waitInterval
+ $elapsed += $waitInterval
+
+ try {
+ $response = Invoke-WebRequest -Uri "http://localhost:$SOLR_PORT/solr/"
-UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
Review Comment:
Ok, thanks for explanation. Good candiate to hide behind a common utility
function `start_solr_and_wait(<port>)`
--
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]