]> git.scottworley.com Git - annex-ec/blobdiff - annex-ec-test
Use more blocks on huge files.
[annex-ec] / annex-ec-test
index 013236d50c24f21afa38dfdaa75f757a6f9e167b..fe06ff21ae89ad26fa11a6d1c1272ac7ed9d2679 100755 (executable)
@@ -1,5 +1,13 @@
 #!/usr/bin/env bash
 
+# annex-ec: Use erasure codes for more efficient storage use in git-annex
+# Copyright (C) 2026  Scott Worley
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
 set -euo pipefail
 
 die() { echo "$*" >&2; exit 1; }
@@ -47,7 +55,9 @@ fsck_everything() {
     for already_deleted in "${deleted_vols[@]}";do
       if [[ "$vol" == "$already_deleted" ]];then continue 2; fi
     done
-    git -C "$(vol_dir "$vol")" annex fsck
+    pushd "$(vol_dir "$vol")"
+      git annex fsck -- *-*
+    popd
   done
 }
 
@@ -99,19 +109,30 @@ make_test_file() {
   echo "$f"
 }
 
-choose_volumes() {
+some_random_volume_names() {
   x=$(for vol in "${vols[@]}";do
         vol_name "$vol"
       done | shuf | head -n "$1" | tr \\n ,)
   echo "${x%,}"
 }
 
+a_random_volume_dir() {
+  while true;do
+    vol="${vols[$RANDOM % $num_vols]}"
+    for already_deleted in "${deleted_vols[@]}";do
+      if [[ "$vol" == "$already_deleted" ]];then continue 2; fi
+    done
+    vol_dir "$vol"
+    break
+  done
+}
+
 MIN_REDUNDANCY=1
 MIN_FILES=2 # If you only have one file in a group, you'd just make copies of it, no need for annex-ec
 MIN_VOLUMES=$((MIN_REDUNDANCY + MIN_FILES))
 
 for (( num_vols=MIN_VOLUMES; num_vols <= 10; num_vols++ ));do
-  for (( redundancy=1; redundancy < num_vols-2; redundancy++ ));do
+  for (( redundancy=1; redundancy <= num_vols-2; redundancy++ ));do
     max_files=$(( num_vols - redundancy ))
     for (( num_files=MIN_FILES; num_files <= max_files; num_files++ ));do
       make_test_vols "$num_vols"
@@ -121,17 +142,23 @@ for (( num_vols=MIN_VOLUMES; num_vols <= 10; num_vols++ ));do
       done
       sync_everything
       sync_everything
-      pushd "$(vol_dir "${vols[$RANDOM % $num_vols]}")"
-        cmd=(annex-ec -r "$redundancy" -v "$(choose_volumes $((num_files+redundancy)))" "${files[@]}")
+      pushd "$(a_random_volume_dir)"
+        cmd=(annex-ec -r "$redundancy" -v "$(some_random_volume_names $((num_files+redundancy)))" "${files[@]}")
         echo "In $PWD , running ${cmd[*]}" >&2
         "${cmd[@]}"
       popd
       sync_everything
+      sync_everything
       fsck_everything
+
       delete_some_test_vols "$redundancy"
-      # TODO: Recover
+      pushd "$(a_random_volume_dir)"
+        annex-ec-recover -- *-*
+      popd
+
+      sync_everything
       sync_everything
-      # fsck_everything # Skip this check until recovery is implemented
+      fsck_everything
       delete_all_test_vols
     done
   done