From 7892665ca16ed11256ee476945ac256a724c00a6 Mon Sep 17 00:00:00 2001 From: Christopher Hoffman Date: Thu, 19 Jun 2025 13:01:46 +0000 Subject: [PATCH] qa: Add interop testing between fscrypt fuse and kclient Signed-off-by: Christopher Hoffman --- .../mixed-clients/tasks/fscrypt-kbuild.yaml | 24 +++++ qa/workunits/fs/fscrypt_cli_setup.sh | 5 +- qa/workunits/fs/fscrypt_kclient_fuse.sh | 96 +++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 qa/suites/fs/mixed-clients/tasks/fscrypt-kbuild.yaml create mode 100755 qa/workunits/fs/fscrypt_kclient_fuse.sh diff --git a/qa/suites/fs/mixed-clients/tasks/fscrypt-kbuild.yaml b/qa/suites/fs/mixed-clients/tasks/fscrypt-kbuild.yaml new file mode 100644 index 0000000000000..045ada0587214 --- /dev/null +++ b/qa/suites/fs/mixed-clients/tasks/fscrypt-kbuild.yaml @@ -0,0 +1,24 @@ +tasks: +- parallel: + - user-workload + - kclient-workload +user-workload: + sequential: + - ceph-fuse: [client.0] + - workunit: + subdir: fscrypt-fuse + clients: + client.0: + - fs/fscrypt_cli_setup.sh + - fs/fscrypt_kclient_fuse.sh fuse + timeout: 4h +kclient-workload: + sequential: + - kclient: [client.1] + - workunit: + subdir: fscrypt-kclient + clients: + client.1: + - fs/fscrypt_cli_setup.sh + - fs/fscrypt_kclient_fuse.sh kclient + timeout: 4h diff --git a/qa/workunits/fs/fscrypt_cli_setup.sh b/qa/workunits/fs/fscrypt_cli_setup.sh index a6f366b4b553b..5541c676ee5f7 100755 --- a/qa/workunits/fs/fscrypt_cli_setup.sh +++ b/qa/workunits/fs/fscrypt_cli_setup.sh @@ -59,7 +59,10 @@ elif command -v yum &>/dev/null; then fi # Clone the custom fscrypt repository, build, and install -git clone https://git.ceph.com/fscrypt.git -b wip-ceph-fuse "$WORK_DIR/fscrypt" +if [ ! -d "$WORK_DIR/fscrypt" ] +then + git clone https://git.ceph.com/fscrypt.git -b wip-ceph-fuse "$WORK_DIR/fscrypt" +fi cd "$WORK_DIR/fscrypt" make sudo make install PREFIX=/usr/local diff --git a/qa/workunits/fs/fscrypt_kclient_fuse.sh b/qa/workunits/fs/fscrypt_kclient_fuse.sh new file mode 100755 index 0000000000000..e5ab10754a901 --- /dev/null +++ b/qa/workunits/fs/fscrypt_kclient_fuse.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +set -xe + +client_type=$1 +TOP=`pwd` +TOP=$(dirname "$(pwd)") +KDIR=${TOP}/kclient +FDIR=${TOP}/fuse + +setup_fscrypt_env() { + DIR=$1 + if [ ! -f /etc/fscrypt.conf ] + then + sudo fscrypt setup --force --verbose + fi + + if [ ! -d $TOP/.fscrypt ] + then + sudo fscrypt setup ${DIR} --force --verbose --all-users + sudo fscrypt status --verbose + fi +} + +encrypt_dir() { + DIR=$1 + KEY=${DIR}/../key + mkdir -p ${DIR} + + if [ ! -f ${KEY} ] + then + sudo dd if=/dev/urandom of=${KEY} bs=32 count=1 + fi + sudo fscrypt encrypt --verbose --source=raw_key --name=protector-${client_type} --no-recovery --skip-unlock --key=${KEY} ${DIR} + #sudo fscrypt encrypt --verbose --source=raw_key --name=randprotector1 --no-recovery --skip-unlock --key=${KEY} ${DIR} +} + +unlock_dir() { + DIR=$1 + KEY=${DIR}/../key + + sudo fscrypt unlock --verbose --key=${KEY} ${DIR} +} + +generate_tree() { + DIR=$1 + cd $DIR + wget -O linux.tar.xz http://download.ceph.com/qa/linux-6.5.11.tar.xz + mkdir linux + cd linux + tar xJf ../linux.tar.xz +} + +build_kernel() { + DIR=$1 + cd ${DIR} + cd linux* + make defconfig + make -j`grep -c processor /proc/cpuinfo` +} + +setup_fscrypt_env ${TOP} +K_LINUX_ROOT=${KDIR}/linux +F_LINUX_ROOT=${FDIR}/linux +case ${client_type} in + "kclient") + mkdir -p ${KDIR} + encrypt_dir ${KDIR} + unlock_dir ${KDIR} + generate_tree ${KDIR} + K_LINUX_ROOT=${KDIR}/linux + touch ${TOP}/k_ready + while [ ! -f ${TOP}/f_ready ] + do + sleep 1s + done + unlock_dir ${FDIR} + build_kernel ${F_LINUX_ROOT} + ;; + "fuse") + mkdir -p ${FDIR} + encrypt_dir ${FDIR} + unlock_dir ${FDIR} + generate_tree ${FDIR} + F_LINUX_ROOT=${FDIR}/linux + touch ${TOP}/f_ready + while [ ! -f ${TOP}/k_ready ] + do + sleep 1s + done + unlock_dir ${KDIR} + build_kernel ${K_LINUX_ROOT} + ;; + *) + echo not found + exit 1 +esac -- 2.39.5