|
3 | 3 | # Debugging
|
4 | 4 | teardown () {
|
5 | 5 | echo
|
6 |
| - # TODO: figure out how to deal with this (output from previous run commands showing up along with the error message) |
7 |
| - echo "Note: ignore the lines between \"...failed\" above and here" |
8 |
| - echo |
9 |
| - echo "Status: $status" |
10 | 6 | echo "Output:"
|
11 | 7 | echo "================================================================"
|
12 |
| - echo "$output" |
| 8 | + echo "${output}" |
13 | 9 | echo "================================================================"
|
14 | 10 | }
|
15 | 11 |
|
16 | 12 | # Checks container health status (if available)
|
17 | 13 | # @param $1 container id/name
|
18 | 14 | _healthcheck ()
|
19 | 15 | {
|
20 |
| - local health_status |
21 |
| - health_status=$(docker inspect --format='{{json .State.Health.Status}}' "$1" 2>/dev/null) |
| 16 | + local health_status |
| 17 | + health_status=$(docker inspect --format='{{json .State.Health.Status}}' "$1" 2>/dev/null) |
22 | 18 |
|
23 |
| - # Wait for 5s then exit with 0 if a container does not have a health status property |
24 |
| - # Necessary for backward compatibility with images that do not support health checks |
25 |
| - if [[ $? != 0 ]]; then |
26 |
| - echo "Waiting 10s for container to start..." |
27 |
| - sleep 10 |
28 |
| - return 0 |
29 |
| - fi |
| 19 | + # Wait for 5s then exit with 0 if a container does not have a health status property |
| 20 | + # Necessary for backward compatibility with images that do not support health checks |
| 21 | + if [[ $? != 0 ]]; then |
| 22 | + echo "Waiting 10s for container to start..." |
| 23 | + sleep 10 |
| 24 | + return 0 |
| 25 | + fi |
30 | 26 |
|
31 |
| - # If it does, check the status |
32 |
| - echo $health_status | grep '"healthy"' >/dev/null 2>&1 |
| 27 | + # If it does, check the status |
| 28 | + echo $health_status | grep '"healthy"' >/dev/null 2>&1 |
33 | 29 | }
|
34 | 30 |
|
35 | 31 | # Waits for containers to become healthy
|
36 |
| -# For reasoning why we are not using `depends_on` `condition` see here: |
37 |
| -# https://github.com/docksal/docksal/issues/225#issuecomment-306604063 |
38 | 32 | _healthcheck_wait ()
|
39 | 33 | {
|
40 |
| - # Wait for cli to become ready by watching its health status |
41 |
| - local container_name="${NAME}" |
42 |
| - local delay=5 |
43 |
| - local timeout=30 |
44 |
| - local elapsed=0 |
| 34 | + # Wait for cli to become ready by watching its health status |
| 35 | + local container_name="${NAME}" |
| 36 | + local delay=5 |
| 37 | + local timeout=30 |
| 38 | + local elapsed=0 |
45 | 39 |
|
46 |
| - until _healthcheck "$container_name"; do |
47 |
| - echo "Waiting for $container_name to become ready..." |
48 |
| - sleep "$delay"; |
| 40 | + until _healthcheck "$container_name"; do |
| 41 | + echo "Waiting for $container_name to become ready..." |
| 42 | + sleep "$delay"; |
49 | 43 |
|
50 |
| - # Give the container 30s to become ready |
51 |
| - elapsed=$((elapsed + delay)) |
52 |
| - if ((elapsed > timeout)); then |
53 |
| - echo-error "$container_name heathcheck failed" \ |
54 |
| - "Container did not enter a healthy state within the expected amount of time." \ |
55 |
| - "Try ${yellow}fin restart${NC}" |
56 |
| - exit 1 |
57 |
| - fi |
58 |
| - done |
| 44 | + # Give the container 30s to become ready |
| 45 | + elapsed=$((elapsed + delay)) |
| 46 | + if ((elapsed > timeout)); then |
| 47 | + echo "$container_name heathcheck failed" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + done |
59 | 51 |
|
60 |
| - return 0 |
| 52 | + return 0 |
61 | 53 | }
|
62 | 54 |
|
63 |
| -# Global skip |
64 |
| -# Uncomment below, then comment skip in the test you want to debug. When done, reverse. |
65 |
| -#SKIP=1 |
| 55 | +# To work on a specific test: |
| 56 | +# run `export SKIP=1` locally, then comment skip in the test you want to debug |
66 | 57 |
|
67 |
| -@test "Bare server" { |
| 58 | +@test "Bare service" { |
68 | 59 | [[ $SKIP == 1 ]] && skip
|
69 | 60 |
|
70 | 61 | ### Setup ###
|
|
0 commit comments