-
Notifications
You must be signed in to change notification settings - Fork 1
/
testScript.py
executable file
·54 lines (47 loc) · 1.37 KB
/
testScript.py
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
#!/usr/bin/python
# author: ajs
# license: bsd
# copyright: re2
import json
import sys
import urllib2
import time
def successLights():
req = urllib2.Request("http://sauron.rhventures.org:8765/lamp/A1/OFF")
urllib2.urlopen(req)
req = urllib2.Request("http://sauron.rhventures.org:8765/lamp/A2/OFF")
urllib2.urlopen(req)
req = urllib2.Request("http://sauron.rhventures.org:8765/lamp/A2/ON")
urllib2.urlopen(req)
def failureLights():
req = urllib2.Request("http://sauron.rhventures.org:8765/lamp/A2/OFF")
urllib2.urlopen(req)
req = urllib2.Request("http://sauron.rhventures.org:8765/lamp/A1/OFF")
urllib2.urlopen(req)
req = urllib2.Request("http://sauron.rhventures.org:8765/lamp/A1/ON")
urllib2.urlopen(req)
###Health Check Solution
bldUrl = "http://rhv-bakkle-bld.rhventures.org:8000"
statusUrl = "/system/health/"
try:
check = urllib2.urlopen(bldUrl + statusUrl)
except:
print "URL Error: " + str(sys.exc_info()[0])
failureLights()
sys.exit(2)
try:
buildStatus = json.load(check)
except:
print "Failed to parse json"
failureLights()
sys.exit(3)
if buildStatus.has_key("health"):
if buildStatus["health"] == 1:
successLights()
print "Website is Healthy! Green GO! Red NO!"
else:
failureLights()
print "Website has Croaked! Red GO! Green NO!"
else:
sys.exit(5)
sys.exit(0)