]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/cephadm/tests/test_spec.py
1 # Disable autopep8 for this file:
9 from ceph
.deployment
.service_spec
import ServiceSpec
, NFSServiceSpec
, RGWSpec
, \
10 IscsiServiceSpec
, HostPlacementSpec
, CustomContainerSpec
11 from orchestrator
import DaemonDescription
, OrchestratorError
14 @pytest.mark
.parametrize(
21 "service_type": "alertmanager"
27 "service_type": "crash"
33 "service_type": "grafana"
51 "service_type": "node-exporter"
57 "service_type": "prometheus"
63 "hostname": "ceph-001",
69 "service_type": "rgw",
70 "service_id": "default-rgw-realm.eu-central-1.1",
71 "rgw_realm": "default-rgw-realm",
72 "rgw_zone": "eu-central-1"
75 "service_type": "osd",
76 "service_id": "osd_spec_default",
81 "model": "MC-55-44-XZ"
84 "model": "SSD-123-foo"
87 "model": "NVME-QQQQ-987"
93 def test_spec_octopus(spec_json
):
94 # https://tracker.ceph.com/issues/44934
95 # Those are real user data from early octopus.
96 # Please do not modify those JSON values.
98 spec
= ServiceSpec
.from_json(spec_json
)
100 # just some verification that we can sill read old octopus specs
101 def convert_to_old_style_json(j
):
103 j_c
.pop('service_name', None)
105 spec
= j_c
.pop('spec')
107 if 'placement' in j_c
:
108 if 'hosts' in j_c
['placement']:
109 j_c
['placement']['hosts'] = [
111 'hostname': HostPlacementSpec
.parse(h
).hostname
,
112 'network': HostPlacementSpec
.parse(h
).network
,
113 'name': HostPlacementSpec
.parse(h
).name
115 for h
in j_c
['placement']['hosts']
117 j_c
.pop('objectstore', None)
118 j_c
.pop('filter_logic', None)
121 assert spec_json
== convert_to_old_style_json(spec
.to_json())
124 @pytest.mark
.parametrize(
128 "hostname": "ceph-001",
129 "container_id": "d94d7969094d",
130 "container_image_id": "0881eb8f169f5556a292b4e2c01d683172b12830a62a9225a98a8e206bb734f0",
131 "container_image_name": "docker.io/prom/alertmanager:latest",
132 "daemon_id": "ceph-001",
133 "daemon_type": "alertmanager",
136 "status_desc": "running",
137 "last_refresh": "2020-04-03T15:31:48.725856",
138 "created": "2020-04-02T19:23:08.829543",
139 "started": "2020-04-03T07:29:16.932838",
143 "hostname": "ceph-001",
144 "container_id": "c4b036202241",
145 "container_image_id": "204a01f9b0b6710dd0c0af7f37ce7139c47ff0f0105d778d7104c69282dfbbf1",
146 "container_image_name": "docker.io/ceph/ceph:v15",
147 "daemon_id": "ceph-001",
148 "daemon_type": "crash",
151 "status_desc": "running",
152 "last_refresh": "2020-04-03T15:31:48.725903",
153 "created": "2020-04-02T19:23:11.390694",
154 "started": "2020-04-03T07:29:16.910897",
158 "hostname": "ceph-001",
159 "container_id": "5b7b94b48f31",
160 "container_image_id": "87a51ecf0b1c9a7b187b21c1b071425dafea0d765a96d5bc371c791169b3d7f4",
161 "container_image_name": "docker.io/ceph/ceph-grafana:latest",
162 "daemon_id": "ceph-001",
163 "daemon_type": "grafana",
166 "status_desc": "running",
167 "last_refresh": "2020-04-03T15:31:48.725950",
168 "created": "2020-04-02T19:23:52.025088",
169 "started": "2020-04-03T07:29:16.847972",
173 "hostname": "ceph-001",
174 "container_id": "9ca007280456",
175 "container_image_id": "204a01f9b0b6710dd0c0af7f37ce7139c47ff0f0105d778d7104c69282dfbbf1",
176 "container_image_name": "docker.io/ceph/ceph:v15",
177 "daemon_id": "ceph-001.gkjwqp",
178 "daemon_type": "mgr",
181 "status_desc": "running",
182 "last_refresh": "2020-04-03T15:31:48.725807",
183 "created": "2020-04-02T19:22:18.648584",
184 "started": "2020-04-03T07:29:16.856153",
188 "hostname": "ceph-001",
189 "container_id": "3d1ba9a2b697",
190 "container_image_id": "204a01f9b0b6710dd0c0af7f37ce7139c47ff0f0105d778d7104c69282dfbbf1",
191 "container_image_name": "docker.io/ceph/ceph:v15",
192 "daemon_id": "ceph-001",
193 "daemon_type": "mon",
196 "status_desc": "running",
197 "last_refresh": "2020-04-03T15:31:48.725715",
198 "created": "2020-04-02T19:22:13.863300",
199 "started": "2020-04-03T07:29:17.206024",
203 "hostname": "ceph-001",
204 "container_id": "36d026c68ba1",
205 "container_image_id": "e5a616e4b9cf68dfcad7782b78e118be4310022e874d52da85c55923fb615f87",
206 "container_image_name": "docker.io/prom/node-exporter:latest",
207 "daemon_id": "ceph-001",
208 "daemon_type": "node-exporter",
211 "status_desc": "running",
212 "last_refresh": "2020-04-03T15:31:48.725996",
213 "created": "2020-04-02T19:23:53.880197",
214 "started": "2020-04-03T07:29:16.880044",
218 "hostname": "ceph-001",
219 "container_id": "faf76193cbfe",
220 "container_image_id": "204a01f9b0b6710dd0c0af7f37ce7139c47ff0f0105d778d7104c69282dfbbf1",
221 "container_image_name": "docker.io/ceph/ceph:v15",
223 "daemon_type": "osd",
226 "status_desc": "running",
227 "last_refresh": "2020-04-03T15:31:48.726088",
228 "created": "2020-04-02T20:35:02.991435",
229 "started": "2020-04-03T07:29:19.373956",
233 "hostname": "ceph-001",
234 "container_id": "f82505bae0f1",
235 "container_image_id": "204a01f9b0b6710dd0c0af7f37ce7139c47ff0f0105d778d7104c69282dfbbf1",
236 "container_image_name": "docker.io/ceph/ceph:v15",
238 "daemon_type": "osd",
241 "status_desc": "running",
242 "last_refresh": "2020-04-03T15:31:48.726134",
243 "created": "2020-04-02T20:35:17.142272",
244 "started": "2020-04-03T07:29:19.374002",
248 "hostname": "ceph-001",
249 "container_id": "2708d84cd484",
250 "container_image_id": "358a0d2395fe711bb8258e8fb4b2d7865c0a9a6463969bcd1452ee8869ea6653",
251 "container_image_name": "docker.io/prom/prometheus:latest",
252 "daemon_id": "ceph-001",
253 "daemon_type": "prometheus",
256 "status_desc": "running",
257 "last_refresh": "2020-04-03T15:31:48.726042",
258 "created": "2020-04-02T19:24:10.281163",
259 "started": "2020-04-03T07:29:16.926292",
263 "hostname": "ceph-001",
264 "daemon_id": "default-rgw-realm.eu-central-1.1.ceph-001.ytywjo",
265 "daemon_type": "rgw",
267 "status_desc": "starting",
272 def test_dd_octopus(dd_json
):
273 # https://tracker.ceph.com/issues/44934
274 # Those are real user data from early octopus.
275 # Please do not modify those JSON values.
277 # Convert datetime properties to old style.
278 # 2020-04-03T07:29:16.926292Z -> 2020-04-03T07:29:16.926292
279 def convert_to_old_style_json(j
):
280 for k
in ['last_refresh', 'created', 'started', 'last_deployed',
283 j
[k
] = j
[k
].rstrip('Z')
287 assert dd_json
== convert_to_old_style_json(
288 DaemonDescription
.from_json(dd_json
).to_json())
291 @pytest.mark
.parametrize("spec,dd,valid",
293 # https://tracker.ceph.com/issues/44934
297 rgw_realm
="default-rgw-realm",
298 rgw_zone
="eu-central-1",
302 daemon_id
="foo.ceph-001.ytywjo",
310 service_id
="foo.bar",
311 rgw_zone
="eu-central-1",
315 daemon_id
="foo.bar.ceph-001.ytywjo",
327 daemon_id
="bar.host.domain.tld.ytywjo",
328 hostname
="host.domain.tld",
335 service_id
="realm.zone",
339 daemon_id
="realm.zone.a",
340 hostname
="smithi028",
352 daemon_id
="foo.hostname.ytywjo",
361 service_id
="default-rgw-realm.eu-central-1.1",
365 daemon_id
="default-rgw-realm.eu-central-1.1.hostname.ytywjo",
371 # service_id contains hostname
372 # (sort of) https://tracker.ceph.com/issues/45294
374 service_id
="default.rgw.realm.ceph.001",
378 daemon_id
="default.rgw.realm.ceph.001.ceph.001.ytywjo",
384 # https://tracker.ceph.com/issues/45293
392 daemon_id
="a.host1.abc123",
398 # '.' char in service_id
405 daemon_id
="a.b.c.host1.abc123",
411 # https://tracker.ceph.com/issues/45617
413 # daemon_id does not contain hostname
426 # daemon_id only contains hostname
439 # https://tracker.ceph.com/issues/45399
441 # daemon_id only contains hostname
448 daemon_id
="a.host1.abc123",
449 hostname
="host1.site",
460 hostname
="host1.site",
465 # https://tracker.ceph.com/issues/45293
478 # service_id contains a '.' char
484 daemon_id
="a.b.c.host1",
490 # trailing chars after hostname
496 daemon_id
="a.b.c.host1.abc123",
502 # chars after hostname without '.'
508 daemon_id
="a.host1abc123",
514 # chars before hostname without '.'
520 daemon_id
="ahost1.abc123",
526 # https://tracker.ceph.com/issues/45293
529 service_type
='iscsi',
534 daemon_id
="a.host1.abc123",
540 # '.' char in service_id
542 service_type
='iscsi',
547 daemon_id
="a.b.c.host1.abc123",
553 # fixed daemon id for teuthology.
555 service_type
='iscsi',
568 service_type
='container',
569 service_id
='hello-world',
570 image
='docker.io/library/hello-world:latest',
573 daemon_type
='container',
574 daemon_id
='hello-world.mgr0',
581 def test_daemon_description_service_name(spec
: ServiceSpec
,
582 dd
: DaemonDescription
,
585 assert spec
.service_name() == dd
.service_name()
587 with pytest
.raises(OrchestratorError
):