Skip to content

Commit 25b606b

Browse files
committed
Add progressive deletion tests
1 parent 43963ee commit 25b606b

File tree

1 file changed

+117
-4
lines changed

1 file changed

+117
-4
lines changed

tests/integration/bash_tests/run_from_any/test_globus_tar_deletion.bash

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ test_globus_tar_deletion()
147147
check_log_has "Creating new tar archive 000000.tar" ${case_name}.log || return 2
148148

149149
echo ""
150-
echo "Checking directory status after 'zstash create' has completed. src should only have index.db. dst should have tar and index.db."
150+
echo "Checking directory status after 'zstash create' has completed."
151151
echo "Checking logs in current directory: ${PWD}"
152152

153153
echo ""
@@ -182,6 +182,98 @@ test_globus_tar_deletion()
182182
return 0 # Success
183183
}
184184

185+
test_globus_progressive_deletion()
186+
{
187+
local path_to_repo=$1
188+
local dst_endpoint=$2
189+
local dst_dir=$3
190+
local blocking_str=$4
191+
192+
src_dir=${path_to_repo}/tests/utils/globus_tar_deletion
193+
rm -rf ${src_dir}
194+
mkdir -p ${src_dir}
195+
dst_endpoint_uuid=$(get_endpoint ${dst_endpoint})
196+
globus_path=globus://${dst_endpoint_uuid}/${dst_dir}
197+
198+
case_name=${blocking_str}_progressive_deletion
199+
echo "Running test_globus_progressive_deletion on case=${case_name}"
200+
echo "Exit codes: 0 -- success, 1 -- zstash failed, 2 -- grep check failed"
201+
202+
setup ${case_name} "${src_dir}"
203+
204+
# Create files totaling >2 GB to trigger multiple tars with maxsize=1 GB
205+
# Each file is ~700 MB, so we'll get 3 tars
206+
echo "Creating large test files (this may take a minute)..."
207+
dd if=/dev/zero of=zstash_demo/file1.dat bs=1M count=700 2>/dev/null # 700 MB
208+
dd if=/dev/zero of=zstash_demo/file2.dat bs=1M count=700 2>/dev/null # 700 MB
209+
dd if=/dev/zero of=zstash_demo/file3.dat bs=1M count=700 2>/dev/null # 700 MB
210+
echo "✓ Test files created"
211+
212+
if [ "$blocking_str" == "non-blocking" ]; then
213+
blocking_flag="--non-blocking"
214+
else
215+
blocking_flag=""
216+
fi
217+
218+
# Run with maxsize=1 GB to create multiple tars
219+
echo "Running zstash create (this may take several minutes due to file size and transfers)..."
220+
zstash create ${blocking_flag} --hpss=${globus_path}/${case_name} --maxsize 1 -v zstash_demo 2>&1 | tee ${case_name}.log
221+
if [ $? != 0 ]; then
222+
echo "${case_name} failed."
223+
return 1
224+
fi
225+
226+
# Check that multiple tar files were created
227+
tar_count=$(grep -c "Creating new tar archive" ${case_name}.log)
228+
if [ ${tar_count} -lt 2 ]; then
229+
echo "Expected at least 2 tar archives to be created, found ${tar_count}"
230+
return 2
231+
fi
232+
echo "✓ Created ${tar_count} tar archives"
233+
234+
# Check that files were deleted progressively
235+
deletion_count=$(grep -c "Deleting .* files from successful transfer" ${case_name}.log)
236+
237+
if [ "$blocking_str" == "blocking" ]; then
238+
# In blocking mode, we should see deletion after each tar transfer
239+
if [ ${deletion_count} -lt $((tar_count - 1)) ]; then
240+
echo "Expected at least $((tar_count - 1)) deletion events in blocking mode, found ${deletion_count}"
241+
return 2
242+
fi
243+
echo "✓ Files deleted progressively (${deletion_count} deletion events)"
244+
else
245+
# In non-blocking mode, deletions happen when we check status
246+
if [ ${deletion_count} -lt 1 ]; then
247+
echo "Expected at least 1 deletion event in non-blocking mode, found ${deletion_count}"
248+
return 2
249+
fi
250+
echo "✓ Files deleted (${deletion_count} deletion events in non-blocking mode)"
251+
fi
252+
253+
# Verify that NO tar files remain in source after completion
254+
echo "Checking that no tar files remain in source"
255+
ls ${src_dir}/${case_name}/zstash_demo/zstash/*.tar 2>&1 | tee ls_tar_check.log
256+
if grep -q "\.tar" ls_tar_check.log && ! grep -q "No such file" ls_tar_check.log; then
257+
echo "Found tar files that should have been deleted!"
258+
return 2
259+
fi
260+
echo "✓ All tar files successfully deleted from source"
261+
262+
# Verify tar files exist in destination
263+
if [ "$blocking_str" == "non-blocking" ]; then
264+
wait_for_directory "${dst_dir}/${case_name}" || return 1
265+
fi
266+
267+
dst_tar_count=$(ls ${dst_dir}/${case_name}/*.tar 2>/dev/null | wc -l)
268+
if [ ${dst_tar_count} -ne ${tar_count} ]; then
269+
echo "Expected ${tar_count} tar files in destination, found ${dst_tar_count}"
270+
return 2
271+
fi
272+
echo "✓ All ${tar_count} tar files present in destination"
273+
274+
return 0
275+
}
276+
185277
# Follow these directions #####################################################
186278

187279
# Example usage:
@@ -233,7 +325,14 @@ run_test_with_tracking() {
233325
echo "Running: ${test_name}"
234326
echo "=========================================="
235327

236-
if test_globus_tar_deletion "${args[@]}"; then
328+
# Determine which test function to call based on test name
329+
if [[ "${test_name}" == *"progressive"* ]]; then
330+
test_func=test_globus_progressive_deletion
331+
else
332+
test_func=test_globus_tar_deletion
333+
fi
334+
335+
if ${test_func} "${args[@]}"; then
237336
# Print test result in the output block AND at the end
238337
echo "${test_name} PASSED"
239338
test_results+=("${test_name} PASSED") # Uses Global variable
@@ -253,15 +352,29 @@ tests_passed=0
253352
tests_failed=0
254353
test_results=() # Global variable to hold test results
255354

256-
echo "Primary tests: single authentication code tests for each endpoint"
355+
echo "Primary tests: basic functionality tests"
257356
echo "If a test hangs, check if https://app.globus.org/activity reports any errors on your transfers."
258357

259-
# Run all tests independently
358+
# Run basic tests
359+
# These check that AT THE END of the run,
360+
# we either still have the files (keep) or the files are deleted (non-keep).
260361
run_test_with_tracking "blocking_non-keep" ${path_to_repo} ${endpoint_str} ${machine_dst_dir} "blocking" "non-keep" || true
261362
run_test_with_tracking "non-blocking_non-keep" ${path_to_repo} ${endpoint_str} ${machine_dst_dir} "non-blocking" "non-keep" || true
262363
run_test_with_tracking "blocking_keep" ${path_to_repo} ${endpoint_str} ${machine_dst_dir} "blocking" "keep" || true
263364
run_test_with_tracking "non-blocking_keep" ${path_to_repo} ${endpoint_str} ${machine_dst_dir} "non-blocking" "keep" || true
264365

366+
echo ""
367+
echo "Progressive deletion tests: verify files are deleted as transfers complete"
368+
echo "WARNING: These tests create ~2GB of data and will take several minutes"
369+
370+
# Run progressive deletion tests
371+
# Thes check that DURING the run,
372+
# files are deleted after successful transfers (non-keep only).
373+
# Blocking -- get files, transfer files, delete at src, start next transfer.
374+
# Non-blocking -- get files, transfer files, get next set of files, transfer those files, check if previous transfer is done (and if so, delete at src).
375+
run_test_with_tracking "blocking_progressive_deletion" ${path_to_repo} ${endpoint_str} ${machine_dst_dir} "blocking" || true
376+
run_test_with_tracking "non-blocking_progressive_deletion" ${path_to_repo} ${endpoint_str} ${machine_dst_dir} "non-blocking" || true
377+
265378
# Print summary
266379
echo ""
267380
echo "=========================================="

0 commit comments

Comments
 (0)