forked from kriti-d/fission
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow non-toplevel modules in python environment (fission#1042)
- Loading branch information
1 parent
93d4f2c
commit a473335
Showing
8 changed files
with
144 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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
Empty file.
This file contains 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,2 @@ | ||
def bar(): | ||
return 'THIS_IS_FOO_BAR' |
This file contains 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,5 @@ | ||
def main(): | ||
return 'THIS_IS_MAIN_MAIN' | ||
|
||
def func(): | ||
return 'THIS_IS_MAIN_FUNC' |
Empty file.
This file contains 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,2 @@ | ||
def entrypoint(): | ||
return 'THIS_IS_ALTMAIN_ENTRYPOINT' |
This file contains 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,92 @@ | ||
#!/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 | ||
|
||
ROOT=$(dirname $0)/../../.. | ||
|
||
cleanup() { | ||
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 | ||
|
||
env_v1api=python-v1-$TEST_ID | ||
env_v2api=python-v2-$TEST_ID | ||
fn1=test-python-env-1-$TEST_ID | ||
fn2=test-python-env-2-$TEST_ID | ||
fn3=test-python-env-3-$TEST_ID | ||
fn4=test-python-env-4-$TEST_ID | ||
fn5=test-python-env-5-$TEST_ID | ||
pkg= | ||
|
||
|
||
log "Creating v1api environment ..." | ||
log "PYTHON_RUNTIME_IMAGE = $PYTHON_RUNTIME_IMAGE" | ||
fission env create \ | ||
--name $env_v1api \ | ||
--image $PYTHON_RUNTIME_IMAGE \ | ||
|
||
log "Creating v2api environment ..." | ||
log "PYTHON_RUNTIME_IMAGE = $PYTHON_RUNTIME_IMAGE PYTHON_BUILDER_IMAGE = $PYTHON_BUILDER_IMAGE" | ||
fission env create \ | ||
--name $env_v2api \ | ||
--image $PYTHON_RUNTIME_IMAGE \ | ||
--builder $PYTHON_BUILDER_IMAGE | ||
timeout 180s bash -c "wait_for_builder $env_v2api" | ||
|
||
log "Creating package ..." | ||
pushd $ROOT/test/tests/test_environments/python_src/ | ||
zip -r $tmp_dir/src-pkg.zip * | ||
popd | ||
pkg=$(fission package create --src $tmp_dir/src-pkg.zip --env $env_v2api | cut -f2 -d' '| tr -d \') | ||
timeout 60s bash -c "waitBuild $pkg" | ||
|
||
|
||
log "===== 1. test env with v1 api =====" | ||
fission fn create --name $fn1 --env $env_v1api --code $ROOT/examples/python/hello.py | ||
fission route create --function $fn1 --url /$fn1 --method GET | ||
sleep 3 # Waiting for router to catch up | ||
timeout 60 bash -c "test_fn $fn1 'Hello, world!'" | ||
|
||
|
||
log "===== 2. test entrypoint = '' =====" | ||
fission fn create --name $fn2 --env $env_v2api --pkg $pkg | ||
fission route create --function $fn2 --url /$fn2 --method GET | ||
sleep 3 # Waiting for router to catch up | ||
timeout 60 bash -c "test_fn $fn2 'THIS_IS_MAIN_MAIN'" | ||
|
||
|
||
log "===== 3. test entrypoint = func =====" | ||
fission fn create --name $fn3 --env $env_v2api --pkg $pkg --entrypoint func | ||
fission route create --function $fn3 --url /$fn3 --method GET | ||
sleep 3 # Waiting for router to catch up | ||
timeout 60 bash -c "test_fn $fn3 'THIS_IS_MAIN_FUNC'" | ||
|
||
|
||
log "===== 4. test entrypoint = foo.bar =====" | ||
fission fn create --name $fn4 --env $env_v2api --pkg $pkg --entrypoint foo.bar | ||
fission route create --function $fn4 --url /$fn4 --method GET | ||
sleep 3 # Waiting for router to catch up | ||
timeout 60 bash -c "test_fn $fn4 'THIS_IS_FOO_BAR'" | ||
|
||
|
||
log "===== 5. test entrypoint = sub_mod.altmain.entrypoint =====" | ||
fission fn create --name $fn5 --env $env_v2api --pkg $pkg --entrypoint sub_mod.altmain.entrypoint | ||
fission route create --function $fn5 --url /$fn5 --method GET | ||
sleep 3 # Waiting for router to catch up | ||
timeout 60 bash -c "test_fn $fn5 'THIS_IS_ALTMAIN_ENTRYPOINT'" | ||
|
||
|
||
log "Test PASSED" |