Skip to content

Commit 96d2ca5

Browse files
authored
Use dd_run_check in ceph tests (#19815)
1 parent 9d751f6 commit 96d2ca5

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

ceph/tests/test_integration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
@pytest.mark.integration
1515
@pytest.mark.usefixtures("dd_environment")
16-
def test_check(aggregator):
16+
def test_check(aggregator, dd_run_check):
1717
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
18-
ceph_check.check({})
18+
dd_run_check(ceph_check)
1919

2020
for metric in EXPECTED_METRICS:
2121
aggregator.assert_metric(metric, at_least=1)

ceph/tests/test_unit.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262

6363

6464
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("raw.json"))
65-
def test_simple_metrics(_, aggregator):
65+
def test_simple_metrics(_, aggregator, dd_run_check):
6666
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
67-
ceph_check.check({})
67+
dd_run_check(ceph_check)
6868

6969
for metric in EXPECTED_METRICS:
7070
aggregator.assert_metric(metric, count=1, tags=EXPECTED_TAGS)
@@ -73,9 +73,9 @@ def test_simple_metrics(_, aggregator):
7373

7474

7575
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("warn.json"))
76-
def test_warn_health(_, aggregator):
76+
def test_warn_health(_, aggregator, dd_run_check):
7777
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
78-
ceph_check.check({})
78+
dd_run_check(ceph_check)
7979

8080
for metric in EXPECTED_METRICS:
8181
aggregator.assert_metric(metric, count=1, tags=EXPECTED_TAGS)
@@ -84,43 +84,43 @@ def test_warn_health(_, aggregator):
8484

8585

8686
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("ceph_luminous_warn.json"))
87-
def test_luminous_warn_health(_, aggregator):
87+
def test_luminous_warn_health(_, aggregator, dd_run_check):
8888
config = copy.deepcopy(BASIC_CONFIG)
8989
config["collect_service_check_for"] = ['OSD_NEARFULL', 'OSD_FULL']
9090
ceph_check = Ceph(CHECK_NAME, {}, [config])
91-
ceph_check.check({})
91+
dd_run_check(ceph_check)
9292

9393
aggregator.assert_service_check('ceph.overall_status', status=Ceph.CRITICAL, tags=EXPECTED_SERVICE_TAGS)
9494
aggregator.assert_service_check('ceph.osd_nearfull', status=Ceph.WARNING, tags=EXPECTED_SERVICE_TAGS)
9595
aggregator.assert_service_check('ceph.osd_full', status=Ceph.CRITICAL, tags=EXPECTED_SERVICE_TAGS)
9696

9797

9898
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("ceph_luminous_ok.json"))
99-
def test_luminous_ok_health(_, aggregator):
99+
def test_luminous_ok_health(_, aggregator, dd_run_check):
100100
config = copy.deepcopy(BASIC_CONFIG)
101101
config["collect_service_check_for"] = ['OSD_NEARFULL']
102102
ceph_check = Ceph(CHECK_NAME, {}, [config])
103-
ceph_check.check({})
103+
dd_run_check(ceph_check)
104104

105105
aggregator.assert_service_check('ceph.overall_status', status=Ceph.OK)
106106
aggregator.assert_service_check('ceph.osd_nearfull', status=Ceph.OK)
107107
aggregator.assert_service_check('ceph.pool_app_not_enabled', count=0)
108108

109109

110110
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("ceph_luminous_warn.json"))
111-
def test_luminous_osd_full_metrics(_, aggregator):
111+
def test_luminous_osd_full_metrics(_, aggregator, dd_run_check):
112112
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
113-
ceph_check.check({})
113+
dd_run_check(ceph_check)
114114

115115
aggregator.assert_metric('ceph.num_full_osds', value=1)
116116
aggregator.assert_metric('ceph.num_near_full_osds', value=1)
117117

118118

119119
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("raw.json"))
120-
def test_tagged_metrics(_, aggregator):
120+
def test_tagged_metrics(_, aggregator, dd_run_check):
121121

122122
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
123-
ceph_check.check({})
123+
dd_run_check(ceph_check)
124124

125125
for osd in ['osd0', 'osd1', 'osd2']:
126126
expected_tags = EXPECTED_TAGS + ['ceph_osd:%s' % osd] + OSD_SPECIFIC_TAGS[osd]
@@ -136,10 +136,10 @@ def test_tagged_metrics(_, aggregator):
136136

137137

138138
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("raw2.json"))
139-
def test_osd_perf_with_osdstats(_, aggregator):
139+
def test_osd_perf_with_osdstats(_, aggregator, dd_run_check):
140140

141141
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
142-
ceph_check.check({})
142+
dd_run_check(ceph_check)
143143

144144
for osd in ['osd0', 'osd1', 'osd2']:
145145
expected_tags = EXPECTED_TAGS + ['ceph_osd:%s' % osd] + OSD_SPECIFIC_TAGS[osd]
@@ -149,10 +149,10 @@ def test_osd_perf_with_osdstats(_, aggregator):
149149

150150

151151
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("ceph_10.2.2.json"))
152-
def test_osd_status_metrics(_, aggregator):
152+
def test_osd_status_metrics(_, aggregator, dd_run_check):
153153

154154
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
155-
ceph_check.check({})
155+
dd_run_check(ceph_check)
156156

157157
expected_metrics = ['ceph.read_op_per_sec', 'ceph.write_op_per_sec', 'ceph.op_per_sec']
158158

@@ -170,27 +170,27 @@ def test_osd_status_metrics(_, aggregator):
170170

171171

172172
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("ceph_10.2.2_mon_health.json"))
173-
def test_osd_status_metrics_non_osd_health(_, aggregator):
173+
def test_osd_status_metrics_non_osd_health(_, aggregator, dd_run_check):
174174
"""
175175
The `detail` key of `health detail` can contain info on the health of non-osd units:
176176
shouldn't make the check fail
177177
"""
178178

179179
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
180-
ceph_check.check({})
180+
dd_run_check(ceph_check)
181181

182182
aggregator.assert_metric('ceph.num_full_osds', value=0, count=1, tags=EXPECTED_TAGS)
183183
aggregator.assert_metric('ceph.num_near_full_osds', value=0, count=1, tags=EXPECTED_TAGS)
184184

185185

186186
@mock.patch("datadog_checks.ceph.Ceph._collect_raw", return_value=mock_data("ceph_stats_by_class.json"))
187-
def test_stats_by_class_metrics(_, aggregator):
187+
def test_stats_by_class_metrics(_, aggregator, dd_run_check):
188188
"""
189189
Test with populated stats by class field
190190
"""
191191

192192
ceph_check = Ceph(CHECK_NAME, {}, [copy.deepcopy(BASIC_CONFIG)])
193-
ceph_check.check({})
193+
dd_run_check(ceph_check)
194194

195195
aggregator.assert_metric('ceph.class_pct_used', count=1, tags=EXPECTED_TAGS + ['ceph_osd_device_class:hdd'])
196196
aggregator.assert_metric('ceph.class_pct_used', count=0, tags=EXPECTED_TAGS + ['ceph_osd_device_class:nvme'])

0 commit comments

Comments
 (0)