added folder structure for testing (#7)

* added folder structure for testing
added testing.sh script
added testing github action

* delete rebalancing file for testing

* run multiple variants of the command

* fix "integer expression expected"

* added assertions

* output logged data
This commit is contained in:
Markus Ressel 2022-03-29 04:02:13 +02:00 committed by GitHub
parent b5fcf1ad0c
commit d62e6e0be7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 75 additions and 3 deletions

View File

@ -15,6 +15,6 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

19
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,19 @@
# Test
name: Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
shellcheck:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run testing script
run: ./testing.sh

3
.gitignore vendored
View File

@ -1 +1,4 @@
test.log
error.log
rebalance_db.txt
testing_data

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
test

46
testing.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
# exit script on error
set -e
# exit on undeclared variable
set -u
log_std_file=./test.log
log_error_file=./error.log
test_data_src=./test/pool
test_pool_data_path=./testing_data
function prepare() {
# cleanup
rm -f $log_std_file
rm -f $log_error_file
rm -f rebalance_db.txt
rm -rf $test_pool_data_path
# setup
cp -rf $test_data_src $test_pool_data_path
}
function assertions() {
# check error log is empty
if grep -q '[^[:space:]]' $log_error_file; then
echo "error log is not empty!"
cat $log_error_file
exit 1
fi
}
prepare
./zfs-inplace-rebalancing.sh $test_pool_data_path >> $log_std_file 2>> $log_error_file
cat $log_std_file
assertions
prepare
./zfs-inplace-rebalancing.sh --checksum true --passes 1 $test_pool_data_path >> $log_std_file 2>> $log_error_file
cat $log_std_file
assertions
prepare
./zfs-inplace-rebalancing.sh --checksum false $test_pool_data_path >> $log_std_file 2>> $log_error_file
cat $log_std_file
assertions

View File

@ -185,7 +185,7 @@ fi
while true ; do
case "$1" in
-c | --checksum )
if [ "$2" -eq 1 ] || [[ "$2" =~ (on|true|yes) ]]; then
if [[ "$2" == 1 || "$2" =~ (on|true|yes) ]]; then
checksum_flag="true"
else
checksum_flag="false"