forked from fnproject/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·66 lines (57 loc) · 1.54 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
set -ex
make build
export fn="$(pwd)/fn"
export FN_REGISTRY=$DOCKER_USER
if [[ -z "$FN_REGISTRY" ]]; then
export FN_REGISTRY=default_docker_user_does_not_push
fi
$fn --version
go test $(go list ./... | grep -v /vendor/ | grep -v /tests)
# This tests all the quickstart commands on the cli on a live server
rm -rf tmp
mkdir tmp
cd tmp
funcname="fn-test-go"
mkdir $funcname
cd $funcname
$fn init --runtime go
$fn run
$fn test
someport=50080
docker rm --force functions || true # just in case
docker pull fnproject/functions
docker run --name functions -d -v /var/run/docker.sock:/var/run/docker.sock -p $someport:8080 fnproject/functions
sleep 10
docker logs functions
export FN_API_URL="http://localhost:$someport"
$fn apps l
$fn apps create myapp
$fn apps l
$fn deploy --local --app myapp
$fn call myapp $funcname
cd ..
# Test ruby func
funcname="rubyfunc"
mkdir $funcname
cd $funcname
$fn init --runtime ruby
$fn run
$fn test
cd ..
# Test 'docker' runtime deploy
funcname="dockerfunc"
mkdir $funcname
cp ../test/funcfile-docker-rt-tests/testfiles/Dockerfile $funcname/
cp ../test/funcfile-docker-rt-tests/testfiles/func.go $funcname/
cd $funcname
$fn init --name $funcname
$fn apps create myapp1
$fn apps l
$fn deploy --local --app myapp1
$fn call myapp1 /$funcname
# todo: would be nice to have a flag to output parseable formats in cli, eg: `fn deploy --output json` would return json with version and other info
$fn routes create myapp1 /another --image $FN_REGISTRY/$funcname:0.0.2
$fn call myapp1 /another
docker rm --force functions
cd ../..
rm -rf tmp