|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # |
3 | | -# Copyright (c) 2023 Eclipse RDF4J contributors. |
| 3 | +# Copyright (c) 2025 Eclipse RDF4J contributors. |
4 | 4 | # |
5 | 5 | # All rights reserved. This program and the accompanying materials |
6 | 6 | # are made available under the terms of the Eclipse Distribution License v1.0 |
|
12 | 12 |
|
13 | 13 | set -e |
14 | 14 |
|
| 15 | +SERVER_PID="" |
| 16 | + |
| 17 | +cleanup() { |
| 18 | + if [ -z "${SERVER_PID:-}" ]; then |
| 19 | + return |
| 20 | + fi |
| 21 | + |
| 22 | + # If the process is already gone, nothing to do |
| 23 | + if ! kill -0 "$SERVER_PID" 2>/dev/null; then |
| 24 | + return |
| 25 | + fi |
| 26 | + |
| 27 | + echo "Sending SIGINT to server-boot module (pid=$SERVER_PID)" |
| 28 | + kill -s INT "$SERVER_PID" 2>/dev/null || true |
| 29 | + |
| 30 | + # Wait for graceful shutdown after SIGINT |
| 31 | + for i in 1 2 3 4 5 6 7 8 9 10; do |
| 32 | + if ! kill -0 "$SERVER_PID" 2>/dev/null; then |
| 33 | + echo "server-boot module stopped gracefully after SIGINT" |
| 34 | + wait "$SERVER_PID" 2>/dev/null || true |
| 35 | + return |
| 36 | + fi |
| 37 | + kill -s INT "$SERVER_PID" 2>/dev/null || true |
| 38 | + sleep 0.5 |
| 39 | + done |
| 40 | + |
| 41 | + # Still alive: send a more aggressive TERM |
| 42 | + echo "Sending SIGTERM to server-boot module (pid=$SERVER_PID)" |
| 43 | + kill "$SERVER_PID" 2>/dev/null || true |
| 44 | + |
| 45 | + # Wait for graceful shutdown after SIGTERM |
| 46 | + for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do |
| 47 | + if ! kill -0 "$SERVER_PID" 2>/dev/null; then |
| 48 | + echo "server-boot module stopped after SIGTERM" |
| 49 | + wait "$SERVER_PID" 2>/dev/null || true |
| 50 | + return |
| 51 | + fi |
| 52 | + sleep 0.5 |
| 53 | + done |
| 54 | + |
| 55 | + # Still alive after: kill definitively |
| 56 | + echo "Sending SIGKILL to server-boot module (pid=$SERVER_PID)" |
| 57 | + kill -9 "$SERVER_PID" 2>/dev/null || true |
| 58 | + wait "$SERVER_PID" 2>/dev/null || true |
| 59 | +} |
| 60 | + |
| 61 | +trap cleanup EXIT |
| 62 | + |
15 | 63 | npm install |
16 | 64 |
|
17 | | -for APP_SERVER in tomcat jetty; do |
18 | | - export APP_SERVER |
| 65 | +cd .. |
19 | 66 |
|
20 | | - cd .. |
21 | | - cd docker |
22 | | - ./run.sh |
23 | | - ./waitForDocker.sh |
24 | | - cd .. |
25 | | - cd e2e |
| 67 | +mvn -q install -Pquick |
26 | 68 |
|
27 | | - sleep 10 |
| 69 | +mvn -pl tools/server-boot spring-boot:run & |
| 70 | +SERVER_PID=$! |
| 71 | +# server-boot module will be stopped automatically on script exit (see cleanup trap above). |
28 | 72 |
|
29 | | - if [ ! -d 'node_modules' ]; then |
30 | | - echo "npm ci" |
31 | | - npm ci |
32 | | - fi |
| 73 | +cd e2e |
33 | 74 |
|
34 | | - docker ps |
| 75 | +sleep 10 |
35 | 76 |
|
36 | | - npx playwright install --with-deps # install browsers |
37 | | - npx playwright test |
| 77 | +if [ ! -d 'node_modules' ]; then |
| 78 | + echo "npm ci" |
| 79 | + npm ci |
| 80 | +fi |
38 | 81 |
|
39 | | - status_npx=$? |
| 82 | +npx playwright install --with-deps # install browsers |
| 83 | +npx playwright test |
40 | 84 |
|
41 | | - cd .. |
42 | | - cd docker |
43 | | - ./shutdown.sh |
| 85 | +status_npx=$? |
44 | 86 |
|
45 | | - # test for error code |
46 | | - if [ $status_npx -ne 0 ] ; then |
47 | | - echo "Error in E2E test for $APP_SERVER" |
48 | | - exit $status_npx |
49 | | - fi |
| 87 | +cd .. |
50 | 88 |
|
51 | | - echo "E2E test for $APP_SERVER OK" |
| 89 | +# test for error code |
| 90 | +if [ $status_npx -ne 0 ]; then |
| 91 | + echo "Error in E2E test" |
| 92 | + exit $status_npx |
| 93 | +fi |
52 | 94 |
|
53 | | - # don't redo the whole build process just for making another docker image |
54 | | - export SKIP_BUILD="skip" |
55 | | -done |
| 95 | +echo "E2E test OK" |
56 | 96 |
|
| 97 | +# don't redo the whole build process just for making another docker image |
| 98 | +export SKIP_BUILD="skip" |
0 commit comments