-
Notifications
You must be signed in to change notification settings - Fork 584
/
ec2-bench.sh
54 lines (46 loc) · 1.41 KB
/
ec2-bench.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
#!/bin/bash
#if [ $# != 3 ];
#do
# echo "USAGE: $0 "
#done
CLUSTER_SIZE=4
INSTANCE_SIZE=m1.large
GROUP_NAME=vold-bench
# create group, if it doesn't exist
ec2-add-group $GROUP_NAME -d "voldemort benchmark security group."
ec2-authorize $GROUP_NAME -P tcp -p 6666
ec2-authorize $GROUP_NAME -P tcp -p 8081
result=$(ec2-run-instances ami-2547a34c -n $CLUSTER_SIZE -g vold-bench -k gsg-keypair --instance-type $INSTANCE_SIZE --availability-zone us-east-1b)
instance_ids=$(echo $result | grep INSTANCE | awk '{print 2}')
function wait_instance_available {
echo "Waiting for instance $1 to start"
while true; do
echo -n "."
# get private dns
host=$(ec2-describe-instances $1 | grep running | awk '{print $5}')
if [ ! -z $host ]; then
echo $host
break;
fi
sleep 1
done
}
## Wait until all the instances are listed as available
public_ips_file=/tmp/vold-bench-public.txt
private_ips_file=/tmp/vold-bench-private.txt
for instance in $instance_ids;
do
wait_instance_available $instance
echo $(ec2-describe-instances $instance | awk '{print $3}') >> $public_ips_file
echo $(ec2-describe-instances $instance | awk '{print $4}') >> $public_ips_file
done
public_ips=$(ec2-describe-instances $1 | grep running | awk '{print $5}')
function check_host_booted {
while true; do
REPLY=$(ssh $SSH_OPTS "root@$1" 'echo "hello"')
if [ ! -z $REPLY ]; then
break;
fi
sleep 5
done
}