diff --git a/environments/go/Dockerfile b/environments/go/Dockerfile index 7a33fa28..371f4c53 100644 --- a/environments/go/Dockerfile +++ b/environments/go/Dockerfile @@ -10,12 +10,12 @@ ADD server.go ${APP} WORKDIR ${APP} RUN go get -RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o /server server.go +RUN go build -a -o /server server.go -FROM alpine:3.7 +FROM ubuntu:18.04 WORKDIR / COPY --from=builder /server / -RUN apk -U add ca-certificates +RUN apt update && apt install -y ca-certificates && rm -rf /var/lib/apt/lists/* ENTRYPOINT ["/server"] EXPOSE 8888 diff --git a/test/build_and_test.sh b/test/build_and_test.sh index 9663a6d3..6ea249c8 100755 --- a/test/build_and_test.sh +++ b/test/build_and_test.sh @@ -38,12 +38,12 @@ build_and_push_fetcher $FETCHER_IMAGE:$TAG build_and_push_builder $BUILDER_IMAGE:$TAG -ENV='python' - -build_and_push_env_runtime $ENV $REPO/$ENV-env:$TAG +build_and_push_env_runtime python $REPO/python-env:$TAG build_and_push_env_runtime jvm $REPO/jvm-env:$TAG +build_and_push_env_runtime go $REPO/go-env:$TAG -build_and_push_env_builder $ENV $REPO/$ENV-env-builder:$TAG $BUILDER_IMAGE:$TAG +build_and_push_env_builder python $REPO/python-env-builder:$TAG $BUILDER_IMAGE:$TAG +build_and_push_env_builder go $REPO/go-env-builder:$TAG $BUILDER_IMAGE:$TAG build_and_push_fluentd $FLUENTD_IMAGE:$TAG diff --git a/test/tests/test_environments/test_go_env.sh b/test/tests/test_environments/test_go_env.sh new file mode 100755 index 00000000..311742b1 --- /dev/null +++ b/test/tests/test_environments/test_go_env.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -euo pipefail + +ROOT=$(dirname $0)/../../.. + +cleanup() { + fission fn delete --name hello-go-poolmgr || true + fission fn delete --name hello-go-nd || true + fission env delete --name go || true +} + +wait_for_builder() { + # wait for tiller ready + while true; do + kubectl --namespace fission-builder get pod -l envName=go|grep Running + if [[ $? -eq 0 ]]; then + break + fi + sleep 5 + done +} + +test_fn() { + echo "Checking for valid response" + + while true; do + response0=$(curl http://$FISSION_ROUTER/$1) + echo $response0 | grep -i $2 + if [[ $? -eq 0 ]]; then + break + fi + sleep 1 + done +} + +export -f wait_for_builder +export -f test_fn + +cd $ROOT/examples/go + +log "Creating environment for Golang" +fission env create --name go --image gcr.io/fission-ci/go-env:test --builder gcr.io/fission-ci/go-env-builder:test --period 5 + +timeout 90 bash -c "wait_for_builder" + +log "Creating pool manager & new deployment function for Golang" +fission fn create --name hello-go-poolmgr --env go --src hello.go --entrypoint Handler +fission fn create --name hello-go-nd --env go --src hello.go --entrypoint Handler --executortype newdeploy +trap cleanup EXIT + +log "Creating route for new deployment function" +fission route create --function hello-go-poolmgr --url /hello-go-poolmgr --method GET +fission route create --function hello-go-nd --url /hello-go-nd --method GET + +log "Waiting for router & pools to catch up" +sleep 5 + +log "Testing pool manager function" +timeout 60 bash -c "test_fn hello-go-poolmgr 'Hello'" + +log "Testing new deployment function" +timeout 60 bash -c "test_fn hello-go-nd 'Hello'"