Merge pull request #73190 from flokli/ceph-tests-python
WIP: nixos/ceph: port tests to python
This commit is contained in:
commit
758efb9348
3 changed files with 173 additions and 165 deletions
|
@ -290,10 +290,15 @@ class Machine:
|
||||||
|
|
||||||
def wait_for_monitor_prompt(self) -> str:
|
def wait_for_monitor_prompt(self) -> str:
|
||||||
assert self.monitor is not None
|
assert self.monitor is not None
|
||||||
|
answer = ""
|
||||||
while True:
|
while True:
|
||||||
answer = self.monitor.recv(1024).decode()
|
undecoded_answer = self.monitor.recv(1024)
|
||||||
|
if not undecoded_answer:
|
||||||
|
break
|
||||||
|
answer += undecoded_answer.decode()
|
||||||
if answer.endswith("(qemu) "):
|
if answer.endswith("(qemu) "):
|
||||||
return answer
|
break
|
||||||
|
return answer
|
||||||
|
|
||||||
def send_monitor_command(self, command: str) -> str:
|
def send_monitor_command(self, command: str) -> str:
|
||||||
message = ("{}\n".format(command)).encode()
|
message = ("{}\n".format(command)).encode()
|
||||||
|
@ -606,12 +611,15 @@ class Machine:
|
||||||
+ os.environ.get("QEMU_OPTS", "")
|
+ os.environ.get("QEMU_OPTS", "")
|
||||||
)
|
)
|
||||||
|
|
||||||
environment = {
|
environment = dict(os.environ)
|
||||||
"QEMU_OPTS": qemu_options,
|
environment.update(
|
||||||
"SHARED_DIR": self.shared_dir,
|
{
|
||||||
"USE_TMPDIR": "1",
|
"TMPDIR": self.state_dir,
|
||||||
}
|
"SHARED_DIR": self.shared_dir,
|
||||||
environment.update(dict(os.environ))
|
"USE_TMPDIR": "1",
|
||||||
|
"QEMU_OPTS": qemu_options,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self.process = subprocess.Popen(
|
self.process = subprocess.Popen(
|
||||||
self.script,
|
self.script,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import ./make-test.nix ({pkgs, lib, ...}:
|
import ./make-test-python.nix ({pkgs, lib, ...}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = {
|
cfg = {
|
||||||
|
@ -109,105 +109,105 @@ let
|
||||||
# For other ways to deploy a ceph cluster, look at the documentation at
|
# For other ways to deploy a ceph cluster, look at the documentation at
|
||||||
# https://docs.ceph.com/docs/master/
|
# https://docs.ceph.com/docs/master/
|
||||||
testscript = { ... }: ''
|
testscript = { ... }: ''
|
||||||
startAll;
|
start_all()
|
||||||
|
|
||||||
$monA->waitForUnit("network.target");
|
monA.wait_for_unit("network.target")
|
||||||
$osd0->waitForUnit("network.target");
|
osd0.wait_for_unit("network.target")
|
||||||
$osd1->waitForUnit("network.target");
|
osd1.wait_for_unit("network.target")
|
||||||
|
|
||||||
# Bootstrap ceph-mon daemon
|
# Bootstrap ceph-mon daemon
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"sudo -u ceph ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'",
|
"sudo -u ceph ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'",
|
||||||
"sudo -u ceph ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'",
|
"sudo -u ceph ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'",
|
||||||
"sudo -u ceph ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring",
|
"sudo -u ceph ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring",
|
||||||
"monmaptool --create --add ${cfg.monA.name} ${cfg.monA.ip} --fsid ${cfg.clusterId} /tmp/monmap",
|
"monmaptool --create --add ${cfg.monA.name} ${cfg.monA.ip} --fsid ${cfg.clusterId} /tmp/monmap",
|
||||||
"sudo -u ceph ceph-mon --mkfs -i ${cfg.monA.name} --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring",
|
"sudo -u ceph ceph-mon --mkfs -i ${cfg.monA.name} --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring",
|
||||||
"sudo -u ceph mkdir -p /var/lib/ceph/mgr/ceph-${cfg.monA.name}/",
|
"sudo -u ceph mkdir -p /var/lib/ceph/mgr/ceph-${cfg.monA.name}/",
|
||||||
"sudo -u ceph touch /var/lib/ceph/mon/ceph-${cfg.monA.name}/done",
|
"sudo -u ceph touch /var/lib/ceph/mon/ceph-${cfg.monA.name}/done",
|
||||||
"systemctl start ceph-mon-${cfg.monA.name}"
|
"systemctl start ceph-mon-${cfg.monA.name}",
|
||||||
);
|
)
|
||||||
$monA->waitForUnit("ceph-mon-${cfg.monA.name}");
|
monA.wait_for_unit("ceph-mon-${cfg.monA.name}")
|
||||||
$monA->mustSucceed("ceph mon enable-msgr2");
|
monA.succeed("ceph mon enable-msgr2")
|
||||||
|
|
||||||
# Can't check ceph status until a mon is up
|
# Can't check ceph status until a mon is up
|
||||||
$monA->succeed("ceph -s | grep 'mon: 1 daemons'");
|
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
|
||||||
|
|
||||||
# Start the ceph-mgr daemon, it has no deps and hardly any setup
|
# Start the ceph-mgr daemon, it has no deps and hardly any setup
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"ceph auth get-or-create mgr.${cfg.monA.name} mon 'allow profile mgr' osd 'allow *' mds 'allow *' > /var/lib/ceph/mgr/ceph-${cfg.monA.name}/keyring",
|
"ceph auth get-or-create mgr.${cfg.monA.name} mon 'allow profile mgr' osd 'allow *' mds 'allow *' > /var/lib/ceph/mgr/ceph-${cfg.monA.name}/keyring",
|
||||||
"systemctl start ceph-mgr-${cfg.monA.name}"
|
"systemctl start ceph-mgr-${cfg.monA.name}",
|
||||||
);
|
)
|
||||||
$monA->waitForUnit("ceph-mgr-a");
|
monA.wait_for_unit("ceph-mgr-a")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'quorum ${cfg.monA.name}'");
|
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'");
|
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
|
||||||
|
|
||||||
# Send the admin keyring to the OSD machines
|
# Send the admin keyring to the OSD machines
|
||||||
$monA->mustSucceed("cp /etc/ceph/ceph.client.admin.keyring /tmp/shared");
|
monA.succeed("cp /etc/ceph/ceph.client.admin.keyring /tmp/shared")
|
||||||
$osd0->mustSucceed("cp /tmp/shared/ceph.client.admin.keyring /etc/ceph");
|
osd0.succeed("cp /tmp/shared/ceph.client.admin.keyring /etc/ceph")
|
||||||
$osd1->mustSucceed("cp /tmp/shared/ceph.client.admin.keyring /etc/ceph");
|
osd1.succeed("cp /tmp/shared/ceph.client.admin.keyring /etc/ceph")
|
||||||
|
|
||||||
# Bootstrap both OSDs
|
# Bootstrap both OSDs
|
||||||
$osd0->mustSucceed(
|
osd0.succeed(
|
||||||
"mkfs.xfs /dev/vdb",
|
"mkfs.xfs /dev/vdb",
|
||||||
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
||||||
"mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
"mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
||||||
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd0.name}/keyring --name osd.${cfg.osd0.name} --add-key ${cfg.osd0.key}",
|
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd0.name}/keyring --name osd.${cfg.osd0.name} --add-key ${cfg.osd0.key}",
|
||||||
"echo '{\"cephx_secret\": \"${cfg.osd0.key}\"}' | ceph osd new ${cfg.osd0.uuid} -i -",
|
'echo \'{"cephx_secret": "${cfg.osd0.key}"}\' | ceph osd new ${cfg.osd0.uuid} -i -',
|
||||||
);
|
)
|
||||||
$osd1->mustSucceed(
|
osd1.succeed(
|
||||||
"mkfs.xfs /dev/vdb",
|
"mkfs.xfs /dev/vdb",
|
||||||
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
||||||
"mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
"mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
||||||
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
|
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
|
||||||
"echo '{\"cephx_secret\": \"${cfg.osd1.key}\"}' | ceph osd new ${cfg.osd1.uuid} -i -"
|
'echo \'{"cephx_secret": "${cfg.osd1.key}"}\' | ceph osd new ${cfg.osd1.uuid} -i -',
|
||||||
);
|
)
|
||||||
|
|
||||||
# Initialize the OSDs with regular filestore
|
# Initialize the OSDs with regular filestore
|
||||||
$osd0->mustSucceed(
|
osd0.succeed(
|
||||||
"ceph-osd -i ${cfg.osd0.name} --mkfs --osd-uuid ${cfg.osd0.uuid}",
|
"ceph-osd -i ${cfg.osd0.name} --mkfs --osd-uuid ${cfg.osd0.uuid}",
|
||||||
"chown -R ceph:ceph /var/lib/ceph/osd",
|
"chown -R ceph:ceph /var/lib/ceph/osd",
|
||||||
"systemctl start ceph-osd-${cfg.osd0.name}",
|
"systemctl start ceph-osd-${cfg.osd0.name}",
|
||||||
);
|
)
|
||||||
$osd1->mustSucceed(
|
osd1.succeed(
|
||||||
"ceph-osd -i ${cfg.osd1.name} --mkfs --osd-uuid ${cfg.osd1.uuid}",
|
"ceph-osd -i ${cfg.osd1.name} --mkfs --osd-uuid ${cfg.osd1.uuid}",
|
||||||
"chown -R ceph:ceph /var/lib/ceph/osd",
|
"chown -R ceph:ceph /var/lib/ceph/osd",
|
||||||
"systemctl start ceph-osd-${cfg.osd1.name}"
|
"systemctl start ceph-osd-${cfg.osd1.name}",
|
||||||
);
|
)
|
||||||
$monA->waitUntilSucceeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'");
|
monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'");
|
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'HEALTH_OK'");
|
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
|
||||||
|
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"ceph osd pool create multi-node-test 100 100",
|
"ceph osd pool create multi-node-test 100 100",
|
||||||
"ceph osd pool ls | grep 'multi-node-test'",
|
"ceph osd pool ls | grep 'multi-node-test'",
|
||||||
"ceph osd pool rename multi-node-test multi-node-other-test",
|
"ceph osd pool rename multi-node-test multi-node-other-test",
|
||||||
"ceph osd pool ls | grep 'multi-node-other-test'"
|
"ceph osd pool ls | grep 'multi-node-other-test'",
|
||||||
);
|
)
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep '1 pools, 100 pgs'");
|
monA.wait_until_succeeds("ceph -s | grep '1 pools, 100 pgs'")
|
||||||
$monA->mustSucceed("ceph osd pool set multi-node-other-test size 2");
|
monA.succeed("ceph osd pool set multi-node-other-test size 2")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'HEALTH_OK'");
|
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep '100 active+clean'");
|
monA.wait_until_succeeds("ceph -s | grep '100 active+clean'")
|
||||||
$monA->mustFail(
|
monA.fail(
|
||||||
"ceph osd pool ls | grep 'multi-node-test'",
|
"ceph osd pool ls | grep 'multi-node-test'",
|
||||||
"ceph osd pool delete multi-node-other-test multi-node-other-test --yes-i-really-really-mean-it"
|
"ceph osd pool delete multi-node-other-test multi-node-other-test --yes-i-really-really-mean-it",
|
||||||
);
|
)
|
||||||
|
|
||||||
# Shut down ceph on all machines in a very unpolite way
|
# Shut down ceph on all machines in a very unpolite way
|
||||||
$monA->crash;
|
monA.crash()
|
||||||
$osd0->crash;
|
osd0.crash()
|
||||||
$osd1->crash;
|
osd1.crash()
|
||||||
|
|
||||||
# Start it up
|
# Start it up
|
||||||
$osd0->start;
|
osd0.start()
|
||||||
$osd1->start;
|
osd1.start()
|
||||||
$monA->start;
|
monA.start()
|
||||||
|
|
||||||
# Ensure the cluster comes back up again
|
# Ensure the cluster comes back up again
|
||||||
$monA->succeed("ceph -s | grep 'mon: 1 daemons'");
|
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'quorum ${cfg.monA.name}'");
|
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
|
||||||
$monA->waitUntilSucceeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'");
|
monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'");
|
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'HEALTH_OK'");
|
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
name = "basic-multi-node-ceph-cluster";
|
name = "basic-multi-node-ceph-cluster";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import ./make-test.nix ({pkgs, lib, ...}:
|
import ./make-test-python.nix ({pkgs, lib, ...}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = {
|
cfg = {
|
||||||
|
@ -74,100 +74,100 @@ let
|
||||||
# For other ways to deploy a ceph cluster, look at the documentation at
|
# For other ways to deploy a ceph cluster, look at the documentation at
|
||||||
# https://docs.ceph.com/docs/master/
|
# https://docs.ceph.com/docs/master/
|
||||||
testscript = { ... }: ''
|
testscript = { ... }: ''
|
||||||
startAll;
|
start_all()
|
||||||
|
|
||||||
$monA->waitForUnit("network.target");
|
monA.wait_for_unit("network.target")
|
||||||
|
|
||||||
# Bootstrap ceph-mon daemon
|
# Bootstrap ceph-mon daemon
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"sudo -u ceph ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'",
|
"sudo -u ceph ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'",
|
||||||
"sudo -u ceph ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'",
|
"sudo -u ceph ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'",
|
||||||
"sudo -u ceph ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring",
|
"sudo -u ceph ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring",
|
||||||
"monmaptool --create --add ${cfg.monA.name} ${cfg.monA.ip} --fsid ${cfg.clusterId} /tmp/monmap",
|
"monmaptool --create --add ${cfg.monA.name} ${cfg.monA.ip} --fsid ${cfg.clusterId} /tmp/monmap",
|
||||||
"sudo -u ceph ceph-mon --mkfs -i ${cfg.monA.name} --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring",
|
"sudo -u ceph ceph-mon --mkfs -i ${cfg.monA.name} --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring",
|
||||||
"sudo -u ceph touch /var/lib/ceph/mon/ceph-${cfg.monA.name}/done",
|
"sudo -u ceph touch /var/lib/ceph/mon/ceph-${cfg.monA.name}/done",
|
||||||
"systemctl start ceph-mon-${cfg.monA.name}"
|
"systemctl start ceph-mon-${cfg.monA.name}",
|
||||||
);
|
)
|
||||||
$monA->waitForUnit("ceph-mon-${cfg.monA.name}");
|
monA.wait_for_unit("ceph-mon-${cfg.monA.name}")
|
||||||
$monA->mustSucceed("ceph mon enable-msgr2");
|
monA.succeed("ceph mon enable-msgr2")
|
||||||
|
|
||||||
# Can't check ceph status until a mon is up
|
# Can't check ceph status until a mon is up
|
||||||
$monA->succeed("ceph -s | grep 'mon: 1 daemons'");
|
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
|
||||||
|
|
||||||
# Start the ceph-mgr daemon, after copying in the keyring
|
# Start the ceph-mgr daemon, after copying in the keyring
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"sudo -u ceph mkdir -p /var/lib/ceph/mgr/ceph-${cfg.monA.name}/",
|
"sudo -u ceph mkdir -p /var/lib/ceph/mgr/ceph-${cfg.monA.name}/",
|
||||||
"ceph auth get-or-create mgr.${cfg.monA.name} mon 'allow profile mgr' osd 'allow *' mds 'allow *' > /var/lib/ceph/mgr/ceph-${cfg.monA.name}/keyring",
|
"ceph auth get-or-create mgr.${cfg.monA.name} mon 'allow profile mgr' osd 'allow *' mds 'allow *' > /var/lib/ceph/mgr/ceph-${cfg.monA.name}/keyring",
|
||||||
"systemctl start ceph-mgr-${cfg.monA.name}"
|
"systemctl start ceph-mgr-${cfg.monA.name}",
|
||||||
);
|
)
|
||||||
$monA->waitForUnit("ceph-mgr-a");
|
monA.wait_for_unit("ceph-mgr-a")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'quorum ${cfg.monA.name}'");
|
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'");
|
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
|
||||||
|
|
||||||
# Bootstrap both OSDs
|
# Bootstrap both OSDs
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"mkfs.xfs /dev/vdb",
|
"mkfs.xfs /dev/vdb",
|
||||||
"mkfs.xfs /dev/vdc",
|
"mkfs.xfs /dev/vdc",
|
||||||
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
||||||
"mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
"mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
|
||||||
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
||||||
"mount /dev/vdc /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
"mount /dev/vdc /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
|
||||||
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd0.name}/keyring --name osd.${cfg.osd0.name} --add-key ${cfg.osd0.key}",
|
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd0.name}/keyring --name osd.${cfg.osd0.name} --add-key ${cfg.osd0.key}",
|
||||||
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
|
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
|
||||||
"echo '{\"cephx_secret\": \"${cfg.osd0.key}\"}' | ceph osd new ${cfg.osd0.uuid} -i -",
|
'echo \'{"cephx_secret": "${cfg.osd0.key}"}\' | ceph osd new ${cfg.osd0.uuid} -i -',
|
||||||
"echo '{\"cephx_secret\": \"${cfg.osd1.key}\"}' | ceph osd new ${cfg.osd1.uuid} -i -"
|
'echo \'{"cephx_secret": "${cfg.osd1.key}"}\' | ceph osd new ${cfg.osd1.uuid} -i -',
|
||||||
);
|
)
|
||||||
|
|
||||||
# Initialize the OSDs with regular filestore
|
# Initialize the OSDs with regular filestore
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"ceph-osd -i ${cfg.osd0.name} --mkfs --osd-uuid ${cfg.osd0.uuid}",
|
"ceph-osd -i ${cfg.osd0.name} --mkfs --osd-uuid ${cfg.osd0.uuid}",
|
||||||
"ceph-osd -i ${cfg.osd1.name} --mkfs --osd-uuid ${cfg.osd1.uuid}",
|
"ceph-osd -i ${cfg.osd1.name} --mkfs --osd-uuid ${cfg.osd1.uuid}",
|
||||||
"chown -R ceph:ceph /var/lib/ceph/osd",
|
"chown -R ceph:ceph /var/lib/ceph/osd",
|
||||||
"systemctl start ceph-osd-${cfg.osd0.name}",
|
"systemctl start ceph-osd-${cfg.osd0.name}",
|
||||||
"systemctl start ceph-osd-${cfg.osd1.name}"
|
"systemctl start ceph-osd-${cfg.osd1.name}",
|
||||||
);
|
)
|
||||||
$monA->waitUntilSucceeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'");
|
monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'");
|
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'HEALTH_OK'");
|
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
|
||||||
|
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"ceph osd pool create single-node-test 100 100",
|
"ceph osd pool create single-node-test 100 100",
|
||||||
"ceph osd pool ls | grep 'single-node-test'",
|
"ceph osd pool ls | grep 'single-node-test'",
|
||||||
"ceph osd pool rename single-node-test single-node-other-test",
|
"ceph osd pool rename single-node-test single-node-other-test",
|
||||||
"ceph osd pool ls | grep 'single-node-other-test'"
|
"ceph osd pool ls | grep 'single-node-other-test'",
|
||||||
);
|
)
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep '1 pools, 100 pgs'");
|
monA.wait_until_succeeds("ceph -s | grep '1 pools, 100 pgs'")
|
||||||
$monA->mustSucceed(
|
monA.succeed(
|
||||||
"ceph osd getcrushmap -o crush",
|
"ceph osd getcrushmap -o crush",
|
||||||
"crushtool -d crush -o decrushed",
|
"crushtool -d crush -o decrushed",
|
||||||
"sed 's/step chooseleaf firstn 0 type host/step chooseleaf firstn 0 type osd/' decrushed > modcrush",
|
"sed 's/step chooseleaf firstn 0 type host/step chooseleaf firstn 0 type osd/' decrushed > modcrush",
|
||||||
"crushtool -c modcrush -o recrushed",
|
"crushtool -c modcrush -o recrushed",
|
||||||
"ceph osd setcrushmap -i recrushed",
|
"ceph osd setcrushmap -i recrushed",
|
||||||
"ceph osd pool set single-node-other-test size 2"
|
"ceph osd pool set single-node-other-test size 2",
|
||||||
);
|
)
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'HEALTH_OK'");
|
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep '100 active+clean'");
|
monA.wait_until_succeeds("ceph -s | grep '100 active+clean'")
|
||||||
$monA->mustFail(
|
monA.fail(
|
||||||
"ceph osd pool ls | grep 'multi-node-test'",
|
"ceph osd pool ls | grep 'multi-node-test'",
|
||||||
"ceph osd pool delete single-node-other-test single-node-other-test --yes-i-really-really-mean-it"
|
"ceph osd pool delete single-node-other-test single-node-other-test --yes-i-really-really-mean-it",
|
||||||
);
|
)
|
||||||
|
|
||||||
# Shut down ceph by stopping ceph.target.
|
# Shut down ceph by stopping ceph.target.
|
||||||
$monA->mustSucceed("systemctl stop ceph.target");
|
monA.succeed("systemctl stop ceph.target")
|
||||||
|
|
||||||
# Start it up
|
# Start it up
|
||||||
$monA->succeed("systemctl start ceph.target");
|
monA.succeed("systemctl start ceph.target")
|
||||||
$monA->waitForUnit("ceph-mon-${cfg.monA.name}");
|
monA.wait_for_unit("ceph-mon-${cfg.monA.name}")
|
||||||
$monA->waitForUnit("ceph-mgr-${cfg.monA.name}");
|
monA.wait_for_unit("ceph-mgr-${cfg.monA.name}")
|
||||||
$monA->waitForUnit("ceph-osd-${cfg.osd0.name}");
|
monA.wait_for_unit("ceph-osd-${cfg.osd0.name}")
|
||||||
$monA->waitForUnit("ceph-osd-${cfg.osd1.name}");
|
monA.wait_for_unit("ceph-osd-${cfg.osd1.name}")
|
||||||
|
|
||||||
# Ensure the cluster comes back up again
|
# Ensure the cluster comes back up again
|
||||||
$monA->succeed("ceph -s | grep 'mon: 1 daemons'");
|
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'quorum ${cfg.monA.name}'");
|
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
|
||||||
$monA->waitUntilSucceeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'");
|
monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'");
|
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
|
||||||
$monA->waitUntilSucceeds("ceph -s | grep 'HEALTH_OK'");
|
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
name = "basic-single-node-ceph-cluster";
|
name = "basic-single-node-ceph-cluster";
|
||||||
|
|
Loading…
Reference in a new issue