adamsaghy commented on code in PR #5082:
URL: https://github.com/apache/fineract/pull/5082#discussion_r2432621017
##########
integration-tests/build.gradle:
##########
@@ -88,15 +88,30 @@ cargo {
cargoRunLocal.dependsOn ':fineract-war:war'
cargoStartLocal.dependsOn ':fineract-war:war'
-cargoStartLocal.mustRunAfter 'testClasses'
-if (!project.hasProperty('cargoDisabled')) {
- test {
- dependsOn(cargoStartLocal)
+String waitForFineractTimeoutSeconds =
project.findProperty('waitForFineractTimeoutSeconds') ?: '600'
+String waitForFineractCommand = "timeout ${waitForFineractTimeoutSeconds} bash
-c 'until curl -k -s --fail
\"https://localhost:8443/fineract-provider/actuator/health\" > /dev/null; do
sleep 5; echo \"Waiting for Fineract startup...\"; done'"
+
+tasks.register('waitForFineract') {
+ doLast {
+ exec {
+ commandLine 'bash', '-lc', waitForFineractCommand
+ }
+ }
+}
Review Comment:
Can we have something like this instead?
```
import java.net.HttpURLConnection
import java.net.URL
tasks.register('waitForFineract') {
doLast {
int timeoutSeconds =
(project.findProperty('waitForFineractTimeoutSeconds') ?: '600') as int
int waited = 0
int interval = 5
URL url = new
URL("https://localhost:8443/fineract-provider/actuator/health")
println "Waiting for Fineract startup (timeout:
${timeoutSeconds}s)..."
while (waited < timeoutSeconds) {
try {
HttpURLConnection connection = (HttpURLConnection)
url.openConnection()
connection.setConnectTimeout(2000)
connection.setReadTimeout(2000)
connection.setRequestMethod("GET")
int responseCode = connection.getResponseCode()
if (responseCode == 200) {
println "Fineract is up!"
return
}
} catch (Exception ignored) { }
sleep(interval * 1000)
waited += interval
println "Still waiting..."
}
throw new GradleException("Fineract did not start within
${timeoutSeconds} seconds")
}
}
```
--
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]