-
Notifications
You must be signed in to change notification settings - Fork 10
Improve tests #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Improve tests #393
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
74b0662
Add test assertions
forsyth2 ea892cc
Restructure testing directories
forsyth2 d5485cd
Add more test assertions
forsyth2 3486b0a
Fix GitHub Actions and update README
forsyth2 e4cadde
Update Chrysalis tests
forsyth2 6faaf7d
Add blocking test notes
forsyth2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # zstash Test Suite | ||
|
|
||
| ## The test directory structure | ||
|
|
||
| ``` | ||
| tests/ | ||
| integration/ # Tests that call zstash from the command line | ||
| bash_tests/ # Test zstash commands via bash scripts | ||
| run_from_chrysalis/ # Run these from Chrysalis (these use Globus and/or require the Chrysalis file system) | ||
| run_from_perlmutter/ # Run these from Perlmutter (these use `hsi` directly and/or require the Perlmutter file system) | ||
| python_tests/ # Test zstash commands via Python unittest wrappers | ||
| group_by_command # Tests organized by command | ||
| group_by_workflow # Tests organized by workflow | ||
| unit/ # Tests of pure functions (uses pytest, not unittest) | ||
| utils/ # Utilities for testing | ||
| ``` | ||
|
|
||
| ## Testing example for Perlmutter | ||
|
|
||
| ```bash | ||
| rm -rf build | ||
| conda clean --all --y | ||
| conda env create -f conda/dev.yml -n zstash_dev_20251017_test1 | ||
| conda activate zstash_dev_20251017_test1 | ||
| pre-commit run --all-files | ||
| python -m pip install . | ||
| pytest tests/unit/test_*.py | ||
| # 1 passed in 0.19s | ||
| python -m unittest tests/integration/python_tests/group_by_command/test_*.py | ||
| # Ran 69 tests in 327.570s | ||
| # OK | ||
| python -m unittest tests/integration/python_tests/group_by_workflow/test_*.py | ||
| # Ran 4 tests in 2.666s | ||
| # OK | ||
| cd tests/integration/bash_tests/run_from_perlmutter/ | ||
| time ./follow_symlinks.sh # NOTE: you will have to change out paths for your username | ||
| # real 0m31.851s | ||
| # No errors | ||
| time ./test_update_non_empty_hpss.bash | ||
| # real 0m10.062s | ||
| # No errors | ||
|
|
||
| # Log into globus.org | ||
| # Log into endpoints (NERSC Perlmutter, Globus Tutorial Collection 1) at globus.org: File Manager > Add the endpoints in the "Collection" fields | ||
| time ./test_ls_globus.bash | ||
| # real 0m26.930s | ||
| # No errors | ||
| ``` | ||
|
|
||
| ## Testing example for Chrysalis | ||
|
|
||
| ```bash | ||
| rm -rf build | ||
| conda clean --all --y | ||
| conda env create -f conda/dev.yml -n zstash_dev_20251017_test1 | ||
| conda activate zstash_dev_20251017_test1 | ||
| pre-commit run --all-files | ||
| python -m pip install . | ||
| pytest tests/unit/test_*.py | ||
| # 1 passed in 0.84s | ||
| python -m unittest tests/integration/python_tests/group_by_command/test_*.py | ||
| # Ran 69 tests in 110.139s | ||
| # OK (skipped=32) | ||
| # NOTE: Some tests are skipped because Chrysalis doesn't have direct `hsi`/HPSS access | ||
| python -m unittest tests/integration/python_tests/group_by_workflow/test_*.py | ||
| # Ran 4 tests in 6.889s | ||
| # OK | ||
| cd tests/integration/bash_tests/run_from_chrysalis/ | ||
|
|
||
| # Log into globus.org | ||
| # 1. Log into endpoints (LCRC Improv DTN, NERSC Perlmutter) at globus.org: File Manager > Add the endpoints in the "Collection" fields | ||
| # 2. To start fresh, with no consents: https://auth.globus.org/v2/web/consents > Manage Your Consents > Globus Endpoint Performance Monitoring > rescind all" | ||
| # Then, increment `try_num` below to avoid using an old directory. | ||
| # Alternatively, start fresh by deleting the directory on Perlmutter: | ||
| # `rm -rf /global/homes/f/forsyth/zstash/tests/test_globus_auth_try{try_num}` | ||
| time ./globus_auth.bash try_num # NOTE: you will have to change out paths for your username | ||
| # Paste the URL into your browser | ||
| # Log into Argonne | ||
| # Log into NERSC | ||
| # Provide a label | ||
| # Copy the auth code to the command line | ||
| # | ||
| # real 2m45.954s | ||
| # No errors | ||
|
|
||
| # If not done above, do the following: | ||
| # Log into globus.org | ||
| # Log into endpoints (LCRC Improv DTN, NERSC Perlmutter) at globus.org: File Manager > Add the endpoints in the "Collection" fields | ||
|
|
||
| # In all cases, do: | ||
| # Then, increment `try_num` below to avoid using an old directory. | ||
| # Alternatively, start fresh by deleting the directory on Perlmutter: | ||
| # `rm -rf /global/homes/f/forsyth/zstash/tests/test_database_corruption_try{try_num}` | ||
| time ./database_corruption.bash try_num # NOTE: you will have to change out paths for your username | ||
| # Success count: 25 | ||
| # Fail count: 0 | ||
| # real 6m43.994s | ||
|
|
||
| time ./symlinks.sh # NOTE: you will have to change out paths for your username | ||
| # real 0m1.346s | ||
| # No errors | ||
|
|
||
| cd blocking_test_scripts | ||
| # Review README_TEST_BLOCKING | ||
| # This uses "12 piControl ocean monthly files, 49 GB", | ||
| # so processing may take a long time. | ||
| # TODO (later PR): Confirm this test works | ||
| ``` | ||
|
|
||
| ## Testing with GitHub Actions | ||
|
|
||
| GitHub Actions runs the tests according to `.github/workflows/build_workflow.yml`: | ||
| ``` | ||
| # Run machine-independent tests | ||
| - name: Run Tests | ||
| run: | | ||
| pytest tests/unit/test_*.py | ||
| python -m unittest tests/integration/python_tests/group_by_command/test_*.py | ||
| python -m unittest tests/integration/python_tests/group_by_workflow/test_*.py | ||
| ``` |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,9 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [[ $# -lt 1 ]]; then | ||
| echo "Usage: text_zstash_blocking.sh (BLOCKING|NON_BLOCKING) [NEW_CREDS]" | ||
| echo "Usage: text_zstash_blocking.sh (BLOCKING|NON_BLOCKING)" | ||
| echo " One of \"BLOCKING\" or \"NON_BLOCKING\" must be supplied as the" | ||
| echo " first parameter." | ||
| echo " Add \"NEW_CREDS\" if Globus credentials have expired." | ||
| echo " This will cause Globus to prompt for new credentials." | ||
| exit 0 | ||
| fi | ||
|
|
||
|
|
@@ -20,14 +18,6 @@ else | |
| exit 0 | ||
| fi | ||
|
|
||
| # remove old auth data, if exists, so that globus will prompt us | ||
| # for new auth credentials in case they have expired: | ||
| if [[ $# -gt 1 ]]; then | ||
| if [[ $2 == "NEW_CREDS" ]]: then | ||
| rm -f ~/.globus-native-apps.cfg | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is no longer used, as of #380. |
||
| fi | ||
| fi | ||
|
|
||
|
|
||
| base_dir=`pwd` | ||
| base_dir=`realpath $base_dir` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
tests/integration/bash_tests/run_from_chrysalis/symlinks.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Test symlinks | ||
| # Adjusted from https://github.com/E3SM-Project/zstash/issues/341 | ||
|
|
||
| check_log_has() | ||
| { | ||
| local expected_grep="${1}" | ||
| local log_file="${2}" | ||
| grep -q "${expected_grep}" ${log_file} | ||
| if [ $? != 0 ]; then | ||
| echo "Expected grep '${expected_grep}' not found in ${log_file}. Test failed." | ||
| exit 2 | ||
| fi | ||
| } | ||
|
|
||
| test_cases() | ||
| { | ||
| local follow_symlinks=$1 | ||
| cd /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks | ||
| rm -rf workdir workdir2 workdir3 | ||
| mkdir workdir workdir2 workdir3 | ||
| cd workdir | ||
| mkdir -p src/d1 src/d2 | ||
| touch src/d1/large_file.txt | ||
|
|
||
| # This creates a symlink in d2 that links to a file in d1 | ||
| # Notice absolute path is used for source | ||
| ln -s /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir/src/d1/large_file.txt src/d2/large_file.txt | ||
|
|
||
| echo "" | ||
| echo "ls -l src/d2" | ||
| case_name="ls_1" | ||
| ls -l src/d2 2>&1 | tee ${case_name}.log | ||
| # symlink | ||
| check_log_has "large_file.txt -> /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir/src/d1/large_file.txt" ${case_name}.log | ||
|
|
||
| echo "" | ||
| case_name="create" | ||
| if [[ "${follow_symlinks,,}" == "true" ]]; then | ||
| echo "zstash create --hpss=none --follow-symlinks --cache /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir2 src/d2" | ||
| zstash create --hpss=none --follow-symlinks --cache /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir2 src/d2 2>&1 | tee ${case_name}.log | ||
| else | ||
| echo "zstash create --hpss=none --cache /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir2 src/d2" | ||
| zstash create --hpss=none --cache /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir2 src/d2 2>&1 | tee ${case_name}.log | ||
| fi | ||
| check_log_has "Adding 000000.tar" ${case_name}.log | ||
|
|
||
| echo "" | ||
| echo "ls -l src/d2" | ||
| case_name="ls_2" | ||
| ls -l src/d2 2>&1 | tee ${case_name}.log | ||
| # symlink (src is unaffected) | ||
| check_log_has "large_file.txt -> /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir/src/d1/large_file.txt" ${case_name}.log | ||
|
|
||
| cd ../workdir3 | ||
| echo "" | ||
| echo "zstash extract --hpss=none --cache /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir2" | ||
| case_name="extract" | ||
| zstash extract --hpss=none --cache /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks/workdir2 2>&1 | tee ${case_name}.log | ||
| check_log_has "No failures detected when extracting the files" ${case_name}.log | ||
|
|
||
| cd .. | ||
| echo "" | ||
| echo "ls workdir3" | ||
| case_name="ls_3" | ||
| ls workdir3 2>&1 | tee ${case_name}.log | ||
| # large_file.txt | ||
| check_log_has "large_file.txt" ${case_name}.log | ||
|
|
||
| cd /home/ac.forsyth2/ez/zstash/tests/utils/test_symlinks | ||
| rm -rf workdir workdir2 workdir3 ls_3.log | ||
|
|
||
| } | ||
|
|
||
| test_cases true | ||
| test_cases false |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, we get
AttributeError: 'TransferClient' object has no attribute 'endpoint_autoactivate'