Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FDK testkit initial commit #1

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Created by .ignore support plugin (hsz.mobi)
### Go template
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
.idea
vendor/
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# build stage
FROM golang:alpine AS build-env
RUN apk --no-cache add build-base git bzr mercurial gcc
RUN go get -u github.com/golang/dep/cmd/dep
ENV D=/go/src/github.com/fnproject/fdk-testkit
ADD . $D
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my pull in fn core, should gopy only gopkg files, then do dep ensure --vendor-only, then do this add in a layer after that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

WORKDIR $D
RUN $GOPATH/bin/dep ensure
RUN go test -c -i && cp fdk-testkit.test /tmp/

# final stage
FROM fnproject/dind
WORKDIR /app
COPY --from=build-env /tmp/fdk-testkit.test /app/fdk-testkit
CMD ["./fdk-testkit"]
129 changes: 129 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/fnproject/fn_go"
version = "0.2.1"

[[constraint]]
branch = "master"
name = "github.com/go-openapi/runtime"

[[constraint]]
branch = "master"
name = "github.com/go-openapi/strfmt"
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Just builds
.PHONY: build test

build:
go test -c -i

test:
go test -v ./...
94 changes: 92 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,92 @@
# fdk-testkit
Compatibility validation tests suite for programming language-specific Fn development kits (FDK)
Testing FDK-based functions
===========================

Function development kit (FDK) as a piece of software that helps to write hot functions by encapsulating logic of processing incoming requests with respect to defined protocol (HTTP, JSON).
Particular testing framework help developers to identify if any programming language-specific FDK compatible with Fn hot formats.


Prerequisites
-------------

This testing framework allows to run FDK tests against live Fn service, to let tests know of where Fn service is hosted please set following environment variable:
```bash
export FN_API_URL=http://fn.io:8080
```

Test suite requires general purpose programming language-specific FDK-based function image that must be developed specifically for this test suite, following environment variable must be set:
```bash
export FDK_FUNCTION_IMAGE="..."
```
This environment variable should contain a reference to the particular docker image.

At this moment Fn server supports 3 formats:

- default
- http
- json

To let developers freedom of choice test suite allows to configure list of formats to test against FDK.
By default tests will use two hot formats: `json` and `http`, it's possible to override those formats using following environment format:
```bash
export FDK_FORMATS=json,http
```
Test suite details
------------------

Test suite contains following tests:

1. `TestFDKFormatSmallBody`

`TestFDKFormatSmallBody` test
--------------------------

FDK should support following formats:

- HTTP (subtest: `test-fdk-http-small-body`)
- JSON (subtest: `test-fdk-json-small-body`)

Request input body:
```json
{
"name": "Jimmy"
}
```

Response output body:
```text
Hello Jimmy
```

How to run tests?
-----------------

There are couple options: from source code, from release binary

From source code:
```bash
go test -v ./...
```

How to keep test apps and routes in place?
------------------------------------------

By default testkit runs cleanup for all app and routes created during particular execution.
In order to keep them in place to let developers work with results test suite can be configured with following boolean environment variable:
```bash
export DISABLE_TESTKIT_CLEANUP=true
```
`True` options: "1", "t", "T", "true", "TRUE", "True"
`False` options: "0", "f", "F", "false", "FALSE", "False"

How to build test binary executable?
------------------------------------

Regular `go build` does not work with tests, so following command will create a binary executable for this particular test suite:
```bash
go test -c -i
```

Sample FDK-based functions
--------------------------

As an example test suite supplied with general purpose test [function written with FDK Python](./functions/python).
Loading