Skip to content

Commit

Permalink
Merge pull request #4393 from AmarnatReddy/fix_createfile
Browse files Browse the repository at this point in the history
Moving file creation ops to client node
  • Loading branch information
mergify[bot] authored Jan 27, 2025
2 parents 8ad0c2d + ac84b4d commit 07f9764
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
2 changes: 1 addition & 1 deletion suites/squid/cephfs/tier-2_cephfs_test-multi-mds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ tests:
abort-on-fail: false
config:
num_of_osds: 28
num_of_files: 1000
num_of_files: 100000
- test:
name: Repeated MDS restarts
module: cephfs_multi_mds.test_cephfs_multimds_repeated_restart_mds.py
Expand Down
43 changes: 43 additions & 0 deletions tests/cephfs/cephfs_multi_mds/create_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Check for correct number of arguments
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <path> <num_of_files> <batch_size>"
exit 1
fi

# Command-line arguments
path="$1" # First argument: target directory
num_of_files="$2" # Second argument: total number of files
batch_size="$3" # Third argument: batch size

# Validate numeric inputs
if ! [[ "$num_of_files" =~ ^[0-9]+$ ]] || ! [[ "$batch_size" =~ ^[0-9]+$ ]]; then
echo "Error: num_of_files and batch_size must be positive integers."
exit 1
fi

# Ensure the target directory exists
sudo mkdir -p "$path"

# Main loop for file creation
for ((i = 0; i < num_of_files; i += batch_size)); do
batch_end=$((i + batch_size))
if ((batch_end > num_of_files)); then
batch_end=$num_of_files
fi

for ((j = i; j < batch_end; j++)); do
file_path="$path/file_$j.txt"
printf "Created file %d\n" "$j" > "$file_path"
done
done

echo "File creation completed!"

##Creating file: /mnt/cephfs-func1_fuse0o2fbln9nk_2/file_99998.txt
#Creating file: /mnt/cephfs-func1_fuse0o2fbln9nk_2/file_99999.txt
#
#real 77m25.091s
#user 11m34.726s
#sys 16m52.106s
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def run(ceph_cluster, **kw):
log.info("Cleaning up the system")
all_paths = kernel_subvol_mount_paths + fuse_subvol_mount_paths
for path in all_paths:
clients[0].exec_command(sudo=True, cmd=f"rm -rf {path}*")
clients[0].exec_command(sudo=True, cmd=f"find {path} -type f -delete")
clients[0].exec_command(sudo=True, cmd=f"umount -l {path}")
clients[0].exec_command(sudo=True, cmd=f"rm -rf {path}")
log.info("Delete Subvolumes for both filesystems")
Expand Down
20 changes: 11 additions & 9 deletions tests/cephfs/cephfs_utilsV1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4489,16 +4489,18 @@ def create_files_in_path(self, clients, path, num_of_files, batch_size):
clients.exec_command(sudo=True, cmd=create_path_cmd)

log.info(f"Path exists or created successfully: {path}")
file = "create_files.sh"
clients.upload_file(
sudo=True,
src="tests/cephfs/cephfs_multi_mds/create_files.sh",
dst=f"/root/{file}",
)

for i in range(0, num_of_files, batch_size):
batch_end = min(i + batch_size, num_of_files)
for j in range(i, batch_end):
file_path = os.path.join(path, f"file_{j}.txt")
create_file_cmd = (
f"echo 'Created files {j}' | sudo tee {file_path} > /dev/null"
)
clients.exec_command(sudo=True, cmd=create_file_cmd)
log.info(f"Created files {i} to {batch_end - 1}")
clients.exec_command(
sudo=True,
cmd=f"bash /root/{file} {path} {num_of_files} {batch_size}",
timeout=3600,
)
log.info(f"Successfully created {num_of_files} files in {path}")
except Exception as e:
log.error(f"An error occurred: {e}")
Expand Down

0 comments on commit 07f9764

Please sign in to comment.