@@ -175,12 +175,48 @@ pipeline {
175175 export PATH=$GRADLE_USER_HOME:$JAVA_HOME/bin:$PATH
176176 cd java-client-api
177177 // Ensure all modules can be built first.
178- ./gradlew clean build -x test
178+ // ./gradlew clean build -x test
179179
180180 // Run a sufficient number of tests to verify the PR.
181181 // Temporarily running a single test to debug the reverse proxy server
182182 //./gradlew cleanTest marklogic-client-api:test || true
183- ./gradlew -PtestUseReverseProxyServer=true runReverseProxyServer marklogic-client-api:test --tests ReadDocumentPageTest || true
183+
184+ // Use a random port to avoid conflicts from previous builds
185+ PROXY_PORT=$((8020 + RANDOM % 1000))
186+ echo "Using reverse proxy port: $PROXY_PORT"
187+
188+ // Check if anything is already using this port
189+ echo "Checking what's using port $PROXY_PORT before starting proxy..."
190+ netstat -tuln | grep $PROXY_PORT || echo "Port $PROXY_PORT is free"
191+
192+ // Start reverse proxy server in background and capture its PID
193+ ./gradlew -PtestUseReverseProxyServer=true -PrpsHttpPort=$PROXY_PORT test-app:runBlockingReverseProxyServer --stacktrace > reverse-proxy.log 2>&1 &
194+ PROXY_PID=$!
195+ echo "Started reverse proxy server with PID: $PROXY_PID"
196+
197+ // Wait for proxy server to be ready
198+ sleep 5
199+
200+ // Check if proxy server is actually listening on the port
201+ echo "Checking if reverse proxy is listening on port $PROXY_PORT..."
202+ netstat -tuln | grep $PROXY_PORT || echo "WARNING: No process listening on port $PROXY_PORT!"
203+
204+ // Show the last few lines of the proxy log
205+ echo "Reverse proxy log (last 20 lines):"
206+ tail -20 reverse-proxy.log || echo "No log file found"
207+
208+ // Run tests
209+ ./gradlew -PtestUseReverseProxyServer=true -DTEST_REVERSE_PROXY_PORT=$PROXY_PORT marklogic-client-api:test --tests ReadDocumentPageTest || true
210+
211+ // Show the reverse proxy log after tests complete
212+ echo "Reverse proxy log after tests (last 50 lines):"
213+ tail -50 reverse-proxy.log || echo "No log file found"
214+
215+ // Kill the reverse proxy server
216+ echo "Stopping reverse proxy server (PID: $PROXY_PID)"
217+ kill $PROXY_PID 2>/dev/null || true
218+ sleep 2
219+ kill -9 $PROXY_PID 2>/dev/null || true
184220 '''
185221 // Omitting this until MLE-24523 can be addressed
186222 // ./gradlew -PtestUseReverseProxyServer=true test-app:runReverseProxyServer marklogic-client-api-functionaltests:runFastFunctionalTests || true
0 commit comments