forked from shahbazn/ansible-aws-alias
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·111 lines (88 loc) · 2.28 KB
/
run_tests.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# set -e
function usage()
{
echo ""
echo "Usage:"
echo ""
echo "./run_tests.sh"
echo " -h --help"
echo " --access-key=AWS_ACCESS_KEY_ID"
echo " --access-secret=AWS_SECRET_ACCESS_KEY"
echo ""
}
if [[ $# -ne 2 ]]
then
usage
exit
fi
while [[ "$1" != "" ]]
do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-h | --help)
usage
exit
;;
--access-key)
AWS_ACCESS_KEY_ID=$VALUE
;;
--access-secret)
AWS_SECRET_ACCESS_KEY=$VALUE
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done
echo "Setting up ansible virtual environments"
SETUP_VERSION="v0.0.5"
ROLE_DIR="$(pwd)/aws_alias_role"
## Install Ansible 2.0
## using the latest 2.0 version
## available on pypi
ANSIBLE_VERSIONS[0]="2.0.2.0"
INSTALL_TYPE[0]="pip"
ANSIBLE_LABEL[0]="v2.0"
## Install Ansible 2.1
## using the latest 2.2 version
## available on pypi
ANSIBLE_VERSIONS[1]="2.1.5.0"
INSTALL_TYPE[1]="pip"
ANSIBLE_LABEL[1]="v2.1"
## Install Ansible 2.2
ANSIBLE_VERSIONS[2]="2.2.1.0"
INSTALL_TYPE[2]="pip"
ANSIBLE_LABEL[2]="v2.2"
# Whats the default version
ANSIBLE_DEFAULT_VERSION="v2.2"
## Create a temp dir
filename=$( echo ${0} | sed 's|/||g' )
my_temp_dir="$(mktemp -dt ${filename}.XXXX)"
curl -s https://raw.githubusercontent.com/ahelal/avm/${SETUP_VERSION}/setup.sh -o $my_temp_dir/setup.sh
# Run the setup
. $my_temp_dir/setup.sh
echo "Setting AWS credentials"
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
# echo "installing dependencies v2.0"
$(avm path v2.0)/pip install -r ${ROLE_DIR}/requirements.txt
echo "installing dependencies v2.1"
$(avm path v2.1)/pip install -r ${ROLE_DIR}/requirements.txt
echo "installing dependencies v2.2"
$(avm path v2.2)/pip install -r ${ROLE_DIR}/requirements.txt
echo "Running unit tests v2.0"
$(avm path v2.0)/nosetests -w ${ROLE_DIR}/library
echo "Running unit tests v2.1"
$(avm path v2.1)/nosetests -w ${ROLE_DIR}/library
echo "Running unit tests v2.2"
$(avm path v2.2)/nosetests -w ${ROLE_DIR}/library
cd ${ROLE_DIR}
echo "Installing integeration test dependencies"
bundle install
echo "Running integeration tests"
kitchen test