Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand test #59

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install coreutils
run: brew install coreutils

- name: Run testing script on macOS
run: ./testing.sh

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test.log
error.log
rebalance_db.txt
testing_data
testing_data
.vscode
84 changes: 83 additions & 1 deletion testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ log_std_file=./test.log
log_error_file=./error.log
test_data_src=./test/pool
test_pool_data_path=./testing_data
test_pool_data_size_path=$test_pool_data_path/size

## Color Constants

Expand All @@ -18,6 +19,7 @@ Color_Off='\033[0m' # Text Reset
# Regular Colors
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Cyan='\033[0;36m' # Cyan

## Functions
Expand All @@ -40,6 +42,21 @@ function prepare() {
cp -rf $test_data_src $test_pool_data_path
}

# return time to the milisecond
function get_time() {

case "$OSTYPE" in
darwin*)
date=$(gdate +%s%N)
;;
*)
date=$(date +%s%N)
;;
esac

echo "$date"
}

function assertions() {
# check error log is empty
if grep -q '[^[:space:]]' $log_error_file; then
Expand All @@ -63,6 +80,14 @@ function assert_matching_file_not_copied() {
fi
}

function print_time_taken(){
time_taken=$1
minute=$((time_taken / 60000))
seconde=$((time_taken % 60000 / 1000))
miliseconde=$((time_taken % 1000))
color_echo "$Yellow" "Time taken: ${minute}m ${seconde}s ${miliseconde}ms"
}

color_echo "$Cyan" "Running tests..."

color_echo "$Cyan" "Running tests with default options..."
Expand Down Expand Up @@ -108,4 +133,61 @@ assert_matching_file_not_copied "mp4.txt"
assertions
color_echo "$Green" "Tests passed!"

color_echo "$Green" "All tests passed!"
color_echo "$Cyan" "Running tests with different file count and size..."
prepare

mkdir -p $test_pool_data_size_path

color_echo "$Cyan" "Creating 1000 files of 1KB each..."
mkdir -p $test_pool_data_size_path/small
for i in {1..1000}; do
dd if=/dev/urandom of=$test_pool_data_size_path/small/file_"$i".txt bs=1024 count=1 >> /dev/null 2>&1
done

color_echo "$Cyan" "Creating 5 file of 1GB each..."
mkdir -p $test_pool_data_size_path/big
for i in {1..5}; do
dd if=/dev/urandom of=$test_pool_data_size_path/big/file_"$i".txt bs=1024 count=1048576 >> /dev/null 2>&1
done

color_echo "$Green" "Files created!"

echo "Running rebalancing on small files..."
# measure time taken
start_time=$(get_time)
./zfs-inplace-rebalancing.sh $test_pool_data_size_path/small >> $log_std_file 2>> $log_error_file
end_time=$(get_time)
time_taken=$(( (end_time - start_time) / 1000000 ))
print_time_taken $time_taken
assertions
color_echo "$Green" "Tests passed!"

echo "Running rebalancing on big files..."
rm -f rebalance_db.txt
# measure time taken
start_time=$(get_time)
./zfs-inplace-rebalancing.sh $test_pool_data_size_path/big >> $log_std_file 2>> $log_error_file
end_time=$(get_time)
time_taken=$(( (end_time - start_time) / 1000000 ))
print_time_taken $time_taken
assertions
color_echo "$Green" "Tests passed!"

echo "Running rebalancing on all files..."
rm -f rebalance_db.txt
# measure time taken
start_time=$(get_time)
./zfs-inplace-rebalancing.sh $test_pool_data_size_path >> $log_std_file 2>> $log_error_file
end_time=$(get_time)
time_taken=$(( (end_time - start_time) / 1000000 ))
print_time_taken $time_taken
assertions
color_echo "$Green" "Tests passed!"

color_echo "$Green" "All tests passed!"
color_echo "$Cyan" "Cleaning"
rm -f $log_std_file
rm -f $log_error_file
rm -f rebalance_db.txt
rm -rf $test_pool_data_path

Loading