From fdf5a67f6f50ee971225cf6f07b2563817e829d7 Mon Sep 17 00:00:00 2001 From: Tolga Ceylan Date: Mon, 5 Feb 2018 11:12:27 -0800 Subject: [PATCH] fn: error image is now deprecated (#737) Please use fn-test-utils instead for testing. --- Makefile | 6 ++---- api/agent/agent_test.go | 6 +++--- api/server/runner_async_test.go | 4 ++-- api/server/runner_test.go | 6 +++--- api/server/server_test.go | 6 +++--- images/error/.gitignore | 3 --- images/error/Dockerfile | 9 --------- images/error/Gemfile | 3 --- images/error/README.md | 3 --- images/error/VERSION | 1 - images/error/build.sh | 4 ---- images/error/func.rb | 13 ------------- images/error/release.sh | 9 --------- images/error/test.sh | 9 --------- 14 files changed, 13 insertions(+), 69 deletions(-) delete mode 100644 images/error/.gitignore delete mode 100644 images/error/Dockerfile delete mode 100644 images/error/Gemfile delete mode 100644 images/error/README.md delete mode 100644 images/error/VERSION delete mode 100755 images/error/build.sh delete mode 100644 images/error/func.rb delete mode 100755 images/error/release.sh delete mode 100755 images/error/test.sh diff --git a/Makefile b/Makefile index fd4280755..f4574292e 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ checkfmt: clear-images: -docker images -q -f dangling=true | xargs docker rmi -f - for i in fnproject/fn-test-utils fnproject/hello fnproject/error \ + for i in fnproject/fn-test-utils fnproject/hello \ fnproject/dind fnproject/fnserver fnproject/fnlb; do \ docker images "$$i" --format '{{ .ID }}\t{{ .Repository }}\t{{ .Tag}}' | while read id repo tag; do \ if [ "$$tag" = "" ]; then docker rmi "$$id"; else docker rmi "$$repo:$$tag"; fi; done; done @@ -56,8 +56,6 @@ build-static: full-test: build-static test test-api -img-error: - docker pull fnproject/error img-hello: docker pull fnproject/hello img-mysql: @@ -67,7 +65,7 @@ img-postgres: img-minio: docker pull minio/minio -pull-images: img-error img-hello img-mysql img-postgres img-minio +pull-images: img-hello img-mysql img-postgres img-minio test-datastore: cd api/datastore && go test -v ./... diff --git a/api/agent/agent_test.go b/api/agent/agent_test.go index 7151efcd1..166467e0e 100644 --- a/api/agent/agent_test.go +++ b/api/agent/agent_test.go @@ -356,15 +356,15 @@ func TestLoggerIsStringerAndWorks(t *testing.T) { func TestSubmitError(t *testing.T) { appName := "myapp" - path := "/error" - image := "fnproject/error" + path := "/" + image := "fnproject/fn-test-utils" const timeout = 10 const idleTimeout = 20 const memory = 256 CPUs := models.MilliCPUs(200) method := "GET" url := "http://127.0.0.1:8080/r/" + appName + path - payload := "payload" + payload := `{"sleepTime": 0, "isDebug": true, "isCrash": true}` typ := "sync" format := "default" config := map[string]string{ diff --git a/api/server/runner_async_test.go b/api/server/runner_async_test.go index 2188cf3b6..915e8da8e 100644 --- a/api/server/runner_async_test.go +++ b/api/server/runner_async_test.go @@ -43,7 +43,7 @@ func TestRouteRunnerAsyncExecution(t *testing.T) { {Type: "async", Path: "/hot-http", AppName: "myapp", Image: "fnproject/fn-test-utils", Format: "http", Config: map[string]string{"test": "true"}, Memory: 128, Timeout: 4, IdleTimeout: 30}, {Type: "async", Path: "/hot-json", AppName: "myapp", Image: "fnproject/fn-test-utils", Format: "json", Config: map[string]string{"test": "true"}, Memory: 128, Timeout: 4, IdleTimeout: 30}, {Type: "async", Path: "/myroute", AppName: "myapp", Image: "fnproject/hello", Config: map[string]string{"test": "true"}, Memory: 128, CPUs: 200, Timeout: 30, IdleTimeout: 30}, - {Type: "async", Path: "/myerror", AppName: "myapp", Image: "fnproject/error", Config: map[string]string{"test": "true"}, Memory: 128, Timeout: 30, IdleTimeout: 30}, + {Type: "async", Path: "/myerror", AppName: "myapp", Image: "fnproject/fn-test-utils", Config: map[string]string{"test": "true"}, Memory: 128, Timeout: 30, IdleTimeout: 30}, {Type: "async", Path: "/myroute/:param", AppName: "myapp", Image: "fnproject/hello", Config: map[string]string{"test": "true"}, Memory: 128, Timeout: 30, IdleTimeout: 30}, }, nil, ) @@ -61,7 +61,7 @@ func TestRouteRunnerAsyncExecution(t *testing.T) { {"/r/myapp/hot-json", `{"sleepTime": 0, "isDebug": true}`, map[string][]string{}, http.StatusAccepted, map[string]string{"TEST": "true", "APP": "true"}}, // FIXME: this just hangs //{"/r/myapp/myroute/1", ``, map[string][]string{}, http.StatusAccepted, map[string]string{"TEST": "true", "APP": "true"}}, - {"/r/myapp/myerror", ``, map[string][]string{}, http.StatusAccepted, map[string]string{"TEST": "true", "APP": "true"}}, + {"/r/myapp/myerror", `{"sleepTime": 0, "isDebug": true, "isCrash": true}`, map[string][]string{}, http.StatusAccepted, map[string]string{"TEST": "true", "APP": "true"}}, {"/r/myapp/myroute", `{ "name": "test" }`, map[string][]string{}, http.StatusAccepted, map[string]string{"TEST": "true", "APP": "true"}}, { "/r/myapp/myroute", diff --git a/api/server/runner_test.go b/api/server/runner_test.go index ebd00f0bb..66051c6c1 100644 --- a/api/server/runner_test.go +++ b/api/server/runner_test.go @@ -132,7 +132,7 @@ func TestRouteRunnerExecution(t *testing.T) { []*models.Route{ {Path: "/", AppName: "myapp", Image: "fnproject/hello", Type: "sync", Memory: 128, Timeout: 30, IdleTimeout: 30, Headers: map[string][]string{"X-Function": {"Test"}}}, {Path: "/myroute", AppName: "myapp", Image: "fnproject/hello", Type: "sync", Memory: 128, Timeout: 30, IdleTimeout: 30, Headers: map[string][]string{"X-Function": {"Test"}}}, - {Path: "/myerror", AppName: "myapp", Image: "fnproject/error", Type: "sync", Memory: 128, Timeout: 30, IdleTimeout: 30, Headers: map[string][]string{"X-Function": {"Test"}}}, + {Path: "/myerror", AppName: "myapp", Image: "fnproject/fn-test-utils", Type: "sync", Memory: 128, Timeout: 30, IdleTimeout: 30, Headers: map[string][]string{"X-Function": {"Test"}}}, {Path: "/mydne", AppName: "myapp", Image: "fnproject/imagethatdoesnotexist", Type: "sync", Memory: 128, Timeout: 30, IdleTimeout: 30}, {Path: "/mydnehot", AppName: "myapp", Image: "fnproject/imagethatdoesnotexist", Type: "sync", Format: "http", Memory: 128, Timeout: 30, IdleTimeout: 30}, }, nil, @@ -154,14 +154,14 @@ func TestRouteRunnerExecution(t *testing.T) { }{ {"/r/myapp/", ``, "GET", http.StatusOK, map[string][]string{"X-Function": {"Test"}}}, {"/r/myapp/myroute", ``, "GET", http.StatusOK, map[string][]string{"X-Function": {"Test"}}}, - {"/r/myapp/myerror", ``, "GET", http.StatusBadGateway, map[string][]string{"X-Function": {"Test"}}}, + {"/r/myapp/myerror", `{"sleepTime": 0, "isDebug": true, "isCrash": true}`, "GET", http.StatusBadGateway, map[string][]string{"X-Function": {"Test"}}}, {"/r/myapp/mydne", ``, "GET", http.StatusNotFound, nil}, {"/r/myapp/mydnehot", ``, "GET", http.StatusNotFound, nil}, // Added same tests again to check if time is reduced by the auth cache {"/r/myapp/", ``, "GET", http.StatusOK, map[string][]string{"X-Function": {"Test"}}}, {"/r/myapp/myroute", ``, "GET", http.StatusOK, map[string][]string{"X-Function": {"Test"}}}, - {"/r/myapp/myerror", ``, "GET", http.StatusBadGateway, map[string][]string{"X-Function": {"Test"}}}, + {"/r/myapp/myerror", `{"sleepTime": 0, "isDebug": true, "isCrash": true}`, "GET", http.StatusBadGateway, map[string][]string{"X-Function": {"Test"}}}, } { body := strings.NewReader(test.body) _, rec := routerRequest(t, srv.Router, test.method, test.path, body) diff --git a/api/server/server_test.go b/api/server/server_test.go index 95b590fcc..93a3df47a 100644 --- a/api/server/server_test.go +++ b/api/server/server_test.go @@ -134,12 +134,12 @@ func TestFullStack(t *testing.T) { {"get app", "GET", "/v1/apps/myapp", ``, http.StatusOK, 0}, // NOTE: cache is lazy, loads when a request comes in for the route, not when added {"add myroute", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute", "path": "/myroute", "image": "fnproject/hello", "type": "sync" } }`, http.StatusOK, 0}, - {"add myroute2", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute2", "path": "/myroute2", "image": "fnproject/error", "type": "sync" } }`, http.StatusOK, 0}, + {"add myroute2", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute2", "path": "/myroute2", "image": "fnproject/fn-test-utils", "type": "sync" } }`, http.StatusOK, 0}, {"get myroute", "GET", "/v1/apps/myapp/routes/myroute", ``, http.StatusOK, 0}, {"get myroute2", "GET", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 0}, {"get all routes", "GET", "/v1/apps/myapp/routes", ``, http.StatusOK, 0}, {"execute myroute", "POST", "/r/myapp/myroute", `{ "name": "Teste" }`, http.StatusOK, 1}, - {"execute myroute2", "POST", "/r/myapp/myroute2", `{ "name": "Teste" }`, http.StatusBadGateway, 2}, + {"execute myroute2", "POST", "/r/myapp/myroute2", `{"sleepTime": 0, "isDebug": true, "isCrash": true}`, http.StatusBadGateway, 2}, {"get myroute2", "GET", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 2}, {"delete myroute", "DELETE", "/v1/apps/myapp/routes/myroute", ``, http.StatusOK, 1}, {"delete myroute2", "DELETE", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 0}, @@ -238,7 +238,7 @@ func TestApiNode(t *testing.T) { {"get app", "GET", "/v1/apps/myapp", ``, http.StatusOK, 0}, {"add myroute", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute", "path": "/myroute", "image": "fnproject/hello", "type": "sync" } }`, http.StatusOK, 0}, - {"add myroute2", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute2", "path": "/myroute2", "image": "fnproject/error", "type": "sync" } }`, http.StatusOK, 0}, + {"add myroute2", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute2", "path": "/myroute2", "image": "fnproject/fn-test-utils", "type": "sync" } }`, http.StatusOK, 0}, {"add myasyncroute", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myasyncroute", "path": "/myasyncroute", "image": "fnproject/hello", "type": "async" } }`, http.StatusOK, 0}, {"get myroute", "GET", "/v1/apps/myapp/routes/myroute", ``, http.StatusOK, 0}, {"get myroute2", "GET", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 0}, diff --git a/images/error/.gitignore b/images/error/.gitignore deleted file mode 100644 index 391a9be89..000000000 --- a/images/error/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -bundle/ -.bundle/ -func.yaml diff --git a/images/error/Dockerfile b/images/error/Dockerfile deleted file mode 100644 index cf4699ac2..000000000 --- a/images/error/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM fnproject/ruby:dev - -WORKDIR /function -ADD Gemfile* /function/ -RUN bundle install - -ADD . /function/ - -ENTRYPOINT ["ruby", "func.rb"] diff --git a/images/error/Gemfile b/images/error/Gemfile deleted file mode 100644 index e05a90012..000000000 --- a/images/error/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gem 'json', '> 1.8.2' diff --git a/images/error/README.md b/images/error/README.md deleted file mode 100644 index 53164d6ff..000000000 --- a/images/error/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Error Function Image - -Raises an error. diff --git a/images/error/VERSION b/images/error/VERSION deleted file mode 100644 index 8a9ecc2ea..000000000 --- a/images/error/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.1 \ No newline at end of file diff --git a/images/error/build.sh b/images/error/build.sh deleted file mode 100755 index d1ed85342..000000000 --- a/images/error/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -ex - -docker build --build-arg HTTPS_PROXY --build-arg HTTP_PROXY -t fnproject/error . diff --git a/images/error/func.rb b/images/error/func.rb deleted file mode 100644 index a86263bda..000000000 --- a/images/error/func.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'json' - -payload = STDIN.read -if payload != "" - payload = JSON.parse(payload) - - # payload contains checks - if payload["input"] - puts payload["input"] - end -end - -raise "Something went terribly wrong!" diff --git a/images/error/release.sh b/images/error/release.sh deleted file mode 100755 index 2c2dcf935..000000000 --- a/images/error/release.sh +++ /dev/null @@ -1,9 +0,0 @@ -set -e - -fn bump -fn build -fn push - -docker build -t fnproject/error:latest . - -docker push fnproject/error:latest diff --git a/images/error/test.sh b/images/error/test.sh deleted file mode 100755 index bf4d794dc..000000000 --- a/images/error/test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -x - -./build.sh - -PAYLOAD='{"input": "yoooo"}' - -# test it -echo $PAYLOAD | docker run --rm -i -e TEST=1 username/func-error \ No newline at end of file