#!/bin/bash -l

set -e -x

export PATH=/var/vcap/packages/cf-cli/bin:$PATH

cells=<%= properties.performance_tests.num_cells %>

api_url=<%= properties.stress_tests.api %>
api_user=<%= properties.stress_tests.admin_user %>
api_password=<%= properties.stress_tests.admin_password %>
cf login -a $api_url -u $api_user -p $api_password <%= properties.stress_tests.skip_ssl_validation ? "--skip-ssl-validation" : "" %>

cleanup() {
  cf delete-org cache-warmer -f || true
  cf delete-quota cache-warmer -f || true
}

trap cleanup ERR

cleanup

cf create-quota cache-warmer -m 1000GB -r 1000
cf create-org cache-warmer
cf set-quota cache-warmer cache-warmer
cf create-space cache-warmer -o cache-warmer
cf target -o cache-warmer -s cache-warmer

for i in $(seq $cells); do
  cf push warm-$i \
    --no-start \
    -b go_buildpack \
    -p /var/vcap/packages/stress_tests/src/github.com/cloudfoundry-incubator/diego-stress-tests/assets/apps/westley
  cf curl /v2/apps/`cf app warm-$i --guid` -X PUT -d '{"diego":true}'
  cf start warm-$i
done

cleanup

#!/bin/bash -l

set -e -x

export PATH=/var/vcap/packages/cf-cli/bin:$PATH

cells=<%= properties.performance_tests.num_cells %>

api_url=<%= properties.stress_tests.api %>
api_user=<%= properties.stress_tests.admin_user %>
api_password='<%= properties.stress_tests.admin_password %>'
cf login -a $api_url -u $api_user -p $api_password <%= properties.stress_tests.skip_ssl_validation ? "--skip-ssl-validation" : "" %>

cleanup() {
  cf delete-org cache-warmer -f || true
  cf delete-quota cache-warmer -f || true
}

trap cleanup ERR

cleanup

cf create-quota cache-warmer -m 1000GB -r 1000
cf create-org cache-warmer
cf set-quota cache-warmer cache-warmer
cf create-space cache-warmer -o cache-warmer
cf target -o cache-warmer -s cache-warmer

for i in $(seq $cells); do
  cf push warm-$i \
    --no-start \
    -b go_buildpack \
    -p /var/vcap/packages/stress_tests/src/github.com/cloudfoundry-incubator/diego-stress-tests/assets/apps/westley
  cf curl /v2/apps/`cf app warm-$i --guid` -X PUT -d '{"diego":true}'
  cf start warm-$i
done

cleanup

Add quotes around api_password when setting it
Add quotes around api_password when setting it

Without these there will be a syntax error if the password
contains (.

$ api_password=a(b
-bash: syntax error near unexpected token `('
