mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Moving tests from CLI to server
This commit is contained in:
8
test/fn-api-tests/fn/log/Dockerfile
Normal file
8
test/fn-api-tests/fn/log/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM funcy/go:dev as build-stage
|
||||
WORKDIR /function
|
||||
ADD . /src
|
||||
RUN cd /src && go build -o func
|
||||
FROM funcy/go
|
||||
WORKDIR /function
|
||||
COPY --from=build-stage /src/func /function/
|
||||
ENTRYPOINT ["./func"]
|
||||
5
test/fn-api-tests/fn/log/func.yaml
Normal file
5
test/fn-api-tests/fn/log/func.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
name: funcy/log
|
||||
version: 0.0.1
|
||||
runtime: go
|
||||
entrypoint: ./func
|
||||
path: /log
|
||||
28
test/fn-api-tests/fn/log/main.go
Normal file
28
test/fn-api-tests/fn/log/main.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
)
|
||||
|
||||
const lBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
type OutputSize struct {
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
func RandStringBytes(n int) string {
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = lBytes[rand.Intn(len(lBytes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func main() {
|
||||
out := &OutputSize{}
|
||||
json.NewDecoder(os.Stdin).Decode(out)
|
||||
fmt.Fprintln(os.Stderr, RandStringBytes(out.Size))
|
||||
}
|
||||
3
test/fn-api-tests/fn/log/sample.payload.json
Normal file
3
test/fn-api-tests/fn/log/sample.payload.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"size": 1048576
|
||||
}
|
||||
8
test/fn-api-tests/fn/multi-log/Dockerfile
Normal file
8
test/fn-api-tests/fn/multi-log/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM funcy/go:dev as build-stage
|
||||
WORKDIR /function
|
||||
ADD . /src
|
||||
RUN cd /src && go build -o func
|
||||
FROM funcy/go
|
||||
WORKDIR /function
|
||||
COPY --from=build-stage /src/func /function/
|
||||
ENTRYPOINT ["./func"]
|
||||
5
test/fn-api-tests/fn/multi-log/func.yaml
Normal file
5
test/fn-api-tests/fn/multi-log/func.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
name: funcy/multi-log
|
||||
version: 0.0.1
|
||||
runtime: go
|
||||
entrypoint: ./func
|
||||
path: /multi-log
|
||||
14
test/fn-api-tests/fn/multi-log/main.go
Normal file
14
test/fn-api-tests/fn/multi-log/main.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Fprintln(os.Stderr, "First line")
|
||||
fmt.Fprintln(os.Stdout, "Ok")
|
||||
time.Sleep(3 * time.Second)
|
||||
fmt.Fprintln(os.Stderr, "Second line")
|
||||
}
|
||||
8
test/fn-api-tests/fn/timeout/Dockerfile
Normal file
8
test/fn-api-tests/fn/timeout/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM funcy/go:dev as build-stage
|
||||
WORKDIR /function
|
||||
ADD . /src
|
||||
RUN cd /src && go build -o func
|
||||
FROM funcy/go
|
||||
WORKDIR /function
|
||||
COPY --from=build-stage /src/func /function/
|
||||
ENTRYPOINT ["./func"]
|
||||
5
test/fn-api-tests/fn/timeout/func.yaml
Normal file
5
test/fn-api-tests/fn/timeout/func.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
name: funcy/timeout
|
||||
version: 0.0.1
|
||||
runtime: go
|
||||
entrypoint: ./func
|
||||
path: /timeouter
|
||||
9
test/fn-api-tests/fn/timeout/main.go
Normal file
9
test/fn-api-tests/fn/timeout/main.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
time.Sleep(32 * time.Second)
|
||||
}
|
||||
Reference in New Issue
Block a user