mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: error image is now deprecated (#737)
Please use fn-test-utils instead for testing.
This commit is contained in:
6
Makefile
6
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" = "<none>" ]; 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 ./...
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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},
|
||||
|
||||
3
images/error/.gitignore
vendored
3
images/error/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
bundle/
|
||||
.bundle/
|
||||
func.yaml
|
||||
@@ -1,9 +0,0 @@
|
||||
FROM fnproject/ruby:dev
|
||||
|
||||
WORKDIR /function
|
||||
ADD Gemfile* /function/
|
||||
RUN bundle install
|
||||
|
||||
ADD . /function/
|
||||
|
||||
ENTRYPOINT ["ruby", "func.rb"]
|
||||
@@ -1,3 +0,0 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'json', '> 1.8.2'
|
||||
@@ -1,3 +0,0 @@
|
||||
# Error Function Image
|
||||
|
||||
Raises an error.
|
||||
@@ -1 +0,0 @@
|
||||
0.0.1
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
docker build --build-arg HTTPS_PROXY --build-arg HTTP_PROXY -t fnproject/error .
|
||||
@@ -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!"
|
||||
@@ -1,9 +0,0 @@
|
||||
set -e
|
||||
|
||||
fn bump
|
||||
fn build
|
||||
fn push
|
||||
|
||||
docker build -t fnproject/error:latest .
|
||||
|
||||
docker push fnproject/error:latest
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user