Skip to content

Commit 56cccb7

Browse files
authored
Add healthcheck for shibboleth-idp in idp-fixture (again) (#100461) (#100523)
(cherry picked from commit d0c263b)
1 parent f94d126 commit 56cccb7

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

x-pack/test/idp-fixture/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ apply plugin: 'elasticsearch.test.fixtures'
66

77
dockerCompose {
88
composeAdditionalArgs = ['--compatibility']
9+
10+
if (System.getenv('BUILDKITE') == 'true') {
11+
// This flag is only available on newer versions of docker-compose, and many Jenkins agents have older versions
12+
upAdditionalArgs = ["--wait"]
13+
}
914
}
1015

1116
tasks.named("preProcessFixture").configure {

x-pack/test/idp-fixture/docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3.7'
1+
version: "3.7"
22
services:
33
openldap:
44
command: --copy-service --loglevel debug
@@ -37,6 +37,12 @@ services:
3737
links:
3838
- openldap:openldap
3939
restart: always #ensure ephemeral port mappings are properly updated
40+
healthcheck:
41+
test: curl -f -s --http0.9 http://localhost:4443 --connect-timeout 10 --max-time 10 --output - > /dev/null
42+
interval: 5s
43+
timeout: 20s
44+
retries: 60
45+
start_period: 10s
4046

4147
oidc-provider:
4248
build:

x-pack/test/idp-fixture/idp/bin/run-jetty.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,19 @@ fi
1010
export JETTY_ARGS="jetty.sslContext.keyStorePassword=$JETTY_BROWSER_SSL_KEYSTORE_PASSWORD jetty.backchannel.sslContext.keyStorePassword=$JETTY_BACKCHANNEL_SSL_KEYSTORE_PASSWORD"
1111
sed -i "s/^-Xmx.*$/-Xmx$JETTY_MAX_HEAP/g" /opt/shib-jetty-base/start.ini
1212

13-
exec /opt/jetty-home/bin/jetty.sh run
13+
# For some reason, this container always immediately (in less than 1 second) exits with code 0 when starting for the first time
14+
# Even with a health check, docker-compose will immediately report the container as unhealthy when using --wait instead of waiting for it to become healthy
15+
# So, let's just start it a second time if it exits quickly
16+
set +e
17+
start_time=$(date +%s)
18+
/opt/jetty-home/bin/jetty.sh run
19+
exit_code=$?
20+
end_time=$(date +%s)
21+
22+
duration=$((end_time - start_time))
23+
if [ $duration -lt 5 ]; then
24+
/opt/jetty-home/bin/jetty.sh run
25+
exit_code=$?
26+
fi
27+
28+
exit $exit_code

0 commit comments

Comments
 (0)