Skip to content

Commit b48dcb4

Browse files
authored
Merge pull request #6513 from DIRACGridBot/cherry-pick-2-6cbfd9e9e-integration
[sweep:integration] RSS fix: understand also real URLs
2 parents 003d381 + 8c0ed55 commit b48dcb4

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/DIRAC/Core/LCG/GOCDBClient.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
WARN: the URL of the GOC DB API is hardcoded, and is: https://goc.egi.eu/gocdbpi/public/
44
"""
55

6-
import time
76
import socket
8-
import requests
9-
7+
import time
108
from datetime import datetime, timedelta
9+
from urllib import parse
1110
from xml.dom import minidom
1211

13-
from DIRAC import S_OK, S_ERROR, gLogger
12+
import requests
13+
from DIRAC import S_ERROR, S_OK, gLogger
1414
from DIRAC.Core.Security.Locations import getCAsLocation
1515

1616

@@ -346,7 +346,10 @@ def _downTimeXMLParsing(self, dt, siteOrRes, entities=None, startDateMax=None):
346346
urls = []
347347
for epElement in affectedEndpoints[0].childNodes:
348348
try:
349-
urls.append(_parseSingleElement(epElement, ["URL"])["URL"])
349+
url = _parseSingleElement(epElement, ["URL"])["URL"]
350+
if "//" not in url:
351+
url = f"//{url}"
352+
urls.append(parse.urlparse(url).hostname)
350353
except (IndexError, KeyError):
351354
pass
352355
except (IndexError, KeyError):

src/DIRAC/Core/LCG/test/Test_LCG.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,32 @@
7171
xml_endpoint_and_affected_ongoing += "<FORMATED_END_DATE>" + nowPlus24h + "</FORMATED_END_DATE>"
7272
xml_endpoint_and_affected_ongoing += "</DOWNTIME></ROOT>\n"
7373

74+
xml_endpoint_and_affected_ongoing_diffURL = '<?xml version="1.0"?>\n<ROOT>'
75+
xml_endpoint_and_affected_ongoing_diffURL += '<DOWNTIME ID="29118" PRIMARY_KEY="109962G0" CLASSIFICATION="UNSCHEDULED">'
76+
xml_endpoint_and_affected_ongoing_diffURL += "<PRIMARY_KEY>109962G0</PRIMARY_KEY>"
77+
xml_endpoint_and_affected_ongoing_diffURL += "<HOSTNAME>lhcbsrm-kit.gridka.de</HOSTNAME>"
78+
xml_endpoint_and_affected_ongoing_diffURL += "<SERVICE_TYPE>SRM</SERVICE_TYPE>"
79+
xml_endpoint_and_affected_ongoing_diffURL += "<ENDPOINT>lhcbsrm-kit.gridka.deSRM</ENDPOINT>"
80+
xml_endpoint_and_affected_ongoing_diffURL += "<HOSTED_BY>FZK-LCG2</HOSTED_BY>"
81+
xml_endpoint_and_affected_ongoing_diffURL += "<GOCDB_PORTAL_URL>https://goc.egi.eu/bof</GOCDB_PORTAL_URL>"
82+
xml_endpoint_and_affected_ongoing_diffURL += "<AFFECTED_ENDPOINTS>"
83+
xml_endpoint_and_affected_ongoing_diffURL += "<ENDPOINT>"
84+
xml_endpoint_and_affected_ongoing_diffURL += "<ID>7517</ID>"
85+
xml_endpoint_and_affected_ongoing_diffURL += "<NAME>lhcbsrm-disk-kit</NAME>"
86+
xml_endpoint_and_affected_ongoing_diffURL += "<URL>https://lhcbsrm-disk-kit.gridka.de:123</URL>"
87+
xml_endpoint_and_affected_ongoing_diffURL += "<INTERFACENAME>SRM</INTERFACENAME>"
88+
xml_endpoint_and_affected_ongoing_diffURL += "<ENDPOINT_MONITORED>N</ENDPOINT_MONITORED>"
89+
xml_endpoint_and_affected_ongoing_diffURL += "</ENDPOINT>"
90+
xml_endpoint_and_affected_ongoing_diffURL += "</AFFECTED_ENDPOINTS>"
91+
xml_endpoint_and_affected_ongoing_diffURL += "<SEVERITY>OUTAGE</SEVERITY>"
92+
xml_endpoint_and_affected_ongoing_diffURL += "<DESCRIPTION>Namespace reordering</DESCRIPTION>"
93+
xml_endpoint_and_affected_ongoing_diffURL += "<INSERT_DATE>1595233003</INSERT_DATE>"
94+
xml_endpoint_and_affected_ongoing_diffURL += "<START_DATE>1595314800</START_DATE>"
95+
xml_endpoint_and_affected_ongoing_diffURL += "<END_DATE>1595343600</END_DATE>"
96+
xml_endpoint_and_affected_ongoing_diffURL += "<FORMATED_START_DATE>" + nowLess12h + "</FORMATED_START_DATE>"
97+
xml_endpoint_and_affected_ongoing_diffURL += "<FORMATED_END_DATE>" + nowPlus24h + "</FORMATED_END_DATE>"
98+
xml_endpoint_and_affected_ongoing_diffURL += "</DOWNTIME></ROOT>\n"
99+
74100
xml_endpoint_and_affected_ongoing_broken = '<?xml version="1.0"?>\n<ROOT>'
75101
xml_endpoint_and_affected_ongoing_broken += '<DOWNTIME ID="29118" PRIMARY_KEY="109962G0" CLASSIFICATION="UNSCHEDULED">'
76102
xml_endpoint_and_affected_ongoing_broken += "<PRIMARY_KEY>109962G0</PRIMARY_KEY>"
@@ -312,6 +338,13 @@ def test__downTimeXMLParsing_affected():
312338
res = GOCCli._downTimeXMLParsing(xml_endpoint_and_affected_ongoing, "Site")
313339
assert res == {}
314340

341+
res = GOCCli._downTimeXMLParsing(xml_endpoint_and_affected_ongoing_diffURL, "Resource")
342+
assert set(res) == {"109962G0 lhcbsrm-kit.gridka.deSRM"}
343+
assert res["109962G0 lhcbsrm-kit.gridka.deSRM"]["HOSTNAME"] == "lhcbsrm-kit.gridka.de"
344+
assert res["109962G0 lhcbsrm-kit.gridka.deSRM"]["URL"] == "lhcbsrm-disk-kit.gridka.de"
345+
res = GOCCli._downTimeXMLParsing(xml_endpoint_and_affected_ongoing_diffURL, "Site")
346+
assert res == {}
347+
315348
res = GOCCli._downTimeXMLParsing(xml_endpoint_and_affected_ongoing_broken, "Resource")
316349
assert list(res)[0] == "109962G0 lhcbsrm-kit.gridka.deSRM"
317350
assert res["109962G0 lhcbsrm-kit.gridka.deSRM"]["HOSTNAME"] == "lhcbsrm-kit.gridka.de"
@@ -327,7 +360,7 @@ def test__downTimeXMLParsing_affected():
327360
res = GOCCli._downTimeXMLParsing(xml_endpoint_and_affected_ongoing_2_endpoints, "Resource")
328361
assert list(res)[0] == "123 appsgrycap.i3m.upv.eses.upv.grycap.im"
329362
assert res["123 appsgrycap.i3m.upv.eses.upv.grycap.im"]["HOSTNAME"] == "appsgrycap.i3m.upv.es"
330-
assert res["123 appsgrycap.i3m.upv.eses.upv.grycap.im"]["URL"] == "https://appsgrycap.i3m.upv.es:31443/im-web/"
363+
assert res["123 appsgrycap.i3m.upv.eses.upv.grycap.im"]["URL"] == "appsgrycap.i3m.upv.es"
331364
res = GOCCli._downTimeXMLParsing(xml_endpoint_and_affected_ongoing_2_endpoints, "Site")
332365
assert res == {}
333366

0 commit comments

Comments
 (0)