-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_sciencemesh.py
80 lines (69 loc) · 3.04 KB
/
test_sciencemesh.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
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
""" Unit testing for sciencemesh
Author: Richard Freitag <[email protected]>
"""
import unittest
import requests
import json
import yaml
g_cs3url = 'https://iop.sciencemesh.uni-muenster.de/iop/mentix/cs3'
g_sitesurl = 'https://iop.sciencemesh.uni-muenster.de/iop/mentix/sites'
expectedResultsFile = 'expected.yaml'
class TestScienceMesh(unittest.TestCase):
def test_cs3(self):
statusCount = 0
instanceCount = 0
offlineCount = 0
print("Testing CS3 URL")
r=requests.get(g_cs3url)
j = json.loads(r.text)
for instance in j:
instanceCount += 1
print(instance["name"])
hosturl = instance["services"][0]["host"]
fullhosturl = "https://" + hosturl
try:
hr = requests.get(fullhosturl)
# print("\tLIVE: " + hosturl)
isLive = True
# print(r.text)
except:
print("\t\t\t\tOffline: " + fullhosturl)
offlineCount += 1
isLive = False
if (isLive):
try:
statusUrl = fullhosturl + "/status.php"
sr = requests.get(statusUrl)
if ('installed' in sr.text):
statusCount += 1
hasStatus = True
print("\tStatus: ", statusUrl)
except:
print("Status url not available: " + statusUrl)
for service in instance["services"]:
servicename = service["endpoint"]["type"]["name"]
# print("\t", servicename)
# if (servicename == "OCM"):
# print("\t\t\t\t OCM ENDPOINT FOUND")
if not (service.get('additional_endpoints') is None):
for additionalEndpoint in service["additional_endpoints"]:
# print("\t\t", additionalEndpoint["type"]["name"])
if (additionalEndpoint["type"]["name"] == "METRICS"):
# print("\t\t\t", additionalEndpoint["path"])
metricsPath = additionalEndpoint["path"]
# try:
# r=requests.get(metricsPath)
# # print(r.text)
# except:
# print("\t\t\t\t", "Metrics access failed")
# print(r.text)
# print("value is present for given JSON key")
# # print(service["additional_endpoints"]["type"]["name"])
# print(service["additional_endpoints"]["type"])
print("Instances: ", instanceCount)
print("Live sites: ", statusCount)
print("Offline: ", offlineCount)
if __name__ == '__main__':
import xmlrunner
# unittest.main()
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))