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:
parent
b5fcf1ad0c
commit
d62e6e0be7
2
.github/workflows/shellcheck.yml
vendored
2
.github/workflows/shellcheck.yml
vendored
@ -15,6 +15,6 @@ jobs:
|
|||||||
name: Shellcheck
|
name: Shellcheck
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Run ShellCheck
|
- name: Run ShellCheck
|
||||||
uses: ludeeus/action-shellcheck@master
|
uses: ludeeus/action-shellcheck@master
|
||||||
|
|||||||
19
.github/workflows/test.yml
vendored
Normal file
19
.github/workflows/test.yml
vendored
Normal 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
3
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
|
test.log
|
||||||
|
error.log
|
||||||
rebalance_db.txt
|
rebalance_db.txt
|
||||||
|
testing_data
|
||||||
1
test/pool/abc-123_!"§$%&()[]{}=?`#'*+-_,;.:|<>~@.txt
Normal file
1
test/pool/abc-123_!"§$%&()[]{}=?`#'*+-_,;.:|<>~@.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
||||||
1
test/pool/projects/[2020] some project/file
Normal file
1
test/pool/projects/[2020] some project/file
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
||||||
1
test/pool/projects/[2020] some project/file.txt
Normal file
1
test/pool/projects/[2020] some project/file.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
||||||
1
test/pool/projects/[2020] some project/mp4.txt
Normal file
1
test/pool/projects/[2020] some project/mp4.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
||||||
46
testing.sh
Executable file
46
testing.sh
Executable 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
|
||||||
@ -185,7 +185,7 @@ fi
|
|||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-c | --checksum )
|
-c | --checksum )
|
||||||
if [ "$2" -eq 1 ] || [[ "$2" =~ (on|true|yes) ]]; then
|
if [[ "$2" == 1 || "$2" =~ (on|true|yes) ]]; then
|
||||||
checksum_flag="true"
|
checksum_flag="true"
|
||||||
else
|
else
|
||||||
checksum_flag="false"
|
checksum_flag="false"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user