running_test.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. set -x
  19. API_HEALTHCHECK_COMMAND="curl -I -m 10 -o /dev/null -s -w %{http_code} http://0.0.0.0:12345/dolphinscheduler/actuator/health"
  20. MASTER_HEALTHCHECK_COMMAND="curl -I -m 10 -o /dev/null -s -w %{http_code} http://0.0.0.0:5679/actuator/health"
  21. WORKER_HEALTHCHECK_COMMAND="curl -I -m 10 -o /dev/null -s -w %{http_code} http://0.0.0.0:1235/actuator/health"
  22. ALERT_HEALTHCHECK_COMMAND="curl -I -m 10 -o /dev/null -s -w %{http_code} http://0.0.0.0:50053/actuator/health"
  23. #Cluster start health check
  24. TIMEOUT=180
  25. START_HEALTHCHECK_EXITCODE=0
  26. for ((i=1; i<=TIMEOUT; i++))
  27. do
  28. MASTER_HTTP_STATUS=$(eval "$MASTER_HEALTHCHECK_COMMAND")
  29. WORKER_HTTP_STATUS=$(eval "$WORKER_HEALTHCHECK_COMMAND")
  30. API_HTTP_STATUS=$(eval "$API_HEALTHCHECK_COMMAND")
  31. ALERT_HTTP_STATUS=$(eval "$ALERT_HEALTHCHECK_COMMAND")
  32. if [[ $MASTER_HTTP_STATUS -eq 200 && $WORKER_HTTP_STATUS -eq 200 && $API_HTTP_STATUS -eq 200 && $ALERT_HTTP_STATUS -eq 200 ]];then
  33. START_HEALTHCHECK_EXITCODE=0
  34. else
  35. START_HEALTHCHECK_EXITCODE=2
  36. fi
  37. if [[ $START_HEALTHCHECK_EXITCODE -eq 0 ]];then
  38. echo "cluster start health check success"
  39. break
  40. fi
  41. if [[ $i -eq $TIMEOUT ]];then
  42. if [[ $MASTER_HTTP_STATUS -ne 200 ]];then
  43. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/master-server/logs/dolphinscheduler-master.log"
  44. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/master-server/logs/*.out"
  45. echo "master start health check failed"
  46. fi
  47. if [[ $WORKER_HTTP_STATUS -ne 200 ]]; then
  48. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/worker-server/logs/dolphinscheduler-worker.log"
  49. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/worker-server/logs/*.out"
  50. echo "worker start health check failed"
  51. fi
  52. if [[ $API_HTTP_STATUS -ne 200 ]]; then
  53. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/api-server/logs/dolphinscheduler-api.log"
  54. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/api-server/logs/*.out"
  55. echo "api start health check failed"
  56. fi
  57. if [[ $ALERT_HTTP_STATUS -ne 200 ]]; then
  58. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/alert-server/logs/dolphinscheduler-alert.log"
  59. docker exec -u root ds bash -c "cat /root/apache-dolphinscheduler-*-SNAPSHOT-bin/alert-server/logs/*.out"
  60. echo "alert start health check failed"
  61. fi
  62. exit $START_HEALTHCHECK_EXITCODE
  63. fi
  64. sleep 1
  65. done
  66. #Stop Cluster
  67. docker exec -u root ds bash -c "/root/apache-dolphinscheduler-*-SNAPSHOT-bin/bin/stop-all.sh"
  68. #Cluster stop health check
  69. sleep 5
  70. MASTER_HTTP_STATUS=$(eval "$MASTER_HEALTHCHECK_COMMAND")
  71. if [[ $MASTER_HTTP_STATUS -ne 200 ]];then
  72. echo "master stop health check success"
  73. else
  74. echo "master stop health check failed"
  75. exit 3
  76. fi
  77. WORKER_HTTP_STATUS=$(eval "$WORKER_HEALTHCHECK_COMMAND")
  78. if [[ $WORKER_HTTP_STATUS -ne 200 ]];then
  79. echo "worker stop health check success"
  80. else
  81. echo "worker stop health check failed"
  82. exit 3
  83. fi
  84. API_HTTP_STATUS=$(eval "$API_HEALTHCHECK_COMMAND")
  85. if [[ $API_HTTP_STATUS -ne 200 ]];then
  86. echo "api stop health check success"
  87. else
  88. echo "api stop health check failed"
  89. exit 3
  90. fi
  91. ALERT_HTTP_STATUS=$(eval "$ALERT_HEALTHCHECK_COMMAND")
  92. if [[ $ALERT_HTTP_STATUS -ne 200 ]];then
  93. echo "alert stop health check success"
  94. else
  95. echo "alert stop health check failed"
  96. exit 3
  97. fi