Skip to content

Commit

Permalink
FreeBSD fix and test (#55)
Browse files Browse the repository at this point in the history
* add: test on freebsd

* test fix vm

* fix: transform to lowercase

transform the `OSTYPE` to a lowercase and store it inside `OSName`

* add: caching of the vm
  • Loading branch information
meo-pill authored Jan 5, 2025
1 parent bd8d447 commit 393cbe2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,29 @@ jobs:
- uses: actions/checkout@v4

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

FreeBSDTest:
name: Test on FreeBSD
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache
key: ${{ runner.os }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
prepare: |
pkg install -y bash
run: |
./testing.sh
14 changes: 8 additions & 6 deletions zfs-inplace-rebalancing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function rebalance() {
# this shouldn't be needed in the typical case of `find` only finding files with links == 1
# but this can run for a long time, so it's good to double check if something changed
if [[ "${skip_hardlinks_flag}" == "true"* ]]; then
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
if [[ "${OSName}" == "linux-gnu"* ]]; then
# Linux
#
# -c --format=FORMAT
Expand All @@ -68,7 +68,7 @@ function rebalance() {
# %h number of hard links

hardlink_count=$(stat -c "%h" "${file_path}")
elif [[ "${OSTYPE}" == "darwin"* ]] || [[ "${OSTYPE}" == "freebsd"* ]]; then
elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
# Mac OS
# FreeBSD
# -f format
Expand Down Expand Up @@ -108,15 +108,15 @@ function rebalance() {
tmp_file_path="${file_path}${tmp_extension}"

echo "Copying '${file_path}' to '${tmp_file_path}'..."
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
if [[ "${OSName}" == "linux-gnu"* ]]; then
# Linux

# --reflink=never -- force standard copy (see ZFS Block Cloning)
# -a -- keep attributes, includes -d -- keep symlinks (dont copy target) and
# -p -- preserve ACLs to
# -x -- stay on one system
cp --reflink=never -ax "${file_path}" "${tmp_file_path}"
elif [[ "${OSTYPE}" == "darwin"* ]] || [[ "${OSTYPE}" == "freebsd"* ]]; then
elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
# Mac OS
# FreeBSD

Expand All @@ -133,7 +133,7 @@ function rebalance() {
# compare copy against original to make sure nothing went wrong
if [[ "${checksum_flag}" == "true"* ]]; then
echo "Comparing copy against original..."
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
if [[ "${OSName}" == "linux-gnu"* ]]; then
# Linux

# file attributes
Expand All @@ -156,7 +156,7 @@ function rebalance() {
copy_md5="${copy_md5} $(md5sum -b "${tmp_file_path}")"
# remove the temporary extension
copy_md5=${copy_md5%"${tmp_extension}"}
elif [[ "${OSTYPE}" == "darwin"* ]] || [[ "${OSTYPE}" == "freebsd"* ]]; then
elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
# Mac OS
# FreeBSD

Expand Down Expand Up @@ -250,6 +250,8 @@ done

root_path=$1

OSName=$(echo "$OSTYPE" | tr '[:upper:]' '[:lower:]')

color_echo "$Cyan" "Start rebalancing $(date):"
color_echo "$Cyan" " Path: ${root_path}"
color_echo "$Cyan" " Rebalancing Passes: ${passes_flag}"
Expand Down

0 comments on commit 393cbe2

Please sign in to comment.