Skip to content

Commit e8ded99

Browse files
committed
Add db query duration tests
1 parent f3a101e commit e8ded99

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

django_prometheus/tests/end2end/testapp/test_db.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,29 @@ def testCounters(self):
6262
>= 200
6363
)
6464

65+
def testHistograms(self):
66+
cursor_db1 = connections["test_db_1"].cursor()
67+
cursor_db2 = connections["test_db_2"].cursor()
68+
cursor_db1.execute("SELECT 1")
69+
for _ in range(200):
70+
cursor_db2.execute("SELECT 2")
71+
assert (
72+
self.getMetric(
73+
"django_db_query_duration_seconds_count",
74+
alias="test_db_1",
75+
vendor="sqlite",
76+
)
77+
> 0
78+
)
79+
assert (
80+
self.getMetric(
81+
"django_db_query_duration_seconds_count",
82+
alias="test_db_2",
83+
vendor="sqlite",
84+
)
85+
>= 200
86+
)
87+
6588
def testExecuteMany(self):
6689
registry = self.saveRegistry()
6790
cursor_db1 = connections["test_db_1"].cursor()

0 commit comments

Comments
 (0)