|
43 | 43 | { pkgs, ... }: |
44 | 44 | { |
45 | 45 | virtualisation = { |
| 46 | + memorySize = 2048; |
46 | 47 | emptyDiskImages = [ |
47 | 48 | 20480 |
48 | 49 | 20480 |
|
92 | 93 | cfg.osd2.name |
93 | 94 | ]; |
94 | 95 | }; |
| 96 | + rgw = { |
| 97 | + enable = true; |
| 98 | + daemons = [ cfg.monA.name ]; |
| 99 | + }; |
95 | 100 | }; |
96 | 101 | }; |
97 | 102 |
|
|
100 | 105 | # For other ways to deploy a ceph cluster, look at the documentation at |
101 | 106 | # https://docs.ceph.com/docs/master/ |
102 | 107 | testScript = '' |
| 108 | + import json |
| 109 | +
|
103 | 110 | start_all() |
104 | 111 |
|
105 | 112 | monA.wait_for_unit("network.target") |
|
194 | 201 | "ceph osd pool delete single-node-other-test single-node-other-test --yes-i-really-really-mean-it", |
195 | 202 | ) |
196 | 203 |
|
| 204 | + # Bootstrap RGW |
| 205 | + monA.succeed( |
| 206 | + "sudo -u ceph mkdir -p /var/lib/ceph/radosgw/ceph-${cfg.monA.name}", |
| 207 | + "ceph auth get-or-create client.${cfg.monA.name} osd 'allow rwx' mon 'allow rw' > /var/lib/ceph/radosgw/ceph-${cfg.monA.name}/keyring", |
| 208 | + "chown ceph:ceph /var/lib/ceph/radosgw/ceph-${cfg.monA.name}/keyring", |
| 209 | + "systemctl start ceph-rgw-${cfg.monA.name}", |
| 210 | + ) |
| 211 | + monA.wait_for_unit("ceph-rgw-${cfg.monA.name}") |
| 212 | + monA.wait_for_open_port(7480) |
| 213 | +
|
197 | 214 | # Shut down ceph by stopping ceph.target. |
198 | 215 | monA.succeed("systemctl stop ceph.target") |
199 | 216 |
|
|
204 | 221 | monA.wait_for_unit("ceph-osd-${cfg.osd0.name}") |
205 | 222 | monA.wait_for_unit("ceph-osd-${cfg.osd1.name}") |
206 | 223 | monA.wait_for_unit("ceph-osd-${cfg.osd2.name}") |
| 224 | + monA.wait_for_unit("ceph-rgw-${cfg.monA.name}") |
207 | 225 |
|
208 | 226 | # Ensure the cluster comes back up again |
209 | 227 | monA.succeed("ceph -s | grep 'mon: 1 daemons'") |
|
222 | 240 | monA.wait_for_open_port(8080) |
223 | 241 | monA.wait_until_succeeds("curl -q --fail http://localhost:8080") |
224 | 242 | monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'") |
| 243 | +
|
| 244 | + # Initialize dashboard creds |
| 245 | + monA.succeed( |
| 246 | + "echo 'foo bar baz qux' > /tmp/dashboard_pw", |
| 247 | + "ceph dashboard ac-user-create admin -i /tmp/dashboard_pw administrator", |
| 248 | + "ceph dashboard set-rgw-credentials", |
| 249 | + ) |
| 250 | +
|
| 251 | + # Get dashboard auth token |
| 252 | + auth_payload = json.dumps({"username": "admin", "password": "foo bar baz qux"}) |
| 253 | + auth_response = json.loads(monA.succeed( |
| 254 | + f"curl --fail -s -X POST -H 'Accept: application/vnd.ceph.api.v1.0+json' -H 'Content-Type: application/json' -d '{auth_payload}' http://localhost:8080/api/auth", |
| 255 | + )) |
| 256 | + token = auth_response["token"] |
| 257 | +
|
| 258 | + # Check cluster health via dashboard API |
| 259 | + health = json.loads(monA.succeed( |
| 260 | + f"curl --fail -s -H 'Accept: application/vnd.ceph.api.v1.0+json' -H 'Authorization: Bearer {token}' http://localhost:8080/api/health/minimal", |
| 261 | + )) |
| 262 | + assert health["health"]["status"] == "HEALTH_OK" |
| 263 | +
|
| 264 | + # List daemons via REST API |
| 265 | + rgw_daemons = json.loads(monA.succeed( |
| 266 | + f"curl --fail -s -H 'Accept: application/vnd.ceph.api.v1.0+json' -H 'Authorization: Bearer {token}' http://localhost:8080/api/rgw/daemon", |
| 267 | + )) |
| 268 | + assert rgw_daemons[0]["id"] == "a" |
225 | 269 | ''; |
226 | 270 | in |
227 | 271 | { |
|
0 commit comments