-
Notifications
You must be signed in to change notification settings - Fork 26
/
benchmark.sh
executable file
·82 lines (54 loc) · 2.08 KB
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
set -e
PROJECT_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [[ "$1" == "docker" ]]; then
# Install composer dependencies
docker run --rm --interactive --tty \
--volume $PROJECT_ROOT:/code \
--user $(id -u):$(id -g) \
composer install --prefer-dist --no-interaction --working-dir=/code --ignore-platform-reqs
# Build DI containers
docker-compose run --no-deps benchmark-cli /code/bin/benchmark build
# Dump autoloader
docker run --rm --interactive --tty \
--volume $PROJECT_ROOT:/code \
--user $(id -u):$(id -g) \
composer dump-autoload --classmap-authoritative --no-interaction --working-dir=/code
# Run the benchmark
docker-compose up --build
elif [[ "$1" == "aws" ]]; then
cd $PROJECT_ROOT/build/infrastructure/aws/
terraform init -backend=true -get=true
echo "TERRAFORM PLAN:"
terraform plan \
-input=false \
-out="$PROJECT_ROOT/build/infrastructure/aws/aws.tfplan" \
-refresh=true \
-var "project_root=$PROJECT_ROOT" \
-var-file="$PROJECT_ROOT/build/infrastructure/config/aws.tfvars"
echo "TERRAFORM APPLY:"
terraform apply \
-auto-approve \
-input=false \
"$PROJECT_ROOT/build/infrastructure/aws/aws.tfplan"
BENCHMARK_URL=`terraform output dns`
echo "RUNNING BENCHMARK: $BENCHMARK_URL"
$PROJECT_ROOT/bin/benchmark "$BENCHMARK_URL"
echo "TERRAFORM DESTROY"
terraform destroy \
-var "project_root=\"$PROJECT_ROOT\"" \
-var-file="$PROJECT_ROOT/build/infrastructure/config/aws.tfvars"
cd $PROJECT_ROOT
elif [[ "$1" == "host" ]]; then
composer install --prefer-dist --no-interaction --working-dir=$PROJECT_ROOT --ignore-platform-reqs
$PROJECT_ROOT/bin/benchmark build
composer dump-autoload --classmap-authoritative --no-interaction --working-dir=$PROJECT_ROOT
VAR="$BENCHMARK_URL"
if [ ! -z "$2" ]; then
VAR="$2"
fi
$PROJECT_ROOT/bin/benchmark "$VAR"
else
echo 'Available options: "docker", "aws", "host"!'
exit 1
fi