Skip to content

Commit f3081b9

Browse files
committed
Update auth tests
1 parent ce18814 commit f3081b9

File tree

2 files changed

+116
-51
lines changed

2 files changed

+116
-51
lines changed

tests/README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ python -m unittest tests/integration/python_tests/group_by_command/test_*.py
3232
python -m unittest tests/integration/python_tests/group_by_workflow/test_*.py
3333
# Ran 4 tests in 2.666s
3434
# OK
35+
36+
cd tests/integration/bash_tests/run_from_any/
37+
# Review the directions at the bottom of globus_auth.bash
38+
# You will need to modify the file and run several times.
39+
3540
cd tests/integration/bash_tests/run_from_perlmutter/
3641
time ./follow_symlinks.sh # NOTE: you will have to change out paths for your username
3742
# real 0m31.851s
@@ -65,24 +70,12 @@ python -m unittest tests/integration/python_tests/group_by_command/test_*.py
6570
python -m unittest tests/integration/python_tests/group_by_workflow/test_*.py
6671
# Ran 4 tests in 6.889s
6772
# OK
68-
cd tests/integration/bash_tests/run_from_chrysalis/
6973

70-
# Log into globus.org
71-
# 1. Log into endpoints (LCRC Improv DTN, NERSC Perlmutter) at globus.org: File Manager > Add the endpoints in the "Collection" fields
72-
# 2. To start fresh, with no consents: https://auth.globus.org/v2/web/consents > Manage Your Consents > Globus Endpoint Performance Monitoring > rescind all"
73-
# Then, increment `try_num` below to avoid using an old directory.
74-
# Alternatively, start fresh by deleting the directory on Perlmutter:
75-
# `rm -rf /global/homes/f/forsyth/zstash/tests/test_globus_auth_try{try_num}`
76-
time ./globus_auth.bash try_num # NOTE: you will have to change out paths for your username
77-
# Paste the URL into your browser
78-
# Log into Argonne
79-
# Log into NERSC
80-
# Provide a label
81-
# Copy the auth code to the command line
82-
#
83-
# real 2m45.954s
84-
# No errors
74+
cd tests/integration/bash_tests/run_from_any/
75+
# Review the directions at the bottom of globus_auth.bash
76+
# You will need to modify the file and run several times.
8577

78+
cd tests/integration/bash_tests/run_from_chrysalis/
8679
# If not done above, do the following:
8780
# Log into globus.org
8881
# Log into endpoints (LCRC Improv DTN, NERSC Perlmutter) at globus.org: File Manager > Add the endpoints in the "Collection" fields

tests/integration/bash_tests/run_from_chrysalis/globus_auth.bash renamed to tests/integration/bash_tests/run_from_any/globus_auth.bash

Lines changed: 107 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
1-
setup()
2-
{
3-
echo "##########################################################################################################"
4-
local case_name="${1}"
5-
local src_dir="${2}"
6-
echo "Testing: ${case_name}"
7-
full_dir="${src_dir}/${case_name}"
8-
rm -rf ${full_dir}
9-
mkdir -p ${full_dir}
10-
cd ${full_dir}
11-
12-
mkdir zstash_demo
13-
mkdir zstash_demo/empty_dir
14-
mkdir zstash_demo/dir
15-
echo -n '' > zstash_demo/file_empty.txt
16-
echo 'file0 stuff' > zstash_demo/dir/file0.txt
17-
}
18-
1+
# Assertions ##################################################################
192
check_log_has()
203
{
214
local expected_grep="${1}"
@@ -38,20 +21,74 @@ check_log_does_not_have()
3821
fi
3922
}
4023

41-
run_test_cases()
24+
# Running #####################################################################
25+
setup()
4226
{
43-
local try_num=$1
27+
echo "##########################################################################################################"
28+
local case_name="${1}"
29+
local src_dir="${2}"
30+
echo "Testing: ${case_name}"
31+
full_dir="${src_dir}/${case_name}"
32+
rm -rf ${full_dir}
33+
mkdir -p ${full_dir}
34+
cd ${full_dir}
35+
36+
mkdir zstash_demo
37+
mkdir zstash_demo/empty_dir
38+
mkdir zstash_demo/dir
39+
echo -n '' > zstash_demo/file_empty.txt
40+
echo 'file0 stuff' > zstash_demo/dir/file0.txt
41+
}
42+
43+
get_endpoint()
44+
{
45+
# Usage example:
46+
# uuid=$(get_endpoint NERSC_PERLMUTTER_ENDPOINT)
4447

45-
PERLMUTTER_ENDPOINT=6bdc7956-fc0f-4ad2-989c-7aa5ee643a79
48+
local endpoint_name=$1
49+
# Define endpoints; see https://app.globus.org/collections
50+
LCRC_IMPROV_DTN_ENDPOINT=15288284-7006-4041-ba1a-6b52501e49f1
51+
NERSC_PERLMUTTER_ENDPOINT=6bdc7956-fc0f-4ad2-989c-7aa5ee643a79
52+
NERSC_HPSS_ENDPOINT=9cd89cfd-6d04-11e5-ba46-22000b92c6ec
53+
PIC_COMPY_DTN_ENDPOINT=68fbd2fa-83d7-11e9-8e63-029d279f7e24
54+
GLOBUS_TUTORIAL_COLLECTION_1_ENDPOINT=6c54cade-bde5-45c1-bdea-f4bd71dba2cc
55+
case ${endpoint_name} in
56+
LCRC_IMPROV_DTN_ENDPOINT)
57+
echo ${LCRC_IMPROV_DTN_ENDPOINT}
58+
;;
59+
NERSC_PERLMUTTER_ENDPOINT)
60+
echo ${NERSC_PERLMUTTER_ENDPOINT}
61+
;;
62+
NERSC_HPSS_ENDPOINT)
63+
echo ${NERSC_HPSS_ENDPOINT}
64+
;;
65+
PIC_COMPY_DTN_ENDPOINT)
66+
echo ${PIC_COMPY_DTN_ENDPOINT}
67+
;;
68+
GLOBUS_TUTORIAL_COLLECTION_1_ENDPOINT)
69+
echo ${GLOBUS_TUTORIAL_COLLECTION_1_ENDPOINT}
70+
;;
71+
*)
72+
echo "Unknown endpoint name: ${endpoint_name}" >&2
73+
exit 1
74+
;;
75+
esac
76+
}
4677

47-
SRC_DIR=/lcrc/group/e3sm/ac.forsyth2/zstash_testing/test_globus_auth # Chrysalis
48-
DST_DIR=globus://${PERLMUTTER_ENDPOINT}/global/homes/f/forsyth/zstash/tests/test_globus_auth_try${try_num} # Perlmutter
49-
# To start fresh with try_num=1, delete the above directory on Perlmutter before running. Example:
50-
# rm -rf /global/homes/f/forsyth/zstash/tests/test_globus_auth_try1
78+
run_test_cases()
79+
{
80+
local path_to_repo=$1
81+
local dst_endpoint=$2
82+
local dst_dir=$3
5183

52-
GLOBUS_CFG=/home/ac.forsyth2/.globus-native-apps.cfg
53-
INI_PATH=/home/ac.forsyth2/.zstash.ini
54-
TOKEN_FILE=/home/ac.forsyth2/.zstash_globus_tokens.json
84+
src_dir=${path_to_repo}/tests/utils/globus_auth
85+
mkdir -p ${src_dir}
86+
dst_endpoint_uuid=$(get_endpoint ${dst_endpoint})
87+
globus_path=globus://${dst_endpoint_uuid}/${dst_dir}
88+
89+
GLOBUS_CFG=${HOME}/.globus-native-apps.cfg
90+
INI_PATH=${HOME}/.zstash.ini
91+
TOKEN_FILE=${HOME}/.zstash_globus_tokens.json
5592

5693
# Start fresh
5794
rm -rf ${GLOBUS_CFG}
@@ -62,9 +99,9 @@ run_test_cases()
6299
echo "Exit codes: 0 -- success, 1 -- zstash failed, 2 -- grep check failed"
63100

64101
case_name="run1"
65-
setup ${case_name} "${SRC_DIR}"
102+
setup ${case_name} "${src_dir}"
66103
# Expecting to see exactly 1 authentication prompt
67-
zstash create --hpss=${DST_DIR}/${case_name} zstash_demo 2>&1 | tee ${case_name}.log
104+
zstash create --hpss=${globus_path}/${case_name} zstash_demo 2>&1 | tee ${case_name}.log
68105
if [ $? != 0 ]; then
69106
echo "${case_name} failed. Check ${case_name}_create.log for details. Cannot continue."
70107
exit 1
@@ -85,9 +122,9 @@ run_test_cases()
85122

86123

87124
case_name="run2"
88-
setup ${case_name} "${SRC_DIR}"
125+
setup ${case_name} "${src_dir}"
89126
# Expecting to see exactly 0 authentication prompts
90-
zstash create --hpss=${DST_DIR}/${case_name} zstash_demo 2>&1 | tee ${case_name}.log
127+
zstash create --hpss=${globus_path}/${case_name} zstash_demo 2>&1 | tee ${case_name}.log
91128
if [ $? != 0 ]; then
92129
echo "${case_name} failed. Check ${case_name}_create.log for details. Cannot continue."
93130
exit 1
@@ -107,15 +144,50 @@ run_test_cases()
107144
check_log_does_not_have "INFO: Tokens saved successfully" ${case_name}.log # Differs from run1
108145

109146
# This part replaces the original test_globus.py `testLs` function.
110-
zstash ls --hpss=${DST_DIR}/run1 2>&1 | tee run1_ls.log
147+
zstash ls --hpss=${globus_path}/run1 2>&1 | tee run1_ls.log
111148
check_log_has "file_empty.txt" run1_ls.log
112149
check_log_has "dir/file0.txt" run1_ls.log
113150
check_log_has "empty_dir" run1_ls.log
114-
zstash ls --hpss=${DST_DIR}/run2 2>&1 | tee run2_ls.log
151+
zstash ls --hpss=${globus_path}/run2 2>&1 | tee run2_ls.log
115152
check_log_has "file_empty.txt" run2_ls.log
116153
check_log_has "dir/file0.txt" run2_ls.log
117154
check_log_has "empty_dir" run2_ls.log
118155
# Could also test -l and -v options, but the above code covers the important part.
119156
}
120157

121-
run_test_cases "$1"
158+
# Follow these directions #####################################################
159+
# Modify these parameters as needed.
160+
161+
# Step 1. Update try_num for each new test run to avoid conflicts with previous runs.
162+
# Alternative: Remove previous test directories manually.
163+
try_num=16
164+
165+
# Step 2. Set paths for your environment by uncommenting the appropriate lines.
166+
# Running from Chrysalis:
167+
path_to_repo = /home/ac.forsyth2/ez/zstash/
168+
dst_dir = /home/ac.forsyth2/zstash/tests/test_globus_auth_try${try_num}
169+
# Running from Perlmutter:
170+
# path_to_repo = /global/homes/f/forsyth/ez/zstash
171+
# dst_dir = global/homes/f/forsyth/zstash/tests/test_globus_auth_try${try_num}
172+
# Running from Compy:
173+
# path_to_repo = /qfs/people/fors729/ez/zstash
174+
# dst_dir= /qfs/people/fors729/zstash/tests/test_globus_auth_try${try_num}
175+
176+
# Step 3. Run the test cases for each endpoint.
177+
# Do once: https://app.globus.org/file-manager?two_pane=true > For "Collection", select the endpoint for the machine you're on, and authenticate if needed.
178+
# For each line below:
179+
# A. Uncomment the appropriate line
180+
# B. https://app.globus.org/file-manager?two_pane=true > For "Collection", select the dst_endpoint name, and authenticate if needed.
181+
# C. https://auth.globus.org/v2/web/consents > Manage Your Consents > Globus Endpoint Performance Monitoring > rescind all"
182+
# D. Run the script with `./globus_auth.bash`
183+
# - Paste the URL into your browser
184+
# - Authenticate to src_endpoint if needed.
185+
# - Authenticate to dst_endpoint if needed.
186+
# - Provide a label
187+
# - Copy the auth code to the command line
188+
run_test_cases ${path_to_repo} LCRC_IMPROV_DTN_ENDPOINT ${dst_dir}
189+
run_test_cases ${path_to_repo} NERSC_PERLMUTTER_ENDPOINT ${dst_dir}
190+
run_test_cases ${path_to_repo} NERSC_HPSS_ENDPOINT ${dst_dir}
191+
run_test_cases ${path_to_repo} PIC_COMPY_DTN_ENDPOINT ${dst_dir}
192+
run_test_cases ${path_to_repo} GLOBUS_TUTORIAL_COLLECTION_1_ENDPOINT ${dst_dir}
193+

0 commit comments

Comments
 (0)