Skip to content

Commit c0a387a

Browse files
committed
test: adding tests for Pilots summary tables
1 parent 9f2ff65 commit c0a387a

File tree

5 files changed

+6089
-6
lines changed

5 files changed

+6089
-6
lines changed

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,8 @@ def getPilotMonitorSelectors(self):
948948
result = self.getDistinctAttributeValues("PilotsHistorySummary", param)
949949
if not result["OK"]:
950950
resultDict = []
951-
resultDict[param] = result["Value"]
951+
else:
952+
resultDict[param] = result["Value"]
952953

953954
return S_OK(resultDict)
954955

tests/Integration/WorkloadManagementSystem/Test_PilotAgentsDB.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"""
66
# pylint: disable=wrong-import-position
77

8+
import csv
9+
from datetime import datetime, timedelta
810
from unittest.mock import patch
911

1012
import DIRAC
@@ -247,16 +249,16 @@ def test_summarySnapshot():
247249
sql = f"INSERT INTO PilotAgents (InitialJobID, CurrentJobID, PilotJobReference, PilotStamp, DestinationSite, Queue, GridSite, VO, GridType, BenchMark, SubmissionTime, LastUpdateTime, Status, StatusReason, AccountingSent) VALUES ({placeholders})"
248250
res = paDB._updatemany(sql, processed_data)
249251
assert res["OK"], res["Message"]
250-
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, DestinationSite, Status, VO;"
252+
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, GridType, Status, VO;"
251253
result = PilotAgentsDB()._query(sql)
252254
assert result["OK"], result["Message"]
253255
values = result["Value"][1]
254256
assert len(values) == 5, "Expected 5 record in the summary"
255257
# Check it corresponds to the basic "GROUP BY" query
256-
sql = "SELECT GridSite, DestinationSite, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, DestinationSite, Status, VO ORDER BY GridSite, DestinationSite, Status, VO;"
258+
sql = "SELECT GridSite, GridType, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, GridType, Status, VO ORDER BY GridSite, Status, VO;"
257259
result_grouped = PilotAgentsDB()._query(sql)
258260
assert result_grouped["OK"], result_grouped["Message"]
259-
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, DestinationSite, Status, VO;"
261+
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, Status, VO;"
260262
result_summary = PilotAgentsDB()._query(sql)
261263
assert result_summary["OK"], result_summary["Message"]
262264
assert result_grouped["Value"] == result_summary["Value"], "Summary and grouped query results differ"
@@ -272,10 +274,10 @@ def test_summarySnapshot():
272274
res = paDB._update(sql)
273275
assert res["OK"], res["Message"]
274276
# Check it corresponds to the basic "GROUP BY" query
275-
sql = "SELECT GridSite, DestinationSite, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, DestinationSite, Status, VO ORDER BY GridSite, DestinationSite, Status, VO;"
277+
sql = "SELECT GridSite, GridType, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, GridType, Status, VO ORDER BY GridSite, Status, VO;"
276278
result_grouped = PilotAgentsDB()._query(sql)
277279
assert result_grouped["OK"], result_grouped["Message"]
278-
sql = "select * FROM PilotsHistorySummary ORDER BY GridSite, DestinationSite, Status, VO;"
280+
sql = "select * FROM PilotsHistorySummary ORDER BY GridSite, Status, VO;"
279281
result_summary = PilotAgentsDB()._query(sql)
280282
assert result_summary["OK"], result_summary["Message"]
281283
assert result_grouped["Value"] == result_summary["Value"], "Summary and grouped query results differ"

0 commit comments

Comments
 (0)