Skip to content

Commit

Permalink
added folder structure for testing (#7)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
markusressel authored Mar 29, 2022
1 parent b5fcf1a commit d62e6e0
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
rebalance_db.txt
test.log
error.log
rebalance_db.txt
testing_data
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
1 change: 1 addition & 0 deletions test/pool/projects/[2020] some project/file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
1 change: 1 addition & 0 deletions test/pool/projects/[2020] some project/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
1 change: 1 addition & 0 deletions test/pool/projects/[2020] some project/mp4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
46 changes: 46 additions & 0 deletions testing.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion zfs-inplace-rebalancing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d62e6e0

Please sign in to comment.