Initial import of the existing CephFS subvolume migration prototype, including the native libcephfs transport, rsync backend, local Ceph lab environment and integration tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
3.0 KiB
Bash
62 lines
3.0 KiB
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
mountpoint -q /mnt/source
|
|
mountpoint -q /mnt/target
|
|
mountpoint -q /mnt/source-fs
|
|
test_dir=".cephmig-smoke-$(cat /proc/sys/kernel/random/uuid)"
|
|
source_ceph() {
|
|
ceph -c /clusters/source/ceph.conf -k /clusters/source/ceph.client.admin.keyring "$@"
|
|
}
|
|
snapshot_created=false
|
|
cleanup() {
|
|
if [[ $snapshot_created = true ]]; then
|
|
source_ceph fs subvolume snapshot rm cephfs demo "$test_dir" --group_name migration
|
|
fi
|
|
rm -rf "/mnt/source/$test_dir" "/mnt/target/$test_dir"
|
|
}
|
|
trap cleanup EXIT
|
|
mkdir "/mnt/source/$test_dir" "/mnt/target/$test_dir"
|
|
printf 'cephmig source\n' > "/mnt/source/$test_dir/file"
|
|
ln "/mnt/source/$test_dir/file" "/mnt/source/$test_dir/hardlink"
|
|
ln -s file "/mnt/source/$test_dir/symlink"
|
|
truncate -s 16777216 "/mnt/source/$test_dir/sparse"
|
|
chmod 0640 "/mnt/source/$test_dir/file"
|
|
python3 - "/mnt/source/$test_dir/file" <<'PY'
|
|
import os, struct, sys
|
|
os.setxattr(sys.argv[1], 'user.cephmig', b'preserve-me')
|
|
# POSIX ACL: owner rw, named user 12345 r, group ---, mask r, other ---.
|
|
entries = [(1, 6, 0xffffffff), (2, 4, 12345), (4, 0, 0xffffffff),
|
|
(16, 4, 0xffffffff), (32, 0, 0xffffffff)]
|
|
acl = struct.pack('<I', 2) + b''.join(struct.pack('<HHI', *e) for e in entries)
|
|
os.setxattr(sys.argv[1], 'system.posix_acl_access', acl)
|
|
PY
|
|
source_ceph fs subvolume snapshot create cephfs demo "$test_dir" --group_name migration
|
|
snapshot_created=true
|
|
snapshot_path=$(source_ceph fs subvolume snapshot getpath cephfs demo "$test_dir" migration)
|
|
snapshot="/mnt/source-fs$snapshot_path/$test_dir"
|
|
# Continue writes on the live subvolume while copying its immutable snapshot.
|
|
printf 'live write after snapshot\n' > "/mnt/source/$test_dir/file"
|
|
cp -a "$snapshot/." "/mnt/target/$test_dir/"
|
|
diff -r "$snapshot" "/mnt/target/$test_dir"
|
|
test "$(cat "/mnt/target/$test_dir/file")" = 'cephmig source'
|
|
test "$(cat "/mnt/source/$test_dir/file")" = 'live write after snapshot'
|
|
test "$(stat -c %a "/mnt/target/$test_dir/file")" = 640
|
|
python3 - "$snapshot/file" "/mnt/target/$test_dir/file" <<'PY'
|
|
import os, sys
|
|
assert os.getxattr(sys.argv[2], 'user.cephmig') == b'preserve-me'
|
|
assert os.getxattr(sys.argv[1], 'system.posix_acl_access') == os.getxattr(sys.argv[2], 'system.posix_acl_access')
|
|
PY
|
|
# Quotas belong to directories and need explicit handling beyond file copying.
|
|
python3 - "/mnt/source/$test_dir" "/mnt/target/$test_dir" <<'PY'
|
|
import os, sys
|
|
for path in sys.argv[1:]:
|
|
os.setxattr(path, 'ceph.quota.max_bytes', b'33554432')
|
|
assert os.getxattr(path, 'ceph.quota.max_bytes') == b'33554432'
|
|
os.setxattr(path, 'ceph.quota.max_bytes', b'0')
|
|
PY
|
|
test "$(stat -c %i "/mnt/target/$test_dir/file")" = "$(stat -c %i "/mnt/target/$test_dir/hardlink")"
|
|
test "$(readlink "/mnt/target/$test_dir/symlink")" = file
|
|
printf 'target only\n' > "/mnt/target/$test_dir/isolated"
|
|
test ! -e "/mnt/source/$test_dir/isolated"
|
|
echo 'PASS: independent clusters, snapshot copy with live changes, permissions, POSIX ACL, xattr, quota operations, hardlink, symlink, sparse-file contents'
|