Skip to content
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

test: add file command test cases #2553

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,100 @@
ANT_LOG: "v"
timeout-minutes: 2

- name: validate help Output format
shell: bash
run: |
set -e
./target/release/ant --help 2>&1 | tee help_output
env:
ANT_LOG: "v"
timeout-minutes: 2

- name: test file cost command
shell: bash
run: |
set -e
touch cost-estimate-file.txt
./target/release/ant --log-output-dest data-dir file cost cost-estimate-file.txt
./target/release/ant --log-output-dest data-dir file cost --timeout 10 cost-estimate-file.txt
./target/release/ant --log-output-dest data-dir file cost --no-verify cost-estimate-file.txt
./target/release/ant --log-output-dest data-dir file upload cost-estimate-file1.txt 2>&1 | grep "Error" # This file doesn't exist

mkdir test_cost_estimate_directory
cd test_cost_estimate_directory

for dir in {1..5}; do
mkdir subdir_$dir
for file in {1..10}; do
dd if=/dev/zero of=subdir_$dir/file_$file.bin bs=10M count=1
done
done
cd ../
./target/release/ant --log-output-dest data-dir file cost --timeout 10 test_cost_estimate_directory | grep "Error" # it is not possible to estimate this in 10 seconds
./target/release/ant --log-output-dest data-dir file cost test_cost_estimate_directory
./target/release/ant --log-output-dest data-dir file cost --no-verify test_cost_estimate_directory

rm -rf test_cost_estimate_directory
rm -rf cost-estimate-file.txt

echo "Hello world test file cost command" > test_file.txt
chmod -r test_file.txt
./target/release/ant --log-output-dest data-dir file cost test_file.txt 2>&1 | grep "Error" # This file is not readable
rm -rf test_file.txt
env:
ANT_LOG: "v"
timeout-minutes: 2

- name: test file upload and download command
shell: bash
run: |
set -e
touch upload-file.txt
echo "Hello world" > upload-file.txt
FILE_ADDR=`./target/release/ant --log-output-dest data-dir file upload upload-file.txt | grep "At address" | grep -oE '[0-9]+'`
./target/release/ant --log-output-dest data-dir file download $FILE_ADDR download-file.txt
[ "$(md5sum upload-file.txt | awk '{print $1}')" = "$(md5sum download-file.txt | awk '{print $1}')" ] && echo "Files are identical." || { echo "Files are different."; exit 1; }
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed

FILE_ADDR=`./target/release/ant --log-output-dest data-dir file upload --timeout 10 upload-file.txt | grep "At address" | grep -oE '[0-9]+'`
./target/release/antr --log-output-dest data-dir file download $FILE_ADDR download-file.txt
[ "$(md5sum upload-file.txt | awk '{print $1}')" = "$(md5sum download-file.txt | awk '{print $1}')" ] && echo "Files are identical." || { echo "Files are different."; exit 1; }
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed

FILE_ADDR='./target/release/antr --log-output-dest data-dir file upload --no-verify upload-file.txt | grep "At address" | grep -oE '[0-9]+''
./target/release/ant --log-output-dest data-dir file download $FILE_ADDR download-file.txt
[ "$(md5sum upload-file.txt | awk '{print $1}')" = "$(md5sum download-file.txt | awk '{print $1}')" ] && echo "Files are identical." || { echo "Files are different."; exit 1; }
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed

./target/release/ant --log-output-dest data-dir file upload upload-file1.txt 2>&1 | grep "Error" # This file doesn't exist
rm -rf upload-file.txt download-file.txt

mkdir test_upload_directory
cd test_upload_directory

for dir in {1..5}; do
mkdir subdir_$dir
for file in {1..10}; do
dd if=/dev/zero of=subdir_$dir/file_$file.bin bs=10M count=1
done
done
cd ../
mkdir test_download_directory
./target/release/ant --log-output-dest data-dir file upload --timeout 10 test_upload_directory | grep "Error" # it is not possible to upload this in 10 seconds

FILE_ADDR=`./target/release/ant --log-output-dest data-dir file upload test_upload_directory | grep "At address" | grep -oE '[0-9]+'`
./target/release/ant --log-output-dest data-dir file download $FILE_ADDR test_download_directory
diff -r test_upload_directory test_download_directory/test_upload_directory

rm -rf test_download_directory/test_download_directory

FILE_ADDR=`./target/release/ant --log-output-dest data-dir file upload --no-verify test_upload_directory | grep "At address" | grep -oE '[0-9]+'`
./target/release/ant --log-output-dest data-dir file download $FILE_ADDR test_download_directory
diff -r test_upload_directory test_download_directory/test_upload_directory

rm -rf test_upload_directory test_download_directory
rm -rf upload-file.txt
env:
ANT_LOG: "v"
timeout-minutes: 2

- name: create local user file
run: echo random > random.txt
env:
Expand Down
Loading