bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/build/test-startup.sh (about)

     1  #!/bin/bash
     2  
     3  echo "Testing that bosun starts and stops cleanly"
     4  
     5  # Generate a minimal config
     6  echo 'RuleFilePath = "/tmp/rule.conf"' > /tmp/bosun.toml
     7  touch /tmp/rule.conf
     8  
     9  # Wait for at most 30 seconds before considering the launch a failure
    10  timeout 30 ./bosun -c /tmp/bosun.toml & TIMEOUT_PID=$!
    11  BOSUN_START_RESULT=$?
    12  
    13  # Give Bosun 5 seconds to start, then stop cleanly
    14  sleep 5
    15  kill -SIGINT $TIMEOUT_PID
    16  BOSUN_SIGNAL_RESULT=$?
    17  
    18  # Wait for the process to exit
    19  wait $TIMEOUT_PID
    20  TIMEOUT_RESULT=$?
    21  
    22  if [ "$BOSUN_START_RESULT" != 0 ]; then
    23      echo "Failed to start bosun cleanly. Exit code ${BOSUN_START_RESULT}"
    24  fi
    25  if [ "$BOSUN_SIGNAL_RESULT" != 0 ]; then
    26      echo "Failed to signal bosun to stop cleanly. Likely crashed before signal sent."
    27  fi
    28  if [ "$BOSUN_STOP_RESULT" != 0 ]; then
    29      echo "Failed to stop bosun cleanly. Exit code ${TIMEOUT_RESULT} (124=60s test timeout reached)"
    30  fi
    31  
    32  (( RESULT = BOSUN_START_RESULT | BOSUN_SIGNAL_RESULT | BOSUN_STOP_RESULT ))
    33  exit $RESULT