Skip to content

Commit

Permalink
Minor fixes to get script to work and to fix invalid group_info and t…
Browse files Browse the repository at this point in the history
…est_config
  • Loading branch information
sthapa committed Apr 1, 2015
1 parent 8bf20fc commit 913eadd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
10 changes: 10 additions & 0 deletions admin_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"stash.osgconnect.net":{
"status":"red",
"notes":"broken"
},
"faxbox.usatlas.org":{
"status":"green",
"notes":"admin override"
}
}
26 changes: 13 additions & 13 deletions check.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_xrootd(service, uri, sha1):
'status': "green",
'notes': ''}
try:
print "run_xrdcp.sh %s /tmp/xrdcp.test" % uri
status = subprocess.call("./run_xrdcp.sh %s /tmp/xrdcp.test" % uri, shell=True)
except OSError:
result['status'] = "red"
Expand Down Expand Up @@ -99,15 +98,15 @@ def run_tests(config={}, site_messages={}):
test_results = []
if not config:
return []
for service, config in config:
for service, config in config.iteritems():
result = {'service': service}
if service in site_messages:
# if service is in site messages use this instead of
# test results
if 'status' in site_messages['service']:
result['status'] = site_messages['service']['status']
if 'note' in site_messages['service']:
result['note'] = site_messages['service']['notes']
if 'status' in site_messages[service]:
result['status'] = site_messages[service]['status']
if 'notes' in site_messages[service]:
result['notes'] = site_messages[service]['notes']
test_results.append(result)
continue
if config['type'] == 'ssh':
Expand All @@ -119,9 +118,9 @@ def run_tests(config={}, site_messages={}):
config['url'],
config['sha1sum']))
elif config['type'] == 'xrootd':
result.update(test_download(service,
config['uri'],
config['sha1sum']))
result.update(test_xrootd(service,
config['uri'],
config['sha1sum']))
test_results.append(result)
return test_results

Expand Down Expand Up @@ -153,7 +152,7 @@ def parse_group_info(group_file=None):
return info
buf = open(group_file).read()
info = json.loads(buf)
return info
return info['groups']


def parse_config(config_file=None):
Expand Down Expand Up @@ -184,12 +183,13 @@ def write_output(output_file=None, results=[], group_info=""):
combined_output = "{\n"
combined_output += '"services": {' + "\n"
for result in results:
result_str = "\"{0}\": {\n".format(result['service'])
result_str += "\"status\": \"{1}\",\n".format(result['status'])
result_str += "\"notes\": \"{2}\"\n},\n".format(result['notes'])
result_str = "\"{0}\": ".format(result['service']) + "{\n"
result_str += "\"status\": \"{0}\",\n".format(result['status'])
result_str += "\"notes\": \"{0}\"".format(result['notes']) + "\n},\n"
combined_output += result_str
combined_output = combined_output[:-2] + "\n"
combined_output += "},\n"
combined_output += "\"groups\" : \n"
combined_output += json.dumps(group_info)
combined_output += "}"
if output_file is None:
Expand Down
4 changes: 2 additions & 2 deletions group_info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"groups": [
"groups": [
{
"services": [
"stash.ci-connect.net",
Expand Down Expand Up @@ -61,4 +61,4 @@
"name": "University of Michican"
}
]
}
}
6 changes: 3 additions & 3 deletions test_config
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
},
"stash.osgconnect.net" : {
"type" : "http",
"host" : "http://stash.osgconnect.net/keys/cern.ch.pub",
"url" : "http://stash.osgconnect.net/keys/cern.ch.pub",
"sha1sum" : "5b83bedef4c7ba38520d7e1b764f0cbc28527fb9"
},
"faxbox.usatlas.org" : {
"type" : "http",
"host" : "http://faxbox.usatlas.org/keys/cern.ch.pub",
"url" : "http://faxbox.usatlas.org/keys/cern.ch.pub",
"sha1sum" : "5b83bedef4c7ba38520d7e1b764f0cbc28527fb9"
},
"login.usatlas.org" : {
Expand All @@ -21,7 +21,7 @@
},
"xrootd.usatlas.org" : {
"type" : "xrootd",
"host" : "root://faxbox.usatlas.org//user/sthapa/filelist",
"uri" : "root://faxbox.usatlas.org//user/sthapa/filelist",
"sha1sum" : "f5127d99e4c75967e1bb992cd7d275554b111d75"
}
}
Expand Down

0 comments on commit 913eadd

Please sign in to comment.