github.com/yasker/longhorn-engine@v0.0.0-20160621014712-6ed6cfca0729/scripts/integration-test (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  killall longhorn ssync || true
     5  
     6  temp=$(mktemp -d)
     7  temp2=$(mktemp -d)
     8  temp3=$(mktemp -d)
     9  temp4=$(mktemp -d)
    10  trap "rm -rf $temp $temp2 $temp3 $temp4" EXIT
    11  
    12  cd $(dirname $0)/..
    13  
    14  if [ ! -x ./bin/longhorn ]; then
    15      ./scripts/build
    16  fi
    17  
    18  ./bin/longhorn controller --frontend rest --enable-backend file test-volume &
    19  ./bin/longhorn replica $temp &
    20  ./bin/longhorn replica --listen localhost:9505 $temp2 &
    21  
    22  # replica with 4MB backing file
    23  backing_file=backing_file.raw
    24  backing_qcow2=backing_file.qcow2
    25  cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $((1024 * 4096)) | head -n 1 > $backing_file
    26  truncate -s 4M $backing_file
    27  
    28  qemu-img convert -f raw -O qcow2 $backing_file $backing_qcow2
    29  cp $backing_qcow2 $temp3
    30  cp $backing_qcow2 $temp4
    31  
    32  ./bin/longhorn replica --listen localhost:9602 --backing-file $backing_qcow2 $temp3 &
    33  ./bin/longhorn replica --listen localhost:9605 --backing-file $backing_qcow2 $temp4 &
    34  
    35  cd integration
    36  find -depth -name __pycache__ -o -name "*.pyc" -exec rm -rf {} \;
    37  if [ -z "$NO_TEST" ]; then
    38      tox "$@"
    39  fi