In the case of large files, it takes a long time for the user to download the source from the URL and upload it to StorgeSvc through CLI. This PR allows a user to use URL as the function source when creating a function and provides a new flag "--keeparchiveurl" to let the user to decided whether the CLI should download the file first or store the file URL in the archive directly. If "--keeparchiveurl" is true, then no checksum will be generated, it's the user's responsibility to ensure the file won't be changed.
72 lines
1.9 KiB
Bash
Executable File
72 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
source $(dirname $0)/../utils.sh
|
|
|
|
TEST_ID=$(generate_test_id)
|
|
echo "TEST_ID = $TEST_ID"
|
|
|
|
ROOT=$(dirname $0)/../..
|
|
|
|
env=nodejs-$TEST_ID
|
|
fn=nodejs-hello-$TEST_ID
|
|
code_url=https://raw.githubusercontent.com/fission/fission/master/examples/nodejs/hello.js
|
|
base64val=$(wget -O- ${code_url} | base64)
|
|
|
|
cleanup() {
|
|
log "Cleaning up..."
|
|
clean_resource_by_id $TEST_ID
|
|
}
|
|
|
|
if [ -z "${TEST_NOCLEANUP:-}" ]; then
|
|
trap cleanup EXIT
|
|
else
|
|
log "TEST_NOCLEANUP is set; not cleaning up test artifacts afterwards."
|
|
fi
|
|
|
|
# Create a hello world function in nodejs, test it with an http trigger
|
|
log "Creating nodejs env"
|
|
fission env create --name $env --image $NODE_RUNTIME_IMAGE
|
|
|
|
log "Creating function with file"
|
|
fission fn create --name $fn --env $env --code ${code_url}
|
|
|
|
pkg=$(kubectl -n default get functions ${fn} -o yaml|grep hello-js|awk '{print $2}')
|
|
literal=$(kubectl -n default get packages ${pkg} -o yaml|grep "literal:"|awk '{print $2}')
|
|
|
|
if [ ${literal} != ${base64val} ]; then
|
|
log "have different literal value: ${literal} vs. ${base64val}"
|
|
exit 1
|
|
fi
|
|
|
|
log "Creating route"
|
|
fission route create --function $fn --url /$fn --method GET
|
|
|
|
log "Waiting for router to catch up"
|
|
sleep 3
|
|
|
|
log "Doing an HTTP GET on the function's route"
|
|
response=$(curl --retry 5 http://$FISSION_ROUTER/$fn)
|
|
|
|
log "Checking for valid response"
|
|
echo $response | grep -i hello
|
|
|
|
log "Update function with file URL"
|
|
fission fn update --name $fn --env $env --code ${code_url} --keepurl
|
|
|
|
pkg=$(kubectl -n default get functions ${fn} -o yaml|grep hello-js|awk '{print $2}')
|
|
url=$(kubectl -n default get packages ${pkg} -o yaml|grep "://"|awk '{print $2}')
|
|
|
|
if [ ${url} != ${code_url} ]; then
|
|
log "have different code url: ${url} vs. ${code_url}"
|
|
exit 1
|
|
fi
|
|
|
|
log "Doing an HTTP GET on the function's route"
|
|
response=$(curl --retry 5 http://$FISSION_ROUTER/$fn)
|
|
|
|
log "Checking for valid response"
|
|
echo $response | grep -i hello
|
|
|
|
log "All done."
|