Skip to content

Commit fca1525

Browse files
committed
Improvements to blocking test
1 parent ce18814 commit fca1525

File tree

6 files changed

+136
-125
lines changed

6 files changed

+136
-125
lines changed
Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,93 +3,87 @@ This document outlines the procedures conducted to test the zstash bloclking
33
and non-blocking behavior.
44

55
Note: As it was intended to test blocking with regard to archive tar-creations
6-
vs Globus transfers, it wsa convenient to have both source snd destination be
7-
the same Globus endpoint. Effectively, we are employing Globus merely to move
6+
vs Globus transfers, it was convenient to have both source and destination be
7+
the same Globus endpoint. Effectively, we are employing Globus merely to move
88
tar archive files from one directory to another on the same file system.
99

1010
The core intent in implementing zstash blocking is to address a potential
1111
"low-disk" condition, where tar-files created to archive source files could
12-
add substantially to the disk load. To avoid disk exhaustion, "blocking"
13-
("--non-blocking" is absent on the command line), tar-file creation will
12+
add substantially to the disk load. To avoid disk exhaustion, when "blocking"
13+
(`--non-blocking` is absent on the command line), tar-file creation will
1414
pause to wait for the previous tarfile globus transfer to complete, so that
1515
the local copy can be deleted before the next tar-file is created.
1616

1717
I. File System Setup
1818
====================
1919

2020
As one may want, or need to re-conduct testing under varied conditions, the
21-
test script:
22-
23-
test_zstash_blocking.sh
24-
25-
will establish the following directory structure in the operator's current
21+
test script `test_zstash_blocking.sh` will establish the following directory structure in the operator's current
2622
working directory:
2723

28-
[CWD]/src_data/
29-
30-
- contains files to be tar-archived. One can experiment
31-
with different sizes of files to trigger behaviors.
32-
33-
[CWD]/src_data/zstash/
34-
35-
- default location of tarfiles produced. This directory is
36-
created automatically by zstash unless "--cache" indicates
37-
an alternate location.
38-
39-
[CWD]/dst_data/
24+
```
25+
[CWD]/src_data/
26+
# Contains files to be tar-archived.
27+
# One can experiment with different sizes of files to trigger behaviors.
4028
41-
- destination for Globus transfer of archives.
29+
[CWD]/src_data/zstash/
30+
# Default location of tarfiles produced.
31+
# This directory is created automatically by zstash unless
32+
# "--cache" indicates an alternate location.
4233
43-
[CWD]/tmp_cache/
34+
[CWD]/dst_data/
35+
# Destination for Globus transfer of archives.
4436
45-
- [Optional] alternative location for tar-file generation.
37+
[CWD]/tmp_cache/
38+
# [Optional] alternative location for tar-file generation.
39+
```
4640

4741
Note: It may be convenient to create a "hold" directory to store files of
4842
various sizes that can be easily produced by running the supplied scripts.
4943

50-
gen_data.sh
51-
gen_data_runner.sh
44+
```
45+
gen_data.sh
46+
gen_data_runner.sh
47+
```
5248

5349
The files to be used for a given test must be moved or copied to the src_data
5450
directory before a test is initiated.
5551

56-
Note: It never hurts to run the supplied script:
57-
58-
reset_test.sh
59-
60-
before a test run. This will delete any archives in the src_data/zstash
52+
Note: It never hurts to run the supplied script `reset_test.sh` before a test run. This will delete any archives in the src_data/zstash
6153
cache and the receiving dst_data directories, and delete the src_data/zstash
62-
directory itself if it exists. This ensures a clean restart for testing.
54+
directory itself if it exists. This ensures a clean restart for testing.
6355
The raw data files placed into src_data are not affected.
6456

6557
II. Running the Test Script
6658
===========================
6759

6860
The test script "test_zstash_blocking.sh" accepts two positional parameters:
6961

70-
test_zstash_blocking.sh (BLOCKING|NON_BLOCKING)
62+
```
63+
test_zstash_blocking.sh (BLOCKING|NON_BLOCKING)
64+
```
7165

72-
If "BLOCKING" is selected, zstash will run in default mode, waiting for
66+
If `BLOCKING` is selected, zstash will run in default mode, waiting for
7367
each tar file to complete transfer before generating another tar file.
7468

75-
If "NON_BLOCKING" is selected, the zstash flag "--non-blocking" is supplied
69+
If `NON_BLOCKING` is selected, the zstash flag `--non-blocking` is supplied
7670
to the zstash command line, and tar files continue to be created in parallel
7771
to running Globus transfers.
7872

7973
It is suggested that you run the test script with
8074

81-
test_zstash_blocking.sh (BLOCKING|NON_BLOCKING) > your_logfile 2>&1
82-
83-
so that your command prompt returns and you can monitor progress with
75+
```
76+
./test_zstash_blocking.sh (BLOCKING|NON_BLOCKING) 2>&1 | tee your_logfile
77+
```
8478

85-
snapshot.sh
86-
87-
which will provide a view of both the tarfile cache and the destination
79+
so that your command prompt returns and you can monitor progress with `snapshot.sh`, which will provide a view of both the tarfile cache and the destination
8880
directory for delivered tar files. It is also suggested that you name your
89-
logfile to reflect the date, and whether BLOCKING or not was specified.
90-
81+
logfile to reflect the date, and whether BLOCKING or not was specified. Example:
82+
```bash
83+
./test_zstash_blocking.sh BLOCKING 2>&1 | tee test_zstash_blocking_20251020.log
84+
```
9185

92-
FINAL NOTE: In the zstash code, the tar file "MINSIZE" parameter is taken
93-
to be (int) multiples of 1 GB. During testing, this had been changed to
86+
FINAL NOTE: In the zstash code, the tar file `MINSIZE` parameter is taken
87+
to be (int) multiples of 1 GB. During testing, this had been changed to
9488
"multiple of 100K" for rapid testing. It may be useful to expose this as
9589
a command line parameter for debugging purposes.

tests/integration/bash_tests/run_from_chrysalis/blocking_test_scripts/gen_data.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/integration/bash_tests/run_from_chrysalis/blocking_test_scripts/gen_data_runner.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/integration/bash_tests/run_from_chrysalis/blocking_test_scripts/reset_test.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/integration/bash_tests/run_from_chrysalis/blocking_test_scripts/snapshot.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 97 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,115 @@
11
#!/bin/bash
22

3-
if [[ $# -lt 1 ]]; then
4-
echo "Usage: text_zstash_blocking.sh (BLOCKING|NON_BLOCKING)"
5-
echo " One of \"BLOCKING\" or \"NON_BLOCKING\" must be supplied as the"
6-
echo " first parameter."
7-
exit 0
8-
fi
3+
# base_dir=`pwd`
4+
# base_dir=`realpath $base_dir`
5+
BASE_DIR="/home/ac.forsyth2/ez/zstash/tests/utils/test_blocking"
96

10-
NON_BLOCKING=1
11-
12-
if [[ $1 == "BLOCKING" ]]; then
13-
NON_BLOCKING=0
14-
elif [[ $1 == "NON_BLOCKING" ]]; then
15-
NON_BLOCKING=1
16-
else
17-
echo "ERROR: Must supply \"BLOCKING\" or \"NON_BLOCKING\" as 1st argument."
18-
exit 0
19-
fi
20-
21-
22-
base_dir=`pwd`
23-
base_dir=`realpath $base_dir`
24-
25-
26-
# See if we are running the zstash we THINK we are:
27-
echo "CALLING zstash version"
28-
zstash version
29-
echo ""
7+
# Set up Globus Endpoint UUIDs ################################################
308

319
# Selectable Endpoint UUIDs
3210
ACME1_GCSv5_UUID=6edb802e-2083-47f7-8f1c-20950841e46a
3311
LCRC_IMPROV_DTN_UUID=15288284-7006-4041-ba1a-6b52501e49f1
3412
NERSC_HPSS_UUID=9cd89cfd-6d04-11e5-ba46-22000b92c6ec
3513

36-
# 12 piControl ocean monthly files, 49 GB
37-
SRC_DATA=$base_dir/src_data
38-
DST_DATA=$base_dir/dst_data
39-
4014
SRC_UUID=$LCRC_IMPROV_DTN_UUID
4115
DST_UUID=$LCRC_IMPROV_DTN_UUID
4216

43-
# Optional
44-
TMP_CACHE=$base_dir/tmp_cache
45-
46-
mkdir -p $SRC_DATA $DST_DATA $TMP_CACHE
17+
# Test assertion functions ####################################################
18+
check_log_has()
19+
{
20+
local expected_grep="${1}"
21+
local log_file="${2}"
22+
grep -q "${expected_grep}" ${log_file}
23+
if [ $? != 0 ]; then
24+
echo "Expected grep '${expected_grep}' not found in ${log_file}. Test failed."
25+
exit 2
26+
fi
27+
}
28+
29+
check_log_does_not_have()
30+
{
31+
local not_expected_grep="${1}"
32+
local log_file="${2}"
33+
grep "${not_expected_grep}" ${log_file}
34+
if [ $? == 0 ]; then
35+
echo "Not-expected grep '${expected_grep}' was found in ${log_file}. Test failed."
36+
exit 2
37+
fi
38+
}
39+
40+
# Helper functions ############################################################
41+
make_test_dirs() {
42+
# 12 piControl ocean monthly files, 49 GB
43+
SRC_DATA=$BASE_DIR/src_data
44+
DST_DATA=$BASE_DIR/dst_data
45+
46+
mkdir -p $SRC_DATA $DST_DATA
47+
48+
echo "src_data: $SRC_DATA"
49+
echo "dst_data: $DST_DATA"
50+
}
51+
52+
generate_test_data() {
53+
i=1
54+
len=1000000 # in bytes
55+
while [[ $i -lt 12 ]]; do
56+
out=$SRC_DATA/small_0${i}_1M
57+
head -c $len </dev/urandom >$out
58+
i=$((i+1))
59+
done
60+
}
61+
62+
snapshot() {
63+
echo "dst_data:"
64+
ls -l $DST_DATA
65+
66+
echo ""
67+
echo "src_data/zstash:"
68+
ls -l $SRC_DATA/zstash
69+
}
70+
71+
remove_test_dirs() {
72+
echo "Attempting to remove $SRC_DATA/zstash/ and $DST_DATA/*"
73+
# SRC_DATA
74+
if [[ -z "$SRC_DATA" ]]; then
75+
echo "Error: SRC_DATA must be defined to delete its zstash subdirectory."
76+
else
77+
rm -rf "$SRC_DATA/zstash/"
78+
fi
79+
# DST_DATA
80+
if [[ -z "$DST_DATA" ]]; then
81+
echo "Error: DST_DATA must be defined to delete it."
82+
else
83+
rm -f "$DST_DATA/*"
84+
fi
85+
}
86+
87+
# Run tests ###################################################################
4788

4889
# Make maxsize 1 GB. This will create a new tar after every 1 GB of data.
4990
# (Since individual files are 4 GB, we will get 1 tarfile per datafile.)
50-
51-
if [[ $NON_BLOCKING -eq 1 ]]; then
52-
echo "TEST: NON_BLOCKING:"
53-
zstash create -v --hpss=globus://$DST_UUID/$DST_DATA --maxsize 1 --non-blocking $SRC_DATA
54-
else
55-
echo "TEST: BLOCKING:"
56-
zstash create -v --hpss=globus://$DST_UUID/$DST_DATA --maxsize 1 $SRC_DATA
57-
# zstash create -v --hpss=globus://$DST_UUID --maxsize 1 --non-blocking --cache $TMP_CACHE $SRC_DATA
58-
fi
91+
MAXSIZE=1 # GB
92+
93+
remove_test_dirs # Start fresh
94+
95+
echo "TEST: NON_BLOCKING"
96+
make_test_dirs
97+
generate_test_data
98+
case_name="zstash_create_non_blocking"
99+
time zstash create -v --hpss=globus://$DST_UUID/$DST_DATA --maxsize ${MAXSIZE} --non-blocking $SRC_DATA 2>&1 | tee ${case_name}.log
100+
check_log_does_not_have "A transfer with identical paths has not yet completed" ${case_name}.log
101+
snapshot
102+
remove_test_dirs
103+
104+
# echo "TEST: BLOCKING"
105+
# make_test_dirs
106+
# generate_test_data
107+
# time zstash create -v --hpss=globus://$DST_UUID/$DST_DATA --maxsize ${MAXSIZE} $SRC_DATA
108+
# snapshot
109+
# remove_test_dirs
59110

60111
echo "Testing Completed"
61-
112+
echo "Go to https://app.globus.org/activity to confirm Globus transfers completed successfully."
113+
# TODO:
114+
# Currently getting dst_data index and dst_data 000000 still in progress afer test completes in ~5 seconds...
62115
exit 0

0 commit comments

Comments
 (0)