Skip to content

Commit b1d87b8

Browse files
committed
test: added integration test for PilotAgentsDB summary table
1 parent 0aafe25 commit b1d87b8

File tree

4 files changed

+1000
-3
lines changed

4 files changed

+1000
-3
lines changed

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,6 @@ def getSummarySnapshot(self, requestedFields=False):
10991099
return S_OK(((requestedFields + valueFields), result["Value"]))
11001100

11011101

1102-
11031102
class PivotedPilotSummaryTable:
11041103
"""
11051104
The class creates a 'pivoted' table by combining records with the same group

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ CREATE TABLE `PilotsHistorySummary` (
7272
`GridType` VARCHAR(32),
7373
`Status` VARCHAR(32),
7474
`PilotCount` INT,
75-
PRIMARY KEY (`GridSite`,`GridType`,`Status`),
76-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
75+
PRIMARY KEY (`GridSite`,`GridType`,`Status`)
76+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

tests/Integration/WorkloadManagementSystem/Test_PilotAgentsDB.py

Lines changed: 18 additions & 0 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+
810
from unittest.mock import patch
911

1012
import DIRAC
@@ -186,3 +188,19 @@ def test_PivotedPilotSummaryTable():
186188
assert "Total" in columns
187189

188190
cleanUpPilots(pilotRef)
191+
192+
193+
def test_summarySnapshot():
194+
# insert some predefined jobs to test the summary snapshot
195+
with open("pilots.csv", newline="", encoding="utf-8") as csvfile:
196+
csvreader = csv.reader(csvfile)
197+
data = list(csvreader)
198+
placeholders = ",".join(["%s"] * len(data[0]))
199+
sql = f"INSERT INTO PilotAgents VALUES ({placeholders})"
200+
res = paDB._updatemany(sql, data)
201+
assert res["OK"], res["Message"]
202+
# Act
203+
res = paDB.fillPilotsHistorySummary()
204+
assert res["OK"], res["Message"]
205+
res = paDB.getSummarySnapshot()
206+
assert res["OK"], res["Message"]

0 commit comments

Comments
 (0)