-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjenkins_test.sh
executable file
·94 lines (78 loc) · 2.61 KB
/
jenkins_test.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
#!/bin/bash
echo "CoprHD Vagrant VM"
echo "Here are the proxy settings: "
env | grep -i proxy
# Stop any running instance of CoprHD
vagrant halt coprhd
PROXYCONF_INSTALLED=`vagrant plugin list | grep proxyconf`
# If not installed - install ProxyConf
if [[ -z $PROXYCONF_INSTALLED ]]; then
echo "Installing vagrant-proxyconf"
vagrant plugin install vagrant-proxyconf
else
echo "vagrant-proxyconf installed already"
fi
CACHIER_INSTALLED=`vagrant plugin list | grep cachier`
if [[ -z $CACHIER_INSTALLED ]]; then
echo "Installing vagrant-cachier"
vagrant plugin install vagrant-cachier
else
echo "vagrant-cachier installed already"
fi
# Comment out when testing
# Clean out any coprhd VM instance
vagrant destroy -f coprhd
# Bring up CoprHD, which includes building the latest master branch
echo "Launching CoprHD"
vagrant up coprhd
STATUS=$?
if [[ ${STATUS} -ne 0 ]]; then
echo "Vagrant up on CoprHD Failed"
vagrant halt coprhd
vagrant destroy -f coprhd
exit ${STATUS}
fi
# Now that CoprHD is up and running - check out version tag versus commit tag in git repo - should match
rm ./cookiefile
# Grab the GIT Tag
OUTPUT=`vagrant ssh coprhd -c "cd /tmp/coprhd-controller; git log --pretty=oneline --abbrev-commit -n 1 | awk '{print $1}'"`
COMMIT_TAG=`echo $OUTPUT | awk '{print $1}'`
echo "COMMIT: ${COMMIT_TAG}"
# Restart OpenSUSE Network - Seems to be an issue with OpenSUSE and host-only networking
vagrant ssh coprhd -c "echo ChangeMe | sudo service network restart"
# Login and check the Version
COPRHD_IP=https://192.168.100.11:4443
CANT_CONNECT="Unable to connect to the service. The service is unavailable"
# Uncomment when Testing - stop services and make sure we fail
# vagrant ssh coprhd -c "echo ChangeMe | sudo /etc/storageos/storageos stop"
printf "Waiting for CoprHD Services to start..."
TIMER=1
echo "Cant connect is: ${CANT_CONNECT}"
while [[ `curl --insecure -G --anyauth $COPRHD_IP/login?using-cookies=true -u 'root:ChangeMe' -c ./cookiefile -v` =~ ${CANT_CONNECT} ]];
do
sleep 5
printf "."
if [ $TIMER -gt 15 ]; then
echo ""
echo "CoprHD Services Did Not Start"
echo ""
exit 1
fi
let TIMER=${TIMER}+1
done
VERSION=`curl -k $COPRHD_IP/upgrade/target-version -b ./cookiefile`
echo "VERSION is: ${VERSION}"
echo "COMMIT_TAG is: ${COMMIT_TAG}"
if [[ $VERSION == *${COMMIT_TAG}* ]]
then
EXIT_STATUS=0
echo "VERSION MATCHES GIT TAG"
else
echo "VERSION MISMATCH: COMMIT_TAG from REPO: ${COMMIT_TAG}, CoprHD Version:${VERSION}"
EXIT_STATUS=1
fi
# Cleanup
echo "Delete cookiefile and stop vagrant"
rm ./cookiefile
vagrant halt coprhd
exit ${EXIT_STATUS}