CLI to operate archives managed by Storage Service (#2450)
* Add API for listing storage service archives If id is mentioned we allow user to download specific archive. If id is not mentioned we list all archives present with storage service. This will allow us to build CLI with storage service and help users to debug storage service. * Added commands for storagesvc cli and functionalities * Reusing code and added geturl and download. * Fixed geturl for localstorage. * Fixed description of fission archive command * Added unit tests for function getstorageurl * Added integration test for archive cli Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
co-authored by
Sanket Sudake
parent
7f21b708e7
commit
21ea35b02a
@@ -57,6 +57,7 @@ main() {
|
||||
# run tests without newdeploy in parallel.
|
||||
export JOBS=6
|
||||
source $ROOT/test/run_test.sh \
|
||||
$ROOT/test/tests/test_archive_cli.sh \
|
||||
$ROOT/test/tests/test_canary.sh \
|
||||
$ROOT/test/tests/test_fn_update/test_idle_objects_reaper.sh \
|
||||
$ROOT/test/tests/mqtrigger/kafka/test_kafka.sh \
|
||||
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
source "$(dirname $0)"/../utils.sh
|
||||
|
||||
TEST_ID=$(generate_test_id)
|
||||
echo "TEST_ID = $TEST_ID"
|
||||
|
||||
tmp_dir="/tmp/test-$TEST_ID"
|
||||
mkdir -p "$tmp_dir"
|
||||
|
||||
podname=$(kubectl get pods -n fission | grep "storagesvc" |awk '{print $1}')
|
||||
|
||||
cleanup() {
|
||||
log "Cleaning up..."
|
||||
clean_resource_by_id $TEST_ID
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
||||
trap cleanup EXIT
|
||||
else
|
||||
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
||||
fi
|
||||
|
||||
create_archive() {
|
||||
log "Creating an archive"
|
||||
mkdir -p "$tmp_dir"/archive
|
||||
dd if=/dev/urandom of="$tmp_dir"/archive/dynamically_generated_file bs=256k count=1
|
||||
printf 'def main():\n return "Hello, world!"' > "$tmp_dir"/archive/hello.py
|
||||
zip -jr "$tmp_dir"/test-deploy-pkg.zip "$tmp_dir"/archive/
|
||||
}
|
||||
|
||||
# Test for upload
|
||||
create_archive
|
||||
uploadResp=$(fission ar upload --name "$tmp_dir"/test-deploy-pkg.zip)
|
||||
filename=$(echo "$uploadResp" | cut -d':' -f2 | tr -d ' ')
|
||||
|
||||
kubectl exec -i "$podname" -n fission -- /bin/sh -c "ls $filename"
|
||||
|
||||
# Test for list
|
||||
listResp=$(fission ar list)
|
||||
|
||||
echo "$listResp" | grep "$filename"
|
||||
|
||||
# Test for download
|
||||
fission ar download --id "$filename"
|
||||
|
||||
fileID=$(echo "$filename" | cut -d'/' -f4)
|
||||
|
||||
ls | grep "$fileID"
|
||||
|
||||
# Test for get-url
|
||||
getURLResp=$(fission ar get-url --id "$filename")
|
||||
|
||||
echo "$getURLResp" | grep "http://storagesvc.fission/v1/archive?id=%2Ffission%2Ffission-functions%2F$fileID"
|
||||
|
||||
# Test for delete
|
||||
fission ar delete --id "$filename"
|
||||
|
||||
fission ar list | grep -v "$filename"
|
||||
|
||||
log "Archive CLI tests done."
|
||||
Reference in New Issue
Block a user