Sha256: fa75844457845e000d9ee1f0523a207876356fc802f2b70f10c16ceebb984684

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

#!/bin/bash
set -e
set -x
shopt -s expand_aliases

export RUBYOPT="-W0"

alias zold="zold --network=test"
alias zold-stress="$1 --network=test"

zold --version

function reserve_port {
  python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'
}

function wait_for_url {
  i=0
  while ! curl --silent --fail $1 > /dev/null; do
    ((i++)) || sleep 0
    if ((i==30)); then
      echo "URL $1 is not available after ${i} attempts"
      exit 12
    fi
    sleep 1
  done
}

function wait_for_port {
  i=0
  while ! nc -z localhost $1; do
    ((i++)) || sleep 0
    if ((i==30)); then
      echo "Port $1 is not available after ${i} attempts"
      exit 13
    fi
    sleep 1
  done
}

function halt_nodes {
  for p in "$@"; do
    pid=$(curl --silent "http://localhost:$p/pid?halt=test" || echo 'absent')
    if [[ "${pid}" =~ ^[0-9]+$ ]]; then
      i=0
      while kill -0 ${pid}; do
        ((i++)) || sleep 0
        if ((i==30)); then
          echo "Process ${pid} didn't die, it's a bug"
          exit 15
        fi
        echo "Still waiting for process ${pid} to die, attempt no.${i}"
        sleep 1
      done
      echo "Process ${pid} is dead!"
    fi
    echo "Node at TCP port ${p} stopped!"
  done
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zold-stress-0.7.0 fixtures/scripts/_head.sh
zold-stress-0.6.0 fixtures/scripts/_head.sh
zold-stress-0.5.3 fixtures/scripts/_head.sh
zold-stress-0.5.2 fixtures/scripts/_head.sh